diff options
author | 2012-06-17 18:40:54 -0400 | |
---|---|---|
committer | 2012-07-16 17:34:41 -0700 | |
commit | 6f974e8ce7b3f661910a49c7c2ba095631f341e9 (patch) | |
tree | 5698f1ed849b92eec547571594a68183c592b590 /drivers/target/target_core_iblock.c | |
parent | target: move sync_cache to struct spc_ops (diff) | |
download | linux-6f974e8ce7b3f661910a49c7c2ba095631f341e9.tar.gz linux-6f974e8ce7b3f661910a49c7c2ba095631f341e9.tar.bz2 linux-6f974e8ce7b3f661910a49c7c2ba095631f341e9.zip |
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) return blkdev_issue_discard(bd, lba, range, GFP_KERNEL, barrier); } +static int iblock_execute_write_same(struct se_cmd *cmd) +{ + struct iblock_dev *ibd = cmd->se_dev->dev_ptr; + int ret; + + ret = blkdev_issue_discard(ibd->ibd_bd, cmd->t_task_lba, + spc_get_write_same_sectors(cmd), GFP_KERNEL, + 0); + if (ret < 0) { + pr_debug("blkdev_issue_discard() failed for WRITE_SAME\n"); + return ret; + } + + target_complete_cmd(cmd, GOOD); + return 0; +} + enum { Opt_udev_path, Opt_readonly, Opt_force, Opt_err }; @@ -669,6 +686,7 @@ static void iblock_bio_done(struct bio *bio, int err) static struct spc_ops iblock_spc_ops = { .execute_rw = iblock_execute_rw, .execute_sync_cache = iblock_execute_sync_cache, + .execute_write_same = iblock_execute_write_same, }; static int iblock_parse_cdb(struct se_cmd *cmd) |