From owner-freebsd-scsi@freebsd.org Tue Jul 7 18:30:50 2015 Return-Path: Delivered-To: freebsd-scsi@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90B42994428; Tue, 7 Jul 2015 18:30:50 +0000 (UTC) (envelope-from rdarbha@juniper.net) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0105.outbound.protection.outlook.com [65.55.169.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 010AB1F28; Tue, 7 Jul 2015 18:30:49 +0000 (UTC) (envelope-from rdarbha@juniper.net) Received: from DM2PR0501MB1150.namprd05.prod.outlook.com (10.160.245.152) by DM2PR0501MB1151.namprd05.prod.outlook.com (10.160.245.153) with Microsoft SMTP Server (TLS) id 15.1.201.16; Tue, 7 Jul 2015 18:30:41 +0000 Received: from DM2PR0501MB1150.namprd05.prod.outlook.com ([10.160.245.152]) by DM2PR0501MB1150.namprd05.prod.outlook.com ([10.160.245.152]) with mapi id 15.01.0201.000; Tue, 7 Jul 2015 18:30:41 +0000 From: Raviprakash Darbha To: "freebsd-scsi@freebsd.org" , "freebsd-geom@freebsd.org" CC: Raviprakash Darbha Subject: questions about camcontrol eject Thread-Topic: questions about camcontrol eject Thread-Index: AQHQuOMHih5nUrGIREWDx+FWI6Z8KQ== Date: Tue, 7 Jul 2015 18:30:41 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: freebsd.org; dkim=none (message not signed) header.d=none; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [66.129.239.14] x-microsoft-exchange-diagnostics: 1; DM2PR0501MB1151; 5:G//G3T20fMKE7BG/ESagbBtUs5sLap+IGaTdwTbiwtemfHgARKC8uRV/VZQUK5FASwMZ6/rta/87LnMG8WE9lY8q3BB81KJpgYyJMKSiEXEuLPnM47KqP3dqubUixP0rklsKr0pXSNkxefVR80x+4w==; 24:3FsK8Ba/EHQmABNIjxLjiO2KK14hjCyujOTd7+PKviOeW3LlwfA28SDCJIn/z7WFovWQHwHKMp+34ZAtJBqPJZJHVmNvSQOWqtUJb8yjlDU=; 20:wZDiY42HqZsHXpgzbqEB2ERJ+DGpD01DUjn+0oCsFvPGx8I3vvZYiTmFYMMWZqxuJ4o8Uq29hVDNTe44mRMbQA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0501MB1151; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:DM2PR0501MB1151; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0501MB1151; x-forefront-prvs: 0630013541 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(53754006)(46102003)(36756003)(229853001)(77156002)(62966003)(54356999)(50986999)(92566002)(16236675004)(77096005)(2656002)(102836002)(122556002)(83716003)(40100003)(2900100001)(99286002)(450100001)(2501003)(87936001)(19580395003)(86362001)(106116001)(5001770100001)(107886002)(5001960100002)(189998001)(82746002)(33656002)(66066001)(5002640100001)(158833001)(4001430100001)(104396002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0501MB1151; H:DM2PR0501MB1150.namprd05.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; MIME-Version: 1.0 X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2015 18:30:41.6811 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0501MB1151 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2015 18:30:50 -0000 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