From owner-svn-src-all@FreeBSD.ORG Thu Jun 19 16:57:27 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 165B66EA; Thu, 19 Jun 2014 16:57:27 +0000 (UTC) Received: from mail-qg0-x22b.google.com (mail-qg0-x22b.google.com [IPv6:2607:f8b0:400d:c04::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 99E502451; Thu, 19 Jun 2014 16:57:26 +0000 (UTC) Received: by mail-qg0-f43.google.com with SMTP id z60so2401291qgd.30 for ; Thu, 19 Jun 2014 09:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=dFCIQ2n0RxMlFmlJJzSto4+xpcCLKDAcqc/Ls4xjhZY=; b=CBjXrD0BhEUytDd+hD9QrPgrY2XcFBPjuw17VCmG0kNh5ZJZbUe8wyQ3Y9zOVuuwqn QPbIMIgU/4xc1QMMV4o1Y9BopYsVceCci6EO5TOYGkUFdp2wUiWUL8W28aaMj4AOSWgf 49GA5NKvscFVo+X7Bd6+GIyLLjIitxmYNWan4yZn7YNNZ6Ye5tVjgS83GRur0AxMvsKC XK29A4rbVZV2jWQxREwscvg/zks3NVcToeAku403DGlHX5/sakfOq6zrd4W68vxM7c7w JrTHVPFt507K7WXPIstRYQSS5h27WoPrXkMln/HUgTRoHBi2e/TV3vZSidPtpV3tJEsz Y+Ng== MIME-Version: 1.0 X-Received: by 10.224.130.136 with SMTP id t8mr9277727qas.49.1403197045785; Thu, 19 Jun 2014 09:57:25 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.224.43.134 with HTTP; Thu, 19 Jun 2014 09:57:25 -0700 (PDT) In-Reply-To: <201406190946.s5J9khBe031610@svn.freebsd.org> References: <201406190946.s5J9khBe031610@svn.freebsd.org> Date: Thu, 19 Jun 2014 09:57:25 -0700 X-Google-Sender-Auth: Fx7nV1gNJme4bOFmNKJchPbGM_E Message-ID: Subject: Re: svn commit: r267639 - head/sys/cam/ctl From: Adrian Chadd To: Alexander Motin Content-Type: text/plain; charset=UTF-8 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2014 16:57:27 -0000 FreeBSD_version? -a On 19 June 2014 02:46, Alexander Motin wrote: > Author: mav > Date: Thu Jun 19 09:46:43 2014 > New Revision: 267639 > URL: http://svnweb.freebsd.org/changeset/base/267639 > > Log: > Increase CTL_DEVID_LEN from 16 to 64 bytes. > > SPC-4 recommends T10 vendor ID based LUN ID was created by concatenating > product name and serial number (and istgt follows that). But product name > is 16 bytes long by itself, so 16 bytes total length is clearly not enough > to fit both. > > To keep compatibility with existing configurations, pad short device IDs > to old length of 16, same as before. > > This change probably breaks CTL user-level ABI, so control tools should > be rebuilt after this change. > > MFC after: 2 weeks > > Modified: > head/sys/cam/ctl/ctl.c > head/sys/cam/ctl/ctl.h > head/sys/cam/ctl/ctl_frontend_iscsi.c > > Modified: head/sys/cam/ctl/ctl.c > ============================================================================== > --- head/sys/cam/ctl/ctl.c Thu Jun 19 09:08:20 2014 (r267638) > +++ head/sys/cam/ctl/ctl.c Thu Jun 19 09:46:43 2014 (r267639) > @@ -91,12 +91,6 @@ struct ctl_softc *control_softc = NULL; > #define CTL_DONE_THREAD > > /* > - * Use the serial number and device ID provided by the backend, rather than > - * making up our own. > - */ > -#define CTL_USE_BACKEND_SN > - > -/* > * Size and alignment macros needed for Copan-specific HA hardware. These > * can go away when the HA code is re-written, and uses busdma for any > * hardware. > @@ -9477,9 +9471,6 @@ ctl_inquiry_evpd_serial(struct ctl_scsii > { > struct scsi_vpd_unit_serial_number *sn_ptr; > struct ctl_lun *lun; > -#ifndef CTL_USE_BACKEND_SN > - char tmpstr[32]; > -#endif > > lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; > > @@ -9513,7 +9504,6 @@ ctl_inquiry_evpd_serial(struct ctl_scsii > > sn_ptr->page_code = SVPD_UNIT_SERIAL_NUMBER; > sn_ptr->length = ctl_min(sizeof(*sn_ptr) - 4, CTL_SN_LEN); > -#ifdef CTL_USE_BACKEND_SN > /* > * If we don't have a LUN, we just leave the serial number as > * all spaces. > @@ -9523,15 +9513,6 @@ ctl_inquiry_evpd_serial(struct ctl_scsii > strncpy((char *)sn_ptr->serial_num, > (char *)lun->be_lun->serial_num, CTL_SN_LEN); > } > -#else > - /* > - * Note that we're using a non-unique serial number here, > - */ > - snprintf(tmpstr, sizeof(tmpstr), "MYSERIALNUMIS000"); > - memset(sn_ptr->serial_num, 0x20, sizeof(sn_ptr->serial_num)); > - strncpy(sn_ptr->serial_num, tmpstr, ctl_min(CTL_SN_LEN, > - ctl_min(sizeof(tmpstr), sizeof(*sn_ptr) - 4))); > -#endif > ctsio->scsi_status = SCSI_STATUS_OK; > > ctsio->be_move_done = ctl_config_move_done; > @@ -9552,10 +9533,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > struct ctl_lun *lun; > struct ctl_frontend *fe; > char *val; > -#ifndef CTL_USE_BACKEND_SN > - char tmpstr[32]; > -#endif /* CTL_USE_BACKEND_SN */ > - int devid_len; > + int data_len, devid_len; > > ctl_softc = control_softc; > > @@ -9568,23 +9546,30 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > > lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; > > - devid_len = sizeof(struct scsi_vpd_device_id) + > + if (lun == NULL) { > + devid_len = CTL_DEVID_MIN_LEN; > + } else { > + devid_len = max(CTL_DEVID_MIN_LEN, > + strnlen(lun->be_lun->device_id, CTL_DEVID_LEN)); > + } > + > + data_len = sizeof(struct scsi_vpd_device_id) + > sizeof(struct scsi_vpd_id_descriptor) + > - sizeof(struct scsi_vpd_id_t10) + CTL_DEVID_LEN + > + sizeof(struct scsi_vpd_id_t10) + devid_len + > sizeof(struct scsi_vpd_id_descriptor) + CTL_WWPN_LEN + > sizeof(struct scsi_vpd_id_descriptor) + > sizeof(struct scsi_vpd_id_rel_trgt_port_id) + > sizeof(struct scsi_vpd_id_descriptor) + > sizeof(struct scsi_vpd_id_trgt_port_grp_id); > > - ctsio->kern_data_ptr = malloc(devid_len, M_CTL, M_WAITOK | M_ZERO); > + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); > devid_ptr = (struct scsi_vpd_device_id *)ctsio->kern_data_ptr; > ctsio->kern_sg_entries = 0; > > - if (devid_len < alloc_len) { > - ctsio->residual = alloc_len - devid_len; > - ctsio->kern_data_len = devid_len; > - ctsio->kern_total_len = devid_len; > + if (data_len < alloc_len) { > + ctsio->residual = alloc_len - data_len; > + ctsio->kern_data_len = data_len; > + ctsio->kern_total_len = data_len; > } else { > ctsio->residual = 0; > ctsio->kern_data_len = alloc_len; > @@ -9597,7 +9582,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > desc = (struct scsi_vpd_id_descriptor *)devid_ptr->desc_list; > t10id = (struct scsi_vpd_id_t10 *)&desc->identifier[0]; > desc1 = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] + > - sizeof(struct scsi_vpd_id_t10) + CTL_DEVID_LEN); > + sizeof(struct scsi_vpd_id_t10) + devid_len); > desc2 = (struct scsi_vpd_id_descriptor *)(&desc1->identifier[0] + > CTL_WWPN_LEN); > desc3 = (struct scsi_vpd_id_descriptor *)(&desc2->identifier[0] + > @@ -9615,7 +9600,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > > devid_ptr->page_code = SVPD_DEVICE_ID; > > - scsi_ulto2b(devid_len - 4, devid_ptr->length); > + scsi_ulto2b(data_len - 4, devid_ptr->length); > > mtx_lock(&ctl_softc->ctl_lock); > > @@ -9644,7 +9629,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > * per-LUN identifier. > */ > desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10; > - desc->length = sizeof(*t10id) + CTL_DEVID_LEN; > + desc->length = sizeof(*t10id) + devid_len; > if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) { > strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor)); > } else { > @@ -9701,7 +9686,6 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > else > desc3->identifier[3] = 2; > > -#ifdef CTL_USE_BACKEND_SN > /* > * If we've actually got a backend, copy the device id from the > * per-LUN data. Otherwise, set it to all spaces. > @@ -9711,19 +9695,13 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio > * Copy the backend's LUN ID. > */ > strncpy((char *)t10id->vendor_spec_id, > - (char *)lun->be_lun->device_id, CTL_DEVID_LEN); > + (char *)lun->be_lun->device_id, devid_len); > } else { > /* > * No backend, set this to spaces. > */ > - memset(t10id->vendor_spec_id, 0x20, CTL_DEVID_LEN); > + memset(t10id->vendor_spec_id, 0x20, devid_len); > } > -#else > - snprintf(tmpstr, sizeof(tmpstr), "MYDEVICEIDIS%4d", > - (lun != NULL) ? (int)lun->lun : 0); > - strncpy(t10id->vendor_spec_id, tmpstr, ctl_min(CTL_DEVID_LEN, > - sizeof(tmpstr))); > -#endif > > ctsio->scsi_status = SCSI_STATUS_OK; > > > Modified: head/sys/cam/ctl/ctl.h > ============================================================================== > --- head/sys/cam/ctl/ctl.h Thu Jun 19 09:08:20 2014 (r267638) > +++ head/sys/cam/ctl/ctl.h Thu Jun 19 09:46:43 2014 (r267639) > @@ -96,7 +96,8 @@ union ctl_modepage_info { > /* > * Device ID length, for VPD page 0x83. > */ > -#define CTL_DEVID_LEN 16 > +#define CTL_DEVID_LEN 64 > +#define CTL_DEVID_MIN_LEN 16 > /* > * WWPN length, for VPD page 0x83. > */ > > Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c > ============================================================================== > --- head/sys/cam/ctl/ctl_frontend_iscsi.c Thu Jun 19 09:08:20 2014 (r267638) > +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Thu Jun 19 09:46:43 2014 (r267639) > @@ -2060,7 +2060,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > const struct icl_pdu *request; > int i, ret; > char *val; > - size_t devid_len, wwnn_len, wwpn_len, lun_name_len; > + size_t data_len, devid_len, wwnn_len, wwpn_len, lun_name_len; > > lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; > request = ctsio->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; > @@ -2078,8 +2078,11 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > wwnn_len += (4 - (wwnn_len % 4)); > > if (lun == NULL) { > + devid_len = CTL_DEVID_MIN_LEN; > lun_name_len = 0; > } else { > + devid_len = max(CTL_DEVID_MIN_LEN, > + strnlen(lun->be_lun->device_id, CTL_DEVID_LEN)); > lun_name_len = strlen(cs->cs_target->ct_name); > lun_name_len += strlen(",lun,XXXXXXXX"); > lun_name_len += 1; /* '\0' */ > @@ -2087,9 +2090,9 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > lun_name_len += (4 - (lun_name_len % 4)); > } > > - devid_len = sizeof(struct scsi_vpd_device_id) + > + data_len = sizeof(struct scsi_vpd_device_id) + > sizeof(struct scsi_vpd_id_descriptor) + > - sizeof(struct scsi_vpd_id_t10) + CTL_DEVID_LEN + > + sizeof(struct scsi_vpd_id_t10) + devid_len + > sizeof(struct scsi_vpd_id_descriptor) + lun_name_len + > sizeof(struct scsi_vpd_id_descriptor) + wwnn_len + > sizeof(struct scsi_vpd_id_descriptor) + wwpn_len + > @@ -2098,14 +2101,14 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > sizeof(struct scsi_vpd_id_descriptor) + > sizeof(struct scsi_vpd_id_trgt_port_grp_id); > > - ctsio->kern_data_ptr = malloc(devid_len, M_CTL, M_WAITOK | M_ZERO); > + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); > devid_ptr = (struct scsi_vpd_device_id *)ctsio->kern_data_ptr; > ctsio->kern_sg_entries = 0; > > - if (devid_len < alloc_len) { > - ctsio->residual = alloc_len - devid_len; > - ctsio->kern_data_len = devid_len; > - ctsio->kern_total_len = devid_len; > + if (data_len < alloc_len) { > + ctsio->residual = alloc_len - data_len; > + ctsio->kern_data_len = data_len; > + ctsio->kern_total_len = data_len; > } else { > ctsio->residual = 0; > ctsio->kern_data_len = alloc_len; > @@ -2118,7 +2121,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > desc = (struct scsi_vpd_id_descriptor *)devid_ptr->desc_list; > t10id = (struct scsi_vpd_id_t10 *)&desc->identifier[0]; > desc1 = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] + > - sizeof(struct scsi_vpd_id_t10) + CTL_DEVID_LEN); > + sizeof(struct scsi_vpd_id_t10) + devid_len); > desc2 = (struct scsi_vpd_id_descriptor *)(&desc1->identifier[0] + > lun_name_len); > desc3 = (struct scsi_vpd_id_descriptor *)(&desc2->identifier[0] + > @@ -2136,7 +2139,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > > devid_ptr->page_code = SVPD_DEVICE_ID; > > - scsi_ulto2b(devid_len - 4, devid_ptr->length); > + scsi_ulto2b(data_len - 4, devid_ptr->length); > > /* > * We're using a LUN association here. i.e., this device ID is a > @@ -2144,7 +2147,7 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > */ > desc->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_ASCII; > desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | SVPD_ID_TYPE_T10; > - desc->length = sizeof(*t10id) + CTL_DEVID_LEN; > + desc->length = sizeof(*t10id) + devid_len; > if (lun == NULL || (val = ctl_get_opt(lun->be_lun, "vendor")) == NULL) { > strncpy((char *)t10id->vendor, CTL_VENDOR, sizeof(t10id->vendor)); > } else { > @@ -2162,12 +2165,12 @@ cfiscsi_devid(struct ctl_scsiio *ctsio, > * Copy the backend's LUN ID. > */ > strncpy((char *)t10id->vendor_spec_id, > - (char *)lun->be_lun->device_id, CTL_DEVID_LEN); > + (char *)lun->be_lun->device_id, devid_len); > } else { > /* > * No backend, set this to spaces. > */ > - memset(t10id->vendor_spec_id, 0x20, CTL_DEVID_LEN); > + memset(t10id->vendor_spec_id, 0x20, devid_len); > } > > /* >