For its VPD page, stgt is using "target port" association (SPC spec section 7.6.3.1, table 297) and "vendor specific" ID type (table 298). Target port association is problematic since port can be associated with number of luns and the requested VPD supposed to be associated with single LUN. Vendor specific ID type is problematic since it should include T10 vendor ID (see 7.6.3.3) where stgt is not related to any specific vendor. The same reasoning holds for NAA, EUI64 and T10 ID types. SCSI Name String (SNS - 7.6.3.11) is the only ID type which doesn't require explicit authority-assigned vendor ID. As of the the above reasons, the association is changed to be LUN and the ID type to be SNS. This allows for inter-operability with the vmware SCSI stack. Signed-off-by: Or Gerlitz <ogerlitz at voltaire.com> Signed-off-by: Alexander Nezhinsky <alexn at voltaire.com> Index: tgt/usr/spc.c =================================================================== --- tgt.orig/usr/spc.c +++ tgt/usr/spc.c @@ -132,12 +132,14 @@ static void update_vpd_83(struct scsi_lu { struct vpd *vpd_pg = lu->attrs.lu_vpd[3]; uint8_t *data = vpd_pg->data; + /* align scsi_id to the next multiple of 4 */ + unsigned int id_len = (strlen(id) + 0x03) & ~0x03; - data[0] = (PIV_ISCSI << 4) | INQ_CODE_ASCII; - data[1] = PIV_VALID | ASS_TGT_PORT | DESG_VENDOR; - data[3] = SCSI_ID_LEN; + data[0] = (PIV_ISCSI << 4) | INQ_CODE_UTF8; + data[1] = PIV_VALID | ASS_LU | DESG_SCSI; + data[3] = id_len; - strncpy((char *)data + 4, id, SCSI_ID_LEN); + strncpy((char *)data + 4, id, vpd_pg->size - 4); } int spc_inquiry(int host_no, struct scsi_cmd *cmd) @@ -1019,6 +1021,7 @@ int spc_lu_init(struct scsi_lu *lu) { struct vpd **lu_vpd = lu->attrs.lu_vpd; struct target *tgt = lu->tgt; + char scsi_id[SCSI_ID_LEN+4]; int pg; lu->attrs.device_type = lu->dev_type_template.type; @@ -1029,7 +1032,7 @@ int spc_lu_init(struct scsi_lu *lu) snprintf(lu->attrs.product_rev, sizeof(lu->attrs.product_rev), "%s", "0001"); snprintf(lu->attrs.scsi_id, sizeof(lu->attrs.scsi_id), - "deadbeaf%d:%" PRIu64, tgt->tid, lu->lun); + "deadbeaf%04x%04" PRIx64, tgt->tid, lu->lun); snprintf(lu->attrs.scsi_sn, sizeof(lu->attrs.scsi_sn), "beaf%d%" PRIu64, tgt->tid, lu->lun); @@ -1040,10 +1043,14 @@ int spc_lu_init(struct scsi_lu *lu) lu_vpd[pg]->vpd_update(lu, lu->attrs.scsi_sn); /* VPD page 0x83 */ + snprintf(scsi_id, SCSI_ID_LEN, "%s%s,L,0x%s", + strncmp(tgt->name, "iqn.", 4) == 0 ? "" : "iqn.", + tgt->name, lu->attrs.scsi_id); + pg = PCODE_OFFSET(0x83); - lu_vpd[pg] = alloc_vpd(SCSI_ID_LEN + 4); + lu_vpd[pg] = alloc_vpd(strlen(scsi_id) + 8); lu_vpd[pg]->vpd_update = update_vpd_83; - lu_vpd[pg]->vpd_update(lu, lu->attrs.scsi_id); + lu_vpd[pg]->vpd_update(lu, scsi_id); lu->attrs.removable = 0; lu->attrs.sense_format = 0; Index: tgt/usr/tgtd.h =================================================================== --- tgt.orig/usr/tgtd.h +++ tgt/usr/tgtd.h @@ -4,7 +4,7 @@ #include "log.h" #include "scsi_cmnd.h" -#define SCSI_ID_LEN 24 +#define SCSI_ID_LEN 256 #define SCSI_SN_LEN 32 #define VENDOR_ID_LEN 8 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html |