diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-05-06 17:55:35 -0700 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-07-22 09:37:44 +0000 |
commit | dd3a5ad8e0c8706659f02c4a72b8c87f6f7ab479 (patch) | |
tree | 83e4bad30b9dcceb9f19632ffe5cf128609ad06e /drivers/target/target_core_transport.c | |
parent | 1eb437a4ac1813f21424b8c9c39575fd61528a26 (diff) | |
download | lwn-dd3a5ad8e0c8706659f02c4a72b8c87f6f7ab479.tar.gz lwn-dd3a5ad8e0c8706659f02c4a72b8c87f6f7ab479.zip |
target: Fix WRITE_SAME_[16,32] number of blocks=0 case
This patch fixes the handling of WRITE_SAME_[16,32] emulation where a
WRITE_SAME_* CDB with number of blocks=0 was being rejected by SCSI
expected data transfer length overflow checking in target core.
It changes both CDB cases in transport_generic_cmd_sequencer() to use
dev->se_sub_dev->se_dev_attrib.block_size to match what sg_write_same
is sending us with --num=0. It also fixes target_emulate_write_same()
to properly determine the num_blocks with --num=0 case to determine the
remaining range for dev->transport->do_discard().
Reported-by: Chris Greiveldinger <chris.greiveldinger@rnanetworks.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_transport.c')
-rw-r--r-- | drivers/target/target_core_transport.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index a29f6d3fc55b..bf401da05f35 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3132,7 +3132,12 @@ static int transport_generic_cmd_sequencer( sectors = transport_get_sectors_32(cdb, cmd, §or_ret); if (sector_ret) goto out_unsupported_cdb; - size = transport_get_size(sectors, cdb, cmd); + + if (sectors != 0) + size = transport_get_size(sectors, cdb, cmd); + else + size = dev->se_sub_dev->se_dev_attrib.block_size; + cmd->t_task.t_task_lba = get_unaligned_be64(&cdb[12]); cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; @@ -3416,7 +3421,12 @@ static int transport_generic_cmd_sequencer( sectors = transport_get_sectors_16(cdb, cmd, §or_ret); if (sector_ret) goto out_unsupported_cdb; - size = transport_get_size(sectors, cdb, cmd); + + if (sectors != 0) + size = transport_get_size(sectors, cdb, cmd); + else + size = dev->se_sub_dev->se_dev_attrib.block_size; + cmd->t_task.t_task_lba = get_unaligned_be64(&cdb[2]); passthrough = (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV); |