diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-06-17 18:40:53 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-16 20:29:12 -0400 |
commit | ad67f0d9e63ca94661e06a145f05a9302368a826 (patch) | |
tree | 2ada5604a0f61fa1f933f29cd4674f0cb95595c6 /drivers/target | |
parent | 0c2ad7d1132d8b089b1d37875917858e03610019 (diff) |
target: move sync_cache to struct spc_ops
Add spc_ops->execute_sync_cache() caller for ->execute_cmd() setup,
and update IBLOCK + FILEIO backends to use it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_file.c | 8 | ||||
-rw-r--r-- | drivers/target/target_core_iblock.c | 5 | ||||
-rw-r--r-- | drivers/target/target_core_sbc.c | 18 |
3 files changed, 12 insertions, 19 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 720ed59834fc..9e2100551c78 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -331,7 +331,7 @@ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl, | |||
331 | return 1; | 331 | return 1; |
332 | } | 332 | } |
333 | 333 | ||
334 | static void fd_emulate_sync_cache(struct se_cmd *cmd) | 334 | static int fd_execute_sync_cache(struct se_cmd *cmd) |
335 | { | 335 | { |
336 | struct se_device *dev = cmd->se_dev; | 336 | struct se_device *dev = cmd->se_dev; |
337 | struct fd_dev *fd_dev = dev->dev_ptr; | 337 | struct fd_dev *fd_dev = dev->dev_ptr; |
@@ -365,7 +365,7 @@ static void fd_emulate_sync_cache(struct se_cmd *cmd) | |||
365 | pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret); | 365 | pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret); |
366 | 366 | ||
367 | if (immed) | 367 | if (immed) |
368 | return; | 368 | return 0; |
369 | 369 | ||
370 | if (ret) { | 370 | if (ret) { |
371 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 371 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
@@ -373,6 +373,8 @@ static void fd_emulate_sync_cache(struct se_cmd *cmd) | |||
373 | } else { | 373 | } else { |
374 | target_complete_cmd(cmd, SAM_STAT_GOOD); | 374 | target_complete_cmd(cmd, SAM_STAT_GOOD); |
375 | } | 375 | } |
376 | |||
377 | return 0; | ||
376 | } | 378 | } |
377 | 379 | ||
378 | static int fd_execute_rw(struct se_cmd *cmd) | 380 | static int fd_execute_rw(struct se_cmd *cmd) |
@@ -554,6 +556,7 @@ static sector_t fd_get_blocks(struct se_device *dev) | |||
554 | 556 | ||
555 | static struct spc_ops fd_spc_ops = { | 557 | static struct spc_ops fd_spc_ops = { |
556 | .execute_rw = fd_execute_rw, | 558 | .execute_rw = fd_execute_rw, |
559 | .execute_sync_cache = fd_execute_sync_cache, | ||
557 | }; | 560 | }; |
558 | 561 | ||
559 | static int fd_parse_cdb(struct se_cmd *cmd) | 562 | static int fd_parse_cdb(struct se_cmd *cmd) |
@@ -573,7 +576,6 @@ static struct se_subsystem_api fileio_template = { | |||
573 | .create_virtdevice = fd_create_virtdevice, | 576 | .create_virtdevice = fd_create_virtdevice, |
574 | .free_device = fd_free_device, | 577 | .free_device = fd_free_device, |
575 | .parse_cdb = fd_parse_cdb, | 578 | .parse_cdb = fd_parse_cdb, |
576 | .do_sync_cache = fd_emulate_sync_cache, | ||
577 | .check_configfs_dev_params = fd_check_configfs_dev_params, | 579 | .check_configfs_dev_params = fd_check_configfs_dev_params, |
578 | .set_configfs_dev_params = fd_set_configfs_dev_params, | 580 | .set_configfs_dev_params = fd_set_configfs_dev_params, |
579 | .show_configfs_dev_params = fd_show_configfs_dev_params, | 581 | .show_configfs_dev_params = fd_show_configfs_dev_params, |
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index eb94367380c1..863c962e5021 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -296,7 +296,7 @@ static void iblock_end_io_flush(struct bio *bio, int err) | |||
296 | * Implement SYCHRONIZE CACHE. Note that we can't handle lba ranges and must | 296 | * Implement SYCHRONIZE CACHE. Note that we can't handle lba ranges and must |
297 | * always flush the whole cache. | 297 | * always flush the whole cache. |
298 | */ | 298 | */ |
299 | static void iblock_emulate_sync_cache(struct se_cmd *cmd) | 299 | static int iblock_execute_sync_cache(struct se_cmd *cmd) |
300 | { | 300 | { |
301 | struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr; | 301 | struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr; |
302 | int immed = (cmd->t_task_cdb[1] & 0x2); | 302 | int immed = (cmd->t_task_cdb[1] & 0x2); |
@@ -315,6 +315,7 @@ static void iblock_emulate_sync_cache(struct se_cmd *cmd) | |||
315 | if (!immed) | 315 | if (!immed) |
316 | bio->bi_private = cmd; | 316 | bio->bi_private = cmd; |
317 | submit_bio(WRITE_FLUSH, bio); | 317 | submit_bio(WRITE_FLUSH, bio); |
318 | return 0; | ||
318 | } | 319 | } |
319 | 320 | ||
320 | static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range) | 321 | static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range) |
@@ -667,6 +668,7 @@ static void iblock_bio_done(struct bio *bio, int err) | |||
667 | 668 | ||
668 | static struct spc_ops iblock_spc_ops = { | 669 | static struct spc_ops iblock_spc_ops = { |
669 | .execute_rw = iblock_execute_rw, | 670 | .execute_rw = iblock_execute_rw, |
671 | .execute_sync_cache = iblock_execute_sync_cache, | ||
670 | }; | 672 | }; |
671 | 673 | ||
672 | static int iblock_parse_cdb(struct se_cmd *cmd) | 674 | static int iblock_parse_cdb(struct se_cmd *cmd) |
@@ -687,7 +689,6 @@ static struct se_subsystem_api iblock_template = { | |||
687 | .free_device = iblock_free_device, | 689 | .free_device = iblock_free_device, |
688 | .parse_cdb = iblock_parse_cdb, | 690 | .parse_cdb = iblock_parse_cdb, |
689 | .do_discard = iblock_do_discard, | 691 | .do_discard = iblock_do_discard, |
690 | .do_sync_cache = iblock_emulate_sync_cache, | ||
691 | .check_configfs_dev_params = iblock_check_configfs_dev_params, | 692 | .check_configfs_dev_params = iblock_check_configfs_dev_params, |
692 | .set_configfs_dev_params = iblock_set_configfs_dev_params, | 693 | .set_configfs_dev_params = iblock_set_configfs_dev_params, |
693 | .show_configfs_dev_params = iblock_show_configfs_dev_params, | 694 | .show_configfs_dev_params = iblock_show_configfs_dev_params, |
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index da441b2782ce..377c5105e270 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -204,19 +204,6 @@ static int sbc_emulate_write_same(struct se_cmd *cmd) | |||
204 | return 0; | 204 | return 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | static int sbc_emulate_synchronize_cache(struct se_cmd *cmd) | ||
208 | { | ||
209 | if (!cmd->se_dev->transport->do_sync_cache) { | ||
210 | pr_err("SYNCHRONIZE_CACHE emulation not supported" | ||
211 | " for: %s\n", cmd->se_dev->transport->name); | ||
212 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; | ||
213 | return -ENOSYS; | ||
214 | } | ||
215 | |||
216 | cmd->se_dev->transport->do_sync_cache(cmd); | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int sbc_emulate_verify(struct se_cmd *cmd) | 207 | static int sbc_emulate_verify(struct se_cmd *cmd) |
221 | { | 208 | { |
222 | target_complete_cmd(cmd, GOOD); | 209 | target_complete_cmd(cmd, GOOD); |
@@ -541,6 +528,9 @@ int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops) | |||
541 | break; | 528 | break; |
542 | case SYNCHRONIZE_CACHE: | 529 | case SYNCHRONIZE_CACHE: |
543 | case SYNCHRONIZE_CACHE_16: | 530 | case SYNCHRONIZE_CACHE_16: |
531 | if (!ops->execute_sync_cache) | ||
532 | goto out_unsupported_cdb; | ||
533 | |||
544 | /* | 534 | /* |
545 | * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE | 535 | * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE |
546 | */ | 536 | */ |
@@ -562,7 +552,7 @@ int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops) | |||
562 | if (sbc_check_valid_sectors(cmd) < 0) | 552 | if (sbc_check_valid_sectors(cmd) < 0) |
563 | goto out_invalid_cdb_field; | 553 | goto out_invalid_cdb_field; |
564 | } | 554 | } |
565 | cmd->execute_cmd = sbc_emulate_synchronize_cache; | 555 | cmd->execute_cmd = ops->execute_sync_cache; |
566 | break; | 556 | break; |
567 | case UNMAP: | 557 | case UNMAP: |
568 | size = get_unaligned_be16(&cdb[7]); | 558 | size = get_unaligned_be16(&cdb[7]); |