diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-01-29 17:18:00 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-01-29 17:24:26 -0500 |
commit | 8b4b0dcbf70d10f3acd6a88fca0679ca711066e0 (patch) | |
tree | d855daea82993811014a7668622a0b7ad6cdb3fa /drivers/target | |
parent | cab9609b449ae5a6875d7d4cef32a814527a3baa (diff) |
target: Fix zero-length READ_CAPACITY_16 regression
This patch fixes a regression introduced in v3.8-rc1 code where a
zero-length READ_CAPACITY_16 was no longer returning GOOD status, but
instead returning TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE to generate
a CHECK_CONDITION status.
This regression was introduced with the following commit:
commit de103c93aff0bed0ae984274e5dc8b95899badab
Author: Christoph Hellwig <hch@lst.de>
Date: Tue Nov 6 12:24:09 2012 -0800
target: pass sense_reason as a return value
and this patch has been tested with the following zero-length CDB:
sg_raw /dev/sdd 9e 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SCSI Status: Good
Sense Information:
sense buffer empty
Also, convert sbc_emulate_readcapacity() to follow the same method
of handling transport_kmap_data_sg() return values, but we never
expect a zero-length request here.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_sbc.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 26a6d183ccb1..a664c664a31a 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -58,11 +58,10 @@ sbc_emulate_readcapacity(struct se_cmd *cmd) | |||
58 | buf[7] = dev->dev_attrib.block_size & 0xff; | 58 | buf[7] = dev->dev_attrib.block_size & 0xff; |
59 | 59 | ||
60 | rbuf = transport_kmap_data_sg(cmd); | 60 | rbuf = transport_kmap_data_sg(cmd); |
61 | if (!rbuf) | 61 | if (rbuf) { |
62 | return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 62 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); |
63 | 63 | transport_kunmap_data_sg(cmd); | |
64 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); | 64 | } |
65 | transport_kunmap_data_sg(cmd); | ||
66 | 65 | ||
67 | target_complete_cmd(cmd, GOOD); | 66 | target_complete_cmd(cmd, GOOD); |
68 | return 0; | 67 | return 0; |
@@ -97,11 +96,10 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) | |||
97 | buf[14] = 0x80; | 96 | buf[14] = 0x80; |
98 | 97 | ||
99 | rbuf = transport_kmap_data_sg(cmd); | 98 | rbuf = transport_kmap_data_sg(cmd); |
100 | if (!rbuf) | 99 | if (rbuf) { |
101 | return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 100 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); |
102 | 101 | transport_kunmap_data_sg(cmd); | |
103 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); | 102 | } |
104 | transport_kunmap_data_sg(cmd); | ||
105 | 103 | ||
106 | target_complete_cmd(cmd, GOOD); | 104 | target_complete_cmd(cmd, GOOD); |
107 | return 0; | 105 | return 0; |