Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jul 2015 18:30:41 +0000
From:      Raviprakash Darbha <rdarbha@juniper.net>
To:        "freebsd-scsi@freebsd.org" <freebsd-scsi@freebsd.org>, "freebsd-geom@freebsd.org" <freebsd-geom@freebsd.org>
Cc:        Raviprakash Darbha <rdarbha@juniper.net>
Subject:   questions about camcontrol eject
Message-ID:  <FE8D9CAE-003A-43AA-A7CD-84B4372243C7@juniper.net>

next in thread | raw e-mail | index | archive | help
Hello All

I am trying to get cam control eject working on my router with 2 drives for=
 sometime and have some observations from the code.

While allocating memory for ccb we either have a malloc option or a memory =
pool. In the eject case we choose the memory pool as its low priority.
After getting the ccb and setting the relevant fields it is submitted to th=
e ata_action routine but then it fails there returning an error code .

//Code snippets
from sys/cam/scsi/scsi-pass.c


                /*
                 * Non-immediate CCBs need a CCB from the per-device pool
                 * of CCBs, which is scheduled by the transport layer.
                 * Immediate CCBs and user-supplied CCBs should just be
                 * malloced.
                 */
                if ((inccb->ccb_h.func_code & XPT_FC_QUEUED)
                 && ((inccb->ccb_h.func_code & XPT_FC_USER_CCB) =3D=3D 0)) =
{
                        ccb =3D cam_periph_getccb(periph, priority);
                        ccb_malloced =3D 0;

                } else {
                        ccb =3D xpt_alloc_ccb_nowait();

                        if (ccb !=3D NULL)
                                xpt_setup_ccb(&ccb->ccb_h, periph->path,
                                              priority);
                        ccb_malloced =3D 1;

                }

                if (ccb =3D=3D NULL) {
                        xpt_print(periph->path, "unable to allocate CCB\n")=
;
                        error =3D ENOMEM;
                        break;
                }

                error =3D passsendccb(periph, ccb, inccb);


from sys/cam/ata/ata/xpt.c

  {
                struct cam_ed *device;
                u_int   maxlen =3D 0;

                device =3D start_ccb->ccb_h.path->device;
                if (device->protocol =3D=3D PROTO_SCSI &&
                    (device->flags & CAM_DEV_IDENTIFY_DATA_VALID)) {
                        uint16_t p =3D
                            device->ident_data.config & ATA_PROTO_MASK;

                        maxlen =3D
                            (device->ident_data.config =3D=3D ATA_PROTO_CFA=
) ? 0 :
                            (p =3D=3D ATA_PROTO_ATAPI_16) ? 16 :
                            (p =3D=3D ATA_PROTO_ATAPI_12) ? 12 : 0;
///// maxlen is still set to 0.
               }
                if (start_ccb->csio.cdb_len > maxlen) {
                        start_ccb->ccb_h.status =3D CAM_REQ_INVALID;
                        xpt_done(start_ccb);
                        break;
///// hence returning from  here.
                }
                xpt_action_default(start_ccb);
                break;
        }


My question is if this is a code path thats expected to run this way in whi=
ch case I am missing something or is this a bug ? In the later case I am as=
suming the ccb_hdr is not set correctly in case we get the ccb from the poo=
l so i m considering to set it by calling  xpt_ccb_setup in that case too t=
o get the right values in the device structure.

Any help is greatly appreciated here. Please let me know if more informatio=
n is needed.

Thanks
Ravi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FE8D9CAE-003A-43AA-A7CD-84B4372243C7>