aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-11-30 15:11:50 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2011-12-06 01:00:58 -0500
commitc638830d040696ff2bae07785fd4277e7e3fe7c4 (patch)
treed81f55b5ecbbecadcd3dc81edfd9f0dedc9901b8 /drivers
parent65b0c78d5a0ca2cb82b7b9f54f855896e0d7fc10 (diff)
target: Don't return an error if disabling unsupported features
If an attribute is present (but not yet supported) it should be OK to write 0 (a no-op) to the attribute. This is an issue because userspace should be able to save and restore all set attribute values without error. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/target/target_core_device.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index e2be1f510da8..9b8639425472 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -954,8 +954,12 @@ int se_dev_set_emulate_dpo(struct se_device *dev, int flag)
954 return -EINVAL; 954 return -EINVAL;
955 } 955 }
956 956
957 pr_err("dpo_emulated not supported\n"); 957 if (flag) {
958 return -EINVAL; 958 pr_err("dpo_emulated not supported\n");
959 return -EINVAL;
960 }
961
962 return 0;
959} 963}
960 964
961int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) 965int se_dev_set_emulate_fua_write(struct se_device *dev, int flag)
@@ -965,7 +969,7 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag)
965 return -EINVAL; 969 return -EINVAL;
966 } 970 }
967 971
968 if (dev->transport->fua_write_emulated == 0) { 972 if (flag && dev->transport->fua_write_emulated == 0) {
969 pr_err("fua_write_emulated not supported\n"); 973 pr_err("fua_write_emulated not supported\n");
970 return -EINVAL; 974 return -EINVAL;
971 } 975 }
@@ -982,8 +986,12 @@ int se_dev_set_emulate_fua_read(struct se_device *dev, int flag)
982 return -EINVAL; 986 return -EINVAL;
983 } 987 }
984 988
985 pr_err("ua read emulated not supported\n"); 989 if (flag) {
986 return -EINVAL; 990 pr_err("ua read emulated not supported\n");
991 return -EINVAL;
992 }
993
994 return 0;
987} 995}
988 996
989int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) 997int se_dev_set_emulate_write_cache(struct se_device *dev, int flag)
@@ -992,7 +1000,7 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag)
992 pr_err("Illegal value %d\n", flag); 1000 pr_err("Illegal value %d\n", flag);
993 return -EINVAL; 1001 return -EINVAL;
994 } 1002 }
995 if (dev->transport->write_cache_emulated == 0) { 1003 if (flag && dev->transport->write_cache_emulated == 0) {
996 pr_err("write_cache_emulated not supported\n"); 1004 pr_err("write_cache_emulated not supported\n");
997 return -EINVAL; 1005 return -EINVAL;
998 } 1006 }
@@ -1053,7 +1061,7 @@ int se_dev_set_emulate_tpu(struct se_device *dev, int flag)
1053 * We expect this value to be non-zero when generic Block Layer 1061 * We expect this value to be non-zero when generic Block Layer
1054 * Discard supported is detected iblock_create_virtdevice(). 1062 * Discard supported is detected iblock_create_virtdevice().
1055 */ 1063 */
1056 if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1064 if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) {
1057 pr_err("Generic Block Discard not supported\n"); 1065 pr_err("Generic Block Discard not supported\n");
1058 return -ENOSYS; 1066 return -ENOSYS;
1059 } 1067 }
@@ -1074,7 +1082,7 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag)
1074 * We expect this value to be non-zero when generic Block Layer 1082 * We expect this value to be non-zero when generic Block Layer
1075 * Discard supported is detected iblock_create_virtdevice(). 1083 * Discard supported is detected iblock_create_virtdevice().
1076 */ 1084 */
1077 if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1085 if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) {
1078 pr_err("Generic Block Discard not supported\n"); 1086 pr_err("Generic Block Discard not supported\n");
1079 return -ENOSYS; 1087 return -ENOSYS;
1080 } 1088 }