From owner-svn-src-all@freebsd.org Fri May 27 22:26:45 2016 Return-Path: Delivered-To: svn-src-all@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 28E09B4D35B; Fri, 27 May 2016 22:26:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E70991D98; Fri, 27 May 2016 22:26:44 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4RMQifK084035; Fri, 27 May 2016 22:26:44 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4RMQhRV084033; Fri, 27 May 2016 22:26:43 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201605272226.u4RMQhRV084033@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 27 May 2016 22:26:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300880 - in head: . sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Fri, 27 May 2016 22:26:45 -0000 Author: asomers Date: Fri May 27 22:26:43 2016 New Revision: 300880 URL: https://svnweb.freebsd.org/changeset/base/300880 Log: Strip leading spaces off of a SCSI disk's serial number sys/cam/scsi/scsi_xpt.c Strip leading spaces off of a SCSI disk's reported serial number when populating the CAM serial number. This affects the output of "diskinfo -v" and the names of /dev/diskid/DISK-* device nodes, among other things. SPC5r05 says that the Product Serial Number field from the Unit Serial Number VPD page is right-aligned. So any leading spaces are not part of the actual serial number. Most devices don't left-pad their serial numbers, but some do. In particular, the SN VPD page that an LSI HBA emulates for a SATA drive contains enough left-padding to fill a 20-byte field. UPDATING Add a note to UPDATING, because some users may have to update /etc/fstab or geom labels. Reviewed by: ken, mav MFC after: Never Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6516 Modified: head/UPDATING head/sys/cam/scsi/scsi_xpt.c Modified: head/UPDATING ============================================================================== --- head/UPDATING Fri May 27 22:16:46 2016 (r300879) +++ head/UPDATING Fri May 27 22:26:43 2016 (r300880) @@ -31,6 +31,16 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20160527: + CAM will now strip leading spaces from SCSI disks' serial numbers. + This will effect users who create UFS filesystems on SCSI disks using + those disk's diskid device nodes. For example, if /etc/fstab + previously contained a line like + "/dev/diskid/DISK-%20%20%20%20%20%20%20ABCDEFG0123456", you should + change it to "/dev/diskid/DISK-ABCDEFG0123456". Users of geom + transfers like gmirror may also be affected. ZFS users should + generally be fine. + 20160523: The bitstring(3) API has been updated with new functionality and improved performance. But it is binary-incompatible with the old API. Modified: head/sys/cam/scsi/scsi_xpt.c ============================================================================== --- head/sys/cam/scsi/scsi_xpt.c Fri May 27 22:16:46 2016 (r300879) +++ head/sys/cam/scsi/scsi_xpt.c Fri May 27 22:26:43 2016 (r300880) @@ -1559,13 +1559,22 @@ probe_device_check: (u_int8_t *)malloc((serial_buf->length + 1), M_CAMXPT, M_NOWAIT); if (path->device->serial_num != NULL) { + int start, slen; + + start = strspn(serial_buf->serial_num, " "); + slen = serial_buf->length - start; + if (slen <= 0) { + /* + * SPC5r05 says that an all-space serial + * number means no product serial number + * is available + */ + slen = 0; + } memcpy(path->device->serial_num, - serial_buf->serial_num, - serial_buf->length); - path->device->serial_num_len = - serial_buf->length; - path->device->serial_num[serial_buf->length] - = '\0'; + &serial_buf->serial_num[start], slen); + path->device->serial_num_len = slen; + path->device->serial_num[slen] = '\0'; } } else if (cam_periph_error(done_ccb, 0, SF_RETRY_UA|SF_NO_PRINT,