Commit c638830d040696ff2bae07785fd4277e7e3fe7c4
Committed by
Nicholas Bellinger
1 parent
65b0c78d5a
Exists in
master
and in
6 other branches
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>
Showing 1 changed file with 16 additions and 8 deletions Side-by-side Diff
drivers/target/target_core_device.c
... | ... | @@ -954,8 +954,12 @@ |
954 | 954 | return -EINVAL; |
955 | 955 | } |
956 | 956 | |
957 | - pr_err("dpo_emulated not supported\n"); | |
958 | - return -EINVAL; | |
957 | + if (flag) { | |
958 | + pr_err("dpo_emulated not supported\n"); | |
959 | + return -EINVAL; | |
960 | + } | |
961 | + | |
962 | + return 0; | |
959 | 963 | } |
960 | 964 | |
961 | 965 | int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) |
... | ... | @@ -965,7 +969,7 @@ |
965 | 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 | 973 | pr_err("fua_write_emulated not supported\n"); |
970 | 974 | return -EINVAL; |
971 | 975 | } |
... | ... | @@ -982,8 +986,12 @@ |
982 | 986 | return -EINVAL; |
983 | 987 | } |
984 | 988 | |
985 | - pr_err("ua read emulated not supported\n"); | |
986 | - return -EINVAL; | |
989 | + if (flag) { | |
990 | + pr_err("ua read emulated not supported\n"); | |
991 | + return -EINVAL; | |
992 | + } | |
993 | + | |
994 | + return 0; | |
987 | 995 | } |
988 | 996 | |
989 | 997 | int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) |
... | ... | @@ -992,7 +1000,7 @@ |
992 | 1000 | pr_err("Illegal value %d\n", flag); |
993 | 1001 | return -EINVAL; |
994 | 1002 | } |
995 | - if (dev->transport->write_cache_emulated == 0) { | |
1003 | + if (flag && dev->transport->write_cache_emulated == 0) { | |
996 | 1004 | pr_err("write_cache_emulated not supported\n"); |
997 | 1005 | return -EINVAL; |
998 | 1006 | } |
... | ... | @@ -1053,7 +1061,7 @@ |
1053 | 1061 | * We expect this value to be non-zero when generic Block Layer |
1054 | 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 | 1065 | pr_err("Generic Block Discard not supported\n"); |
1058 | 1066 | return -ENOSYS; |
1059 | 1067 | } |
... | ... | @@ -1074,7 +1082,7 @@ |
1074 | 1082 | * We expect this value to be non-zero when generic Block Layer |
1075 | 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 | 1086 | pr_err("Generic Block Discard not supported\n"); |
1079 | 1087 | return -ENOSYS; |
1080 | 1088 | } |