diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-06-17 18:40:54 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-16 20:34:41 -0400 |
commit | 6f974e8ce7b3f661910a49c7c2ba095631f341e9 (patch) | |
tree | 5698f1ed849b92eec547571594a68183c592b590 /drivers/target/target_core_iblock.c | |
parent | ad67f0d9e63ca94661e06a145f05a9302368a826 (diff) |
target: move write_same to struct spc_ops
Add spc_ops->execute_write_same() caller for ->execute_cmd() setup,
and update IBLOCK backends to use it.
(nab: add export of spc_get_write_same_sectors symbol)
(roland: Carry forward: Fix range calculation in WRITE SAME emulation
when num blocks == 0)
Signed-off-by: Christoph Hellwig <hch@lst.de>
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.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 863c962e5021..ee70cc9f6a64 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -327,6 +327,23 @@ static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range) | |||
327 | return blkdev_issue_discard(bd, lba, range, GFP_KERNEL, barrier); | 327 | return blkdev_issue_discard(bd, lba, range, GFP_KERNEL, barrier); |
328 | } | 328 | } |
329 | 329 | ||
330 | static int iblock_execute_write_same(struct se_cmd *cmd) | ||
331 | { | ||
332 | struct iblock_dev *ibd = cmd->se_dev->dev_ptr; | ||
333 | int ret; | ||
334 | |||
335 | ret = blkdev_issue_discard(ibd->ibd_bd, cmd->t_task_lba, | ||
336 | spc_get_write_same_sectors(cmd), GFP_KERNEL, | ||
337 | 0); | ||
338 | if (ret < 0) { | ||
339 | pr_debug("blkdev_issue_discard() failed for WRITE_SAME\n"); | ||
340 | return ret; | ||
341 | } | ||
342 | |||
343 | target_complete_cmd(cmd, GOOD); | ||
344 | return 0; | ||
345 | } | ||
346 | |||
330 | enum { | 347 | enum { |
331 | Opt_udev_path, Opt_readonly, Opt_force, Opt_err | 348 | Opt_udev_path, Opt_readonly, Opt_force, Opt_err |
332 | }; | 349 | }; |
@@ -669,6 +686,7 @@ static void iblock_bio_done(struct bio *bio, int err) | |||
669 | static struct spc_ops iblock_spc_ops = { | 686 | static struct spc_ops iblock_spc_ops = { |
670 | .execute_rw = iblock_execute_rw, | 687 | .execute_rw = iblock_execute_rw, |
671 | .execute_sync_cache = iblock_execute_sync_cache, | 688 | .execute_sync_cache = iblock_execute_sync_cache, |
689 | .execute_write_same = iblock_execute_write_same, | ||
672 | }; | 690 | }; |
673 | 691 | ||
674 | static int iblock_parse_cdb(struct se_cmd *cmd) | 692 | static int iblock_parse_cdb(struct se_cmd *cmd) |