From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> This patch adds Thin Provisioning VPD page (0xb2) emulation for EVPD INQUIRY emulation following sbcr22 section 6.5.4 Thin Provisioning VPD page. This code currently sets: *) Descriptor Present bit to DP=0 to signal no attached PROVISIONING GROUP DESCRIPTORs. *) Leaves the THRESHOLD EXPONENT set to 0x00 following mkp's lead in sd.c and recommendation that this may be changing again in the future. Here is how it looks in action with sg_vpd with TCM_Loop -> TCM/IBLOCK -> scsi_debug w/ TPE + TPU enabled: target# sg_vpd --page=0xb2 /dev/sdh Thin provisioning VPD page (SBC): Unmap supported (TPU): 1 Write same with unmap supported (TPWS): 0 Anchored LBAs not supported Threshold exponent: 0 Descriptor present (DP): 0 Many thanks to Martin Petersen for answering questions here! Signed-off-by: Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/target_core_transport.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 2093563..57fbbf9 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -4984,6 +4984,38 @@ set_len: if (DEV_ATTRIB(dev)->unmap_granularity_alignment != 0) buf[32] |= 0x80; /* Set the UGAVALID bit */ break; + case 0xb2: /* Thin Provisioning VPD */ + /* + * From sbc3r22 section 6.5.4 Thin Provisioning VPD page: + * + * The PAGE LENGTH field is defined in SPC-4. If the DP bit is + * set to zero, then the page length shall be set to 0004h. If the + * DP bit is set to one, then the page length shall be set to the value + * defined in table 162. + */ + buf[0] = TRANSPORT(dev)->get_device_type(dev); + buf[1] = 0xb2; + /* + * Set Hardcoded length mentioned above for DP=0 + */ + put_unaligned_be16(0x0004, &buf[2]); + /* + * The THRESHOLD EXPONENT field indicates the threshold set size in LBAs + * as a power of 2 (i.e., the threshold set size is equal to 2(threshold exponent)). + * + * Note that this is currently set to 0x00 as mkp says it will be + * changing again. We can enable this once it has settled in T10 + * and is actually used by Linux/SCSI ML code. + */ + buf[4] = 0x00; + /* + * A TPU bit set to one indicates that the device server supports + * the UNMAP command (see 5.25). A TPU bit set to zero indicates + * that the device server does not support the UNMAP command. + */ + if (DEV_ATTRIB(dev)->emulate_tpu != 0) + buf[5] = 0x80; + break; default: printk(KERN_ERR "Unknown VPD Code: 0x%02x\n", cdb[2]); return -1; -- 1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html