Skip to contentSkip to conversation

scsi_lib: Decode T-10 vendor IDs

PATCH Superseded Hannes Reinecke 2 participants 2 messages May 6, 2016 – May 9, 2016 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi_lib: Decode T-10 vendor IDs

Some arrays / HBAs will only present T-10 vendor IDs, so we should be decoding them, too.

---
 drivers/scsi/scsi_lib.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/scsi/scsi_lib.c +16 -0
index b920c5d..a6158f8 100644
@@ -3064,6 +3064,7 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len)
 	 * - EUI-64 based 12-byte
 	 * - NAA IEEE Registered
 	 * - NAA IEEE Extended
+	 * - T10 Vendor ID
 	 * as longer descriptors reduce the likelyhood
 	 * of identification clashes.
 	 */
@@ -3082,6 +3083,21 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len)
 			goto next_desig;
 
 		switch (d[1] & 0xf) {
+		case 0x1:
+			/* T-10 Vendor ID */
+			if (cur_id_size > d[3])
+				break;
+			/* Prefer anything */
+			if (cur_id_type > 0x01)
+				break;
+			cur_id_size = d[3];
+			if (cur_id_size + 4 > id_len)
+				cur_id_size = id_len - 4;
+			cur_id_str = d + 4;
+			cur_id_type = d[1] & 0xf;
+			id_size = snprintf(id, id_len, "t10.%*pE",
+					   cur_id_size, cur_id_str);
+			break;
 		case 0x2:
 			/* EUI-64 */
 			if (cur_id_size > d[3])
Signature · 1 line
1.8.5.6
#1 lore raw
Quoted 22 lines · Hannes Reinecke

Some arrays / HBAs will only present T-10 vendor IDs, so we should be decoding them, too.

---
 drivers/scsi/scsi_lib.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/scsi/scsi_lib.c +1 -0
index b920c5d..a6158f8 100644
@@ -3064,6 +3064,7 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len)
 	 * - EUI-64 based 12-byte
 	 * - NAA IEEE Registered
 	 * - NAA IEEE Extended
+	 * - T10 Vendor ID
 	 * as longer descriptors reduce the likelyhood
 	 * of identification clashes.
 	 */

drivers/scsi/scsi_lib.c int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len) · line 3092

Quoted 10 lines
drivers/scsi/scsi_lib.c +7 -0
@@ -3082,6 +3083,21 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len)
 			goto next_desig;
 
 		switch (d[1] & 0xf) {
+		case 0x1:
+			/* T-10 Vendor ID */
+			if (cur_id_size > d[3])
+				break;
+			/* Prefer anything */
+			if (cur_id_type > 0x01)
+				break;

This doesn't work as desired because cur_id_type is initialized to 0xff. The test needs to be:

+ if (cur_id_type > 0x01 && cur_id_type != 0xff)
+ break;

With that change it works (and you could put my tested-by on it).

Thanks,
Paul.