From owner-svn-src-stable@freebsd.org Thu Jan 5 11:41:54 2017 Return-Path: Delivered-To: svn-src-stable@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 BB00DCA096D; Thu, 5 Jan 2017 11:41:54 +0000 (UTC) (envelope-from mav@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 7D4E71233; Thu, 5 Jan 2017 11:41:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v05BfrYt058222; Thu, 5 Jan 2017 11:41:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05BfrVw058220; Thu, 5 Jan 2017 11:41:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201701051141.v05BfrVw058220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 5 Jan 2017 11:41:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r311423 - in stable/10: sys/cam/ctl usr.sbin/ctladm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 11:41:54 -0000 Author: mav Date: Thu Jan 5 11:41:53 2017 New Revision: 311423 URL: https://svnweb.freebsd.org/changeset/base/311423 Log: MFC r310356: Add support for locally assigned RFC 4122 UUID LUN identifiers. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/usr.sbin/ctladm/ctladm.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:41:02 2017 (r311422) +++ stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:41:53 2017 (r311423) @@ -4362,6 +4362,8 @@ hex2bin(const char *str, uint8_t *buf, i str += 2; buf_size *= 2; for (i = 0; str[i] != 0 && i < buf_size; i++) { + while (str[i] == '-') /* Skip dashes in UUIDs. */ + str++; c = str[i]; if (isdigit(c)) c -= '0'; @@ -4397,7 +4399,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft struct ctl_lun *nlun, *lun; struct scsi_vpd_id_descriptor *desc; struct scsi_vpd_id_t10 *t10id; - const char *eui, *naa, *scsiname, *vendor, *value; + const char *eui, *naa, *scsiname, *uuid, *vendor, *value; int lun_number, i, lun_malloced; int devidlen, idlen1, idlen2 = 0, len; @@ -4449,6 +4451,10 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft if (naa != NULL) { len += sizeof(struct scsi_vpd_id_descriptor) + 16; } + uuid = ctl_get_opt(&be_lun->options, "uuid"); + if (uuid != NULL) { + len += sizeof(struct scsi_vpd_id_descriptor) + 18; + } lun->lun_devid = malloc(sizeof(struct ctl_devid) + len, M_CTL, M_WAITOK | M_ZERO); desc = (struct scsi_vpd_id_descriptor *)lun->lun_devid->data; @@ -4495,6 +4501,16 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft desc->length = desc->length > 8 ? 16 : 8; len -= 16 - desc->length; } + if (uuid != NULL) { + desc = (struct scsi_vpd_id_descriptor *)(&desc->identifier[0] + + desc->length); + desc->proto_codeset = SVPD_ID_CODESET_BINARY; + desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_LUN | + SVPD_ID_TYPE_UUID; + desc->identifier[0] = 0x10; + hex2bin(uuid, &desc->identifier[2], 16); + desc->length = 18; + } lun->lun_devid->len = len; mtx_lock(&ctl_softc->ctl_lock); Modified: stable/10/usr.sbin/ctladm/ctladm.8 ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.8 Thu Jan 5 11:41:02 2017 (r311422) +++ stable/10/usr.sbin/ctladm/ctladm.8 Thu Jan 5 11:41:53 2017 (r311423) @@ -35,7 +35,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd October 15, 2016 +.Dd December 21, 2016 .Dt CTLADM 8 .Os .Sh NAME @@ -859,9 +859,12 @@ Specifies LUN SCSI name string. Specifies LUN EUI-64 identifier. .It Va naa Specifies LUN NAA identifier. -Either EUI or NAA identifier should be set to UNIQUE value to allow +.It Va uuid +Specifies LUN locally assigned RFC 4122 UUID identifier. +EUI, NAA or UUID identifier should be set to UNIQUE value to allow EXTENDED COPY command access the LUN. Non-unique LUN identifiers may lead to data corruption. +Some initiators may not support later introduced UUID identifiers. .It Va ha_role Setting to "primary" or "secondary" overrides default role of the node in HA cluster, set by kern.cam.ctl.ha_role sysctl.