diff options
author | Christoph Hellwig <hch@infradead.org> | 2011-10-14 07:30:17 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:21:31 -0400 |
commit | f55918fa3202a646dad2404f7de008108edc5048 (patch) | |
tree | 6b39361985ad31ce9511763e504dfdf89e92412b /drivers/target | |
parent | df5fa691ce61aedd3e4dbcf960ee44f05b797d8b (diff) |
target: clean up the backend interface to caching parameters
Remove the dpo_emulated, fua_write_emulated, fua_read_emulated and
write_cache_emulated methods, and replace them with a simple bitfields in
se_subsystem_api in those cases where they ever returned one.
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_device.c | 55 | ||||
-rw-r--r-- | drivers/target/target_core_file.c | 33 | ||||
-rw-r--r-- | drivers/target/target_core_iblock.c | 34 |
3 files changed, 19 insertions, 103 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index ca6e4a4df134..81352b7f9130 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -972,36 +972,24 @@ int se_dev_set_unmap_granularity_alignment( | |||
972 | 972 | ||
973 | int se_dev_set_emulate_dpo(struct se_device *dev, int flag) | 973 | int se_dev_set_emulate_dpo(struct se_device *dev, int flag) |
974 | { | 974 | { |
975 | if ((flag != 0) && (flag != 1)) { | 975 | if (flag != 0 && flag != 1) { |
976 | pr_err("Illegal value %d\n", flag); | 976 | pr_err("Illegal value %d\n", flag); |
977 | return -EINVAL; | 977 | return -EINVAL; |
978 | } | 978 | } |
979 | if (dev->transport->dpo_emulated == NULL) { | 979 | |
980 | pr_err("dev->transport->dpo_emulated is NULL\n"); | 980 | pr_err("dpo_emulated not supported\n"); |
981 | return -EINVAL; | 981 | return -EINVAL; |
982 | } | ||
983 | if (dev->transport->dpo_emulated(dev) == 0) { | ||
984 | pr_err("dev->transport->dpo_emulated not supported\n"); | ||
985 | return -EINVAL; | ||
986 | } | ||
987 | dev->se_sub_dev->se_dev_attrib.emulate_dpo = flag; | ||
988 | pr_debug("dev[%p]: SE Device Page Out (DPO) Emulation" | ||
989 | " bit: %d\n", dev, dev->se_sub_dev->se_dev_attrib.emulate_dpo); | ||
990 | return 0; | ||
991 | } | 982 | } |
992 | 983 | ||
993 | int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) | 984 | int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) |
994 | { | 985 | { |
995 | if ((flag != 0) && (flag != 1)) { | 986 | if (flag != 0 && flag != 1) { |
996 | pr_err("Illegal value %d\n", flag); | 987 | pr_err("Illegal value %d\n", flag); |
997 | return -EINVAL; | 988 | return -EINVAL; |
998 | } | 989 | } |
999 | if (dev->transport->fua_write_emulated == NULL) { | 990 | |
1000 | pr_err("dev->transport->fua_write_emulated is NULL\n"); | 991 | if (dev->transport->fua_write_emulated == 0) { |
1001 | return -EINVAL; | 992 | pr_err("fua_write_emulated not supported\n"); |
1002 | } | ||
1003 | if (dev->transport->fua_write_emulated(dev) == 0) { | ||
1004 | pr_err("dev->transport->fua_write_emulated not supported\n"); | ||
1005 | return -EINVAL; | 993 | return -EINVAL; |
1006 | } | 994 | } |
1007 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write = flag; | 995 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write = flag; |
@@ -1012,36 +1000,23 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) | |||
1012 | 1000 | ||
1013 | int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) | 1001 | int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) |
1014 | { | 1002 | { |
1015 | if ((flag != 0) && (flag != 1)) { | 1003 | if (flag != 0 && flag != 1) { |
1016 | pr_err("Illegal value %d\n", flag); | 1004 | pr_err("Illegal value %d\n", flag); |
1017 | return -EINVAL; | 1005 | return -EINVAL; |
1018 | } | 1006 | } |
1019 | if (dev->transport->fua_read_emulated == NULL) { | 1007 | |
1020 | pr_err("dev->transport->fua_read_emulated is NULL\n"); | 1008 | pr_err("ua read emulated not supported\n"); |
1021 | return -EINVAL; | 1009 | return -EINVAL; |
1022 | } | ||
1023 | if (dev->transport->fua_read_emulated(dev) == 0) { | ||
1024 | pr_err("dev->transport->fua_read_emulated not supported\n"); | ||
1025 | return -EINVAL; | ||
1026 | } | ||
1027 | dev->se_sub_dev->se_dev_attrib.emulate_fua_read = flag; | ||
1028 | pr_debug("dev[%p]: SE Device Forced Unit Access READs: %d\n", | ||
1029 | dev, dev->se_sub_dev->se_dev_attrib.emulate_fua_read); | ||
1030 | return 0; | ||
1031 | } | 1010 | } |
1032 | 1011 | ||
1033 | int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) | 1012 | int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) |
1034 | { | 1013 | { |
1035 | if ((flag != 0) && (flag != 1)) { | 1014 | if (flag != 0 && flag != 1) { |
1036 | pr_err("Illegal value %d\n", flag); | 1015 | pr_err("Illegal value %d\n", flag); |
1037 | return -EINVAL; | 1016 | return -EINVAL; |
1038 | } | 1017 | } |
1039 | if (dev->transport->write_cache_emulated == NULL) { | 1018 | if (dev->transport->write_cache_emulated == 0) { |
1040 | pr_err("dev->transport->write_cache_emulated is NULL\n"); | 1019 | pr_err("write_cache_emulated not supported\n"); |
1041 | return -EINVAL; | ||
1042 | } | ||
1043 | if (dev->transport->write_cache_emulated(dev) == 0) { | ||
1044 | pr_err("dev->transport->write_cache_emulated not supported\n"); | ||
1045 | return -EINVAL; | 1020 | return -EINVAL; |
1046 | } | 1021 | } |
1047 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache = flag; | 1022 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache = flag; |
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 98aa5836448b..19a0be9c6570 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -400,33 +400,6 @@ static void fd_emulate_sync_cache(struct se_task *task) | |||
400 | } | 400 | } |
401 | 401 | ||
402 | /* | 402 | /* |
403 | * Tell TCM Core that we are capable of WriteCache emulation for | ||
404 | * an underlying struct se_device. | ||
405 | */ | ||
406 | static int fd_emulated_write_cache(struct se_device *dev) | ||
407 | { | ||
408 | return 1; | ||
409 | } | ||
410 | |||
411 | static int fd_emulated_dpo(struct se_device *dev) | ||
412 | { | ||
413 | return 0; | ||
414 | } | ||
415 | /* | ||
416 | * Tell TCM Core that we will be emulating Forced Unit Access (FUA) for WRITEs | ||
417 | * for TYPE_DISK. | ||
418 | */ | ||
419 | static int fd_emulated_fua_write(struct se_device *dev) | ||
420 | { | ||
421 | return 1; | ||
422 | } | ||
423 | |||
424 | static int fd_emulated_fua_read(struct se_device *dev) | ||
425 | { | ||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | /* | ||
430 | * WRITE Force Unit Access (FUA) emulation on a per struct se_task | 403 | * WRITE Force Unit Access (FUA) emulation on a per struct se_task |
431 | * LBA range basis.. | 404 | * LBA range basis.. |
432 | */ | 405 | */ |
@@ -640,15 +613,13 @@ static struct se_subsystem_api fileio_template = { | |||
640 | .name = "fileio", | 613 | .name = "fileio", |
641 | .owner = THIS_MODULE, | 614 | .owner = THIS_MODULE, |
642 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, | 615 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, |
616 | .write_cache_emulated = 1, | ||
617 | .fua_write_emulated = 1, | ||
643 | .attach_hba = fd_attach_hba, | 618 | .attach_hba = fd_attach_hba, |
644 | .detach_hba = fd_detach_hba, | 619 | .detach_hba = fd_detach_hba, |
645 | .allocate_virtdevice = fd_allocate_virtdevice, | 620 | .allocate_virtdevice = fd_allocate_virtdevice, |
646 | .create_virtdevice = fd_create_virtdevice, | 621 | .create_virtdevice = fd_create_virtdevice, |
647 | .free_device = fd_free_device, | 622 | .free_device = fd_free_device, |
648 | .dpo_emulated = fd_emulated_dpo, | ||
649 | .fua_write_emulated = fd_emulated_fua_write, | ||
650 | .fua_read_emulated = fd_emulated_fua_read, | ||
651 | .write_cache_emulated = fd_emulated_write_cache, | ||
652 | .alloc_task = fd_alloc_task, | 623 | .alloc_task = fd_alloc_task, |
653 | .do_task = fd_do_task, | 624 | .do_task = fd_do_task, |
654 | .do_sync_cache = fd_emulate_sync_cache, | 625 | .do_sync_cache = fd_emulate_sync_cache, |
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index d9ad2a216eaa..41ad02b5fb87 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -351,34 +351,6 @@ static void iblock_emulate_sync_cache(struct se_task *task) | |||
351 | submit_bio(WRITE_FLUSH, bio); | 351 | submit_bio(WRITE_FLUSH, bio); |
352 | } | 352 | } |
353 | 353 | ||
354 | /* | ||
355 | * Tell TCM Core that we are capable of WriteCache emulation for | ||
356 | * an underlying struct se_device. | ||
357 | */ | ||
358 | static int iblock_emulated_write_cache(struct se_device *dev) | ||
359 | { | ||
360 | return 1; | ||
361 | } | ||
362 | |||
363 | static int iblock_emulated_dpo(struct se_device *dev) | ||
364 | { | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * Tell TCM Core that we will be emulating Forced Unit Access (FUA) for WRITEs | ||
370 | * for TYPE_DISK. | ||
371 | */ | ||
372 | static int iblock_emulated_fua_write(struct se_device *dev) | ||
373 | { | ||
374 | return 1; | ||
375 | } | ||
376 | |||
377 | static int iblock_emulated_fua_read(struct se_device *dev) | ||
378 | { | ||
379 | return 0; | ||
380 | } | ||
381 | |||
382 | static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range) | 354 | static int iblock_do_discard(struct se_device *dev, sector_t lba, u32 range) |
383 | { | 355 | { |
384 | struct iblock_dev *ibd = dev->dev_ptr; | 356 | struct iblock_dev *ibd = dev->dev_ptr; |
@@ -679,15 +651,13 @@ static struct se_subsystem_api iblock_template = { | |||
679 | .name = "iblock", | 651 | .name = "iblock", |
680 | .owner = THIS_MODULE, | 652 | .owner = THIS_MODULE, |
681 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, | 653 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, |
654 | .write_cache_emulated = 1, | ||
655 | .fua_write_emulated = 1, | ||
682 | .attach_hba = iblock_attach_hba, | 656 | .attach_hba = iblock_attach_hba, |
683 | .detach_hba = iblock_detach_hba, | 657 | .detach_hba = iblock_detach_hba, |
684 | .allocate_virtdevice = iblock_allocate_virtdevice, | 658 | .allocate_virtdevice = iblock_allocate_virtdevice, |
685 | .create_virtdevice = iblock_create_virtdevice, | 659 | .create_virtdevice = iblock_create_virtdevice, |
686 | .free_device = iblock_free_device, | 660 | .free_device = iblock_free_device, |
687 | .dpo_emulated = iblock_emulated_dpo, | ||
688 | .fua_write_emulated = iblock_emulated_fua_write, | ||
689 | .fua_read_emulated = iblock_emulated_fua_read, | ||
690 | .write_cache_emulated = iblock_emulated_write_cache, | ||
691 | .alloc_task = iblock_alloc_task, | 661 | .alloc_task = iblock_alloc_task, |
692 | .do_task = iblock_do_task, | 662 | .do_task = iblock_do_task, |
693 | .do_discard = iblock_do_discard, | 663 | .do_discard = iblock_do_discard, |