VPD pages between 0xB0 and 0xBF are protocol specific, so we should only mark them as supported for TYPE_DISK. And the referrals VPD page should only be marked as supported if referrals are enabled. Signed-off-by: Hannes Reinecke <hare@xxxxxxx> --- drivers/target/target_core_spc.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index daa5a63..3437d3c 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -633,18 +633,38 @@ static struct { static sense_reason_t spc_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) { - int p; + struct se_device *dev = cmd->se_dev; + int p, n, vpds_supported = 0; /* * Only report the INQUIRY EVPD=1 pages after a valid NAA * Registered Extended LUN WWN has been set via ConfigFS * during device creation/restart. */ - if (cmd->se_dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL) { - buf[3] = ARRAY_SIZE(evpd_handlers); - for (p = 0; p < ARRAY_SIZE(evpd_handlers); ++p) - buf[p + 4] = evpd_handlers[p].page; + if (!(dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL)) + return 0; + + n = 4; + for (p = 0; p < ARRAY_SIZE(evpd_handlers); ++p) { + /* + * VPD pages between 0xb0 and 0xbf are + * protocol specific; currently they + * are only implemented for SBC. + */ + if (evpd_handlers[p].page >= 0xb0 && + dev->transport->get_device_type(dev) != TYPE_DISK) + continue; + /* + * VPD page 0xb3 should be present if + * referrals are supported. + */ + if (evpd_handlers[p].page == 0xb3 && + list_empty(&dev->t10_alua.lba_map_list)) + continue; + vpds_supported++; + buf[n++] = evpd_handlers[p].page; } + buf[3] = vpds_supported; return 0; } -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html