diff options
author | Roland Dreier <roland@purestorage.com> | 2012-07-16 20:10:17 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-16 20:10:17 -0400 |
commit | 1765fe5edcb83f53fc67edeb559fcf4bc82c6460 (patch) | |
tree | 8248c8a4f2a92b7806aca6457ddf5337464880b5 | |
parent | d35212f3ca3bf4fb49d15e37f530c9931e2d2183 (diff) |
target: Fix range calculation in WRITE SAME emulation when num blocks == 0
When NUMBER OF LOGICAL BLOCKS is 0, WRITE SAME is supposed to write
all the blocks from the specified LBA through the end of the device.
However, dev->transport->get_blocks(dev) (perhaps confusingly) returns
the last valid LBA rather than the number of blocks, so the correct
number of blocks to write starting with lba is
dev->transport->get_blocks(dev) - lba + 1
(nab: Backport roland's for-3.6 patch to for-3.5)
Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: Cc: <stable@vger.kernel.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_cdb.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index 9888693a18fe..664f6e775d0e 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -1095,7 +1095,7 @@ int target_emulate_write_same(struct se_cmd *cmd) | |||
1095 | if (num_blocks != 0) | 1095 | if (num_blocks != 0) |
1096 | range = num_blocks; | 1096 | range = num_blocks; |
1097 | else | 1097 | else |
1098 | range = (dev->transport->get_blocks(dev) - lba); | 1098 | range = (dev->transport->get_blocks(dev) - lba) + 1; |
1099 | 1099 | ||
1100 | pr_debug("WRITE_SAME UNMAP: LBA: %llu Range: %llu\n", | 1100 | pr_debug("WRITE_SAME UNMAP: LBA: %llu Range: %llu\n", |
1101 | (unsigned long long)lba, (unsigned long long)range); | 1101 | (unsigned long long)lba, (unsigned long long)range); |