aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_iblock.c
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-07-16 18:34:23 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-07-16 20:35:36 -0400
commit1a5fa4576ec8a462313c7516b31d7453481ddbe8 (patch)
tree5a88ad2720656e7286bde6d4d301382877b67af1 /drivers/target/target_core_iblock.c
parent2594e29865c291db162313187612cd9f14538f33 (diff)
target: Fix reading of data length fields for UNMAP commands
The UNMAP DATA LENGTH and UNMAP BLOCK DESCRIPTOR DATA LENGTH fields are in the unmap descriptor (the payload transferred to our data out buffer), not in the CDB itself. Read them from the correct place in target_emulated_unmap. 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/target_core_iblock.c')
-rw-r--r--drivers/target/target_core_iblock.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 8fb3822bad55..e6d08ee3166e 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -324,7 +324,6 @@ static int iblock_execute_unmap(struct se_cmd *cmd)
324 struct se_device *dev = cmd->se_dev; 324 struct se_device *dev = cmd->se_dev;
325 struct iblock_dev *ibd = dev->dev_ptr; 325 struct iblock_dev *ibd = dev->dev_ptr;
326 unsigned char *buf, *ptr = NULL; 326 unsigned char *buf, *ptr = NULL;
327 unsigned char *cdb = &cmd->t_task_cdb[0];
328 sector_t lba; 327 sector_t lba;
329 unsigned int size = cmd->data_length, range; 328 unsigned int size = cmd->data_length, range;
330 int ret = 0, offset; 329 int ret = 0, offset;
@@ -333,11 +332,12 @@ static int iblock_execute_unmap(struct se_cmd *cmd)
333 /* First UNMAP block descriptor starts at 8 byte offset */ 332 /* First UNMAP block descriptor starts at 8 byte offset */
334 offset = 8; 333 offset = 8;
335 size -= 8; 334 size -= 8;
336 dl = get_unaligned_be16(&cdb[0]);
337 bd_dl = get_unaligned_be16(&cdb[2]);
338 335
339 buf = transport_kmap_data_sg(cmd); 336 buf = transport_kmap_data_sg(cmd);
340 337
338 dl = get_unaligned_be16(&buf[0]);
339 bd_dl = get_unaligned_be16(&buf[2]);
340
341 ptr = &buf[offset]; 341 ptr = &buf[offset];
342 pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu" 342 pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
343 " ptr: %p\n", dev->transport->name, dl, bd_dl, size, ptr); 343 " ptr: %p\n", dev->transport->name, dl, bd_dl, size, ptr);