diff options
author | Roland Dreier <roland@purestorage.com> | 2012-02-13 19:18:15 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-02-25 17:37:49 -0500 |
commit | 089461dda1770c10fea0b988ff74519a9be81d7e (patch) | |
tree | 4e1a644fe2a32ae3ffa22c52673060e617b2e692 /drivers/target | |
parent | d95b82461c56a6ff8ff248b101049a69ebb20278 (diff) |
target: Set peripheral device type consistently in INQUIRY response
Current code sets the peripheral device type to 0x3f == "not present
unknown" for virtual LUN 0 for standard INQUIRY commands, but leaves it
as 0 == "connected direct access block" for VPD INQUIRY commands. This
is just because the check for LUN 0 only happens in some code paths.
Make our peripheral device type consistent by moving the LUN 0 check
into the common emulate_inquiry() code.
Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_cdb.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index ef8034b60d8d..af8ebbde45ea 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -70,15 +70,11 @@ target_emulate_inquiry_std(struct se_cmd *cmd, char *buf) | |||
70 | { | 70 | { |
71 | struct se_lun *lun = cmd->se_lun; | 71 | struct se_lun *lun = cmd->se_lun; |
72 | struct se_device *dev = cmd->se_dev; | 72 | struct se_device *dev = cmd->se_dev; |
73 | struct se_portal_group *tpg = lun->lun_sep->sep_tpg; | ||
74 | 73 | ||
75 | if (dev == tpg->tpg_virt_lun0.lun_se_dev) { | 74 | /* Set RMB (removable media) for tape devices */ |
76 | buf[0] = 0x3f; /* Not connected */ | 75 | if (dev->transport->get_device_type(dev) == TYPE_TAPE) |
77 | } else { | 76 | buf[1] = 0x80; |
78 | buf[0] = dev->transport->get_device_type(dev); | 77 | |
79 | if (buf[0] == TYPE_TAPE) | ||
80 | buf[1] = 0x80; | ||
81 | } | ||
82 | buf[2] = dev->transport->get_device_rev(dev); | 78 | buf[2] = dev->transport->get_device_rev(dev); |
83 | 79 | ||
84 | /* | 80 | /* |
@@ -606,6 +602,7 @@ int target_emulate_inquiry(struct se_task *task) | |||
606 | { | 602 | { |
607 | struct se_cmd *cmd = task->task_se_cmd; | 603 | struct se_cmd *cmd = task->task_se_cmd; |
608 | struct se_device *dev = cmd->se_dev; | 604 | struct se_device *dev = cmd->se_dev; |
605 | struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; | ||
609 | unsigned char *buf, *map_buf; | 606 | unsigned char *buf, *map_buf; |
610 | unsigned char *cdb = cmd->t_task_cdb; | 607 | unsigned char *cdb = cmd->t_task_cdb; |
611 | int p, ret; | 608 | int p, ret; |
@@ -630,6 +627,11 @@ int target_emulate_inquiry(struct se_task *task) | |||
630 | buf = map_buf; | 627 | buf = map_buf; |
631 | } | 628 | } |
632 | 629 | ||
630 | if (dev == tpg->tpg_virt_lun0.lun_se_dev) | ||
631 | buf[0] = 0x3f; /* Not connected */ | ||
632 | else | ||
633 | buf[0] = dev->transport->get_device_type(dev); | ||
634 | |||
633 | if (!(cdb[1] & 0x1)) { | 635 | if (!(cdb[1] & 0x1)) { |
634 | if (cdb[2]) { | 636 | if (cdb[2]) { |
635 | pr_err("INQUIRY with EVPD==0 but PAGE CODE=%02x\n", | 637 | pr_err("INQUIRY with EVPD==0 but PAGE CODE=%02x\n", |
@@ -643,8 +645,6 @@ int target_emulate_inquiry(struct se_task *task) | |||
643 | goto out; | 645 | goto out; |
644 | } | 646 | } |
645 | 647 | ||
646 | buf[0] = dev->transport->get_device_type(dev); | ||
647 | |||
648 | for (p = 0; p < ARRAY_SIZE(evpd_handlers); ++p) { | 648 | for (p = 0; p < ARRAY_SIZE(evpd_handlers); ++p) { |
649 | if (cdb[2] == evpd_handlers[p].page) { | 649 | if (cdb[2] == evpd_handlers[p].page) { |
650 | buf[1] = cdb[2]; | 650 | buf[1] = cdb[2]; |