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

scsi: target: iscsi: Replace tpg enable attr with ops.enable

Remove tpg/enable attribute. Add fabric ops enable_tpg implementation
instead.

Link: https://lore.kernel.org/r/20210910084133.17956-3-d.bogdanov@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Dmitry Bogdanov and committed by
Martin K. Petersen
382731ec 80ed33c8

+32 -59
+32 -59
drivers/target/iscsi/iscsi_target_configfs.c
··· 1005 1005 1006 1006 /* Start items for lio_target_tpg_cit */ 1007 1007 1008 - static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page) 1009 - { 1010 - struct se_portal_group *se_tpg = to_tpg(item); 1011 - struct iscsi_portal_group *tpg = container_of(se_tpg, 1012 - struct iscsi_portal_group, tpg_se_tpg); 1013 - ssize_t len; 1014 - 1015 - spin_lock(&tpg->tpg_state_lock); 1016 - len = sprintf(page, "%d\n", 1017 - (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0); 1018 - spin_unlock(&tpg->tpg_state_lock); 1019 - 1020 - return len; 1021 - } 1022 - 1023 - static ssize_t lio_target_tpg_enable_store(struct config_item *item, 1024 - const char *page, size_t count) 1025 - { 1026 - struct se_portal_group *se_tpg = to_tpg(item); 1027 - struct iscsi_portal_group *tpg = container_of(se_tpg, 1028 - struct iscsi_portal_group, tpg_se_tpg); 1029 - u32 op; 1030 - int ret; 1031 - 1032 - ret = kstrtou32(page, 0, &op); 1033 - if (ret) 1034 - return ret; 1035 - if ((op != 1) && (op != 0)) { 1036 - pr_err("Illegal value for tpg_enable: %u\n", op); 1037 - return -EINVAL; 1038 - } 1039 - 1040 - ret = iscsit_get_tpg(tpg); 1041 - if (ret < 0) 1042 - return -EINVAL; 1043 - 1044 - if (op) { 1045 - ret = iscsit_tpg_enable_portal_group(tpg); 1046 - if (ret < 0) 1047 - goto out; 1048 - } else { 1049 - /* 1050 - * iscsit_tpg_disable_portal_group() assumes force=1 1051 - */ 1052 - ret = iscsit_tpg_disable_portal_group(tpg, 1); 1053 - if (ret < 0) 1054 - goto out; 1055 - } 1056 - 1057 - iscsit_put_tpg(tpg); 1058 - return count; 1059 - out: 1060 - iscsit_put_tpg(tpg); 1061 - return -EINVAL; 1062 - } 1063 - 1064 - 1065 1008 static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item, 1066 1009 char *page) 1067 1010 { 1068 1011 return target_show_dynamic_sessions(to_tpg(item), page); 1069 1012 } 1070 1013 1071 - CONFIGFS_ATTR(lio_target_tpg_, enable); 1072 1014 CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions); 1073 1015 1074 1016 static struct configfs_attribute *lio_target_tpg_attrs[] = { 1075 - &lio_target_tpg_attr_enable, 1076 1017 &lio_target_tpg_attr_dynamic_sessions, 1077 1018 NULL, 1078 1019 }; ··· 1068 1127 free_out: 1069 1128 kfree(tpg); 1070 1129 return NULL; 1130 + } 1131 + 1132 + static int lio_target_tiqn_enabletpg(struct se_portal_group *se_tpg, 1133 + bool enable) 1134 + { 1135 + struct iscsi_portal_group *tpg = container_of(se_tpg, 1136 + struct iscsi_portal_group, tpg_se_tpg); 1137 + int ret; 1138 + 1139 + ret = iscsit_get_tpg(tpg); 1140 + if (ret < 0) 1141 + return -EINVAL; 1142 + 1143 + if (enable) { 1144 + ret = iscsit_tpg_enable_portal_group(tpg); 1145 + if (ret < 0) 1146 + goto out; 1147 + } else { 1148 + /* 1149 + * iscsit_tpg_disable_portal_group() assumes force=1 1150 + */ 1151 + ret = iscsit_tpg_disable_portal_group(tpg, 1); 1152 + if (ret < 0) 1153 + goto out; 1154 + } 1155 + 1156 + iscsit_put_tpg(tpg); 1157 + return 0; 1158 + out: 1159 + iscsit_put_tpg(tpg); 1160 + return -EINVAL; 1071 1161 } 1072 1162 1073 1163 static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg) ··· 1528 1556 .fabric_drop_wwn = lio_target_call_coredeltiqn, 1529 1557 .add_wwn_groups = lio_target_add_wwn_groups, 1530 1558 .fabric_make_tpg = lio_target_tiqn_addtpg, 1559 + .fabric_enable_tpg = lio_target_tiqn_enabletpg, 1531 1560 .fabric_drop_tpg = lio_target_tiqn_deltpg, 1532 1561 .fabric_make_np = lio_target_call_addnptotpg, 1533 1562 .fabric_drop_np = lio_target_call_delnpfromtpg,