Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Grover and committed by
Nicholas Bellinger
c638830d 65b0c78d

+16 -8
+16 -8
drivers/target/target_core_device.c
··· 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) ··· 969 965 return -EINVAL; 970 966 } 971 967 972 - if (dev->transport->fua_write_emulated == 0) { 968 + if (flag && dev->transport->fua_write_emulated == 0) { 973 969 pr_err("fua_write_emulated not supported\n"); 974 970 return -EINVAL; 975 971 } ··· 986 982 return -EINVAL; 987 983 } 988 984 989 - pr_err("ua read emulated not supported\n"); 990 - return -EINVAL; 985 + if (flag) { 986 + pr_err("ua read emulated not supported\n"); 987 + return -EINVAL; 988 + } 989 + 990 + return 0; 991 991 } 992 992 993 993 int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) ··· 1000 992 pr_err("Illegal value %d\n", flag); 1001 993 return -EINVAL; 1002 994 } 1003 - if (dev->transport->write_cache_emulated == 0) { 995 + if (flag && dev->transport->write_cache_emulated == 0) { 1004 996 pr_err("write_cache_emulated not supported\n"); 1005 997 return -EINVAL; 1006 998 } ··· 1061 1053 * We expect this value to be non-zero when generic Block Layer 1062 1054 * Discard supported is detected iblock_create_virtdevice(). 1063 1055 */ 1064 - if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1056 + if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1065 1057 pr_err("Generic Block Discard not supported\n"); 1066 1058 return -ENOSYS; 1067 1059 } ··· 1082 1074 * We expect this value to be non-zero when generic Block Layer 1083 1075 * Discard supported is detected iblock_create_virtdevice(). 1084 1076 */ 1085 - if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1077 + if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { 1086 1078 pr_err("Generic Block Discard not supported\n"); 1087 1079 return -ENOSYS; 1088 1080 }