diff options
-rw-r--r-- | Documentation/filesystems/configfs/configfs.txt | 11 | ||||
-rw-r--r-- | drivers/infiniband/core/cma_configfs.c | 31 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 75 | ||||
-rw-r--r-- | drivers/target/target_core_configfs.c | 203 | ||||
-rw-r--r-- | drivers/target/target_core_fabric_configfs.c | 194 | ||||
-rw-r--r-- | drivers/target/target_core_internal.h | 1 | ||||
-rw-r--r-- | drivers/target/target_core_stat.c | 41 | ||||
-rw-r--r-- | drivers/usb/gadget/configfs.c | 36 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_mass_storage.c | 6 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_rndis.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/function/uvc_configfs.c | 198 | ||||
-rw-r--r-- | fs/configfs/dir.c | 44 | ||||
-rw-r--r-- | fs/configfs/item.c | 1 | ||||
-rw-r--r-- | fs/dlm/config.c | 38 | ||||
-rw-r--r-- | fs/ocfs2/cluster/nodemanager.c | 22 | ||||
-rw-r--r-- | include/linux/configfs.h | 11 | ||||
-rw-r--r-- | include/target/target_core_base.h | 3 |
17 files changed, 286 insertions, 634 deletions
diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt index e5fe521eea1d..8ec9136aae56 100644 --- a/Documentation/filesystems/configfs/configfs.txt +++ b/Documentation/filesystems/configfs/configfs.txt | |||
@@ -250,7 +250,8 @@ child item. | |||
250 | struct config_item cg_item; | 250 | struct config_item cg_item; |
251 | struct list_head cg_children; | 251 | struct list_head cg_children; |
252 | struct configfs_subsystem *cg_subsys; | 252 | struct configfs_subsystem *cg_subsys; |
253 | struct config_group **default_groups; | 253 | struct list_head default_groups; |
254 | struct list_head group_entry; | ||
254 | }; | 255 | }; |
255 | 256 | ||
256 | void config_group_init(struct config_group *group); | 257 | void config_group_init(struct config_group *group); |
@@ -420,15 +421,15 @@ These automatic subgroups, or default groups, do not preclude other | |||
420 | children of the parent group. If ct_group_ops->make_group() exists, | 421 | children of the parent group. If ct_group_ops->make_group() exists, |
421 | other child groups can be created on the parent group directly. | 422 | other child groups can be created on the parent group directly. |
422 | 423 | ||
423 | A configfs subsystem specifies default groups by filling in the | 424 | A configfs subsystem specifies default groups by adding them using the |
424 | NULL-terminated array default_groups on the config_group structure. | 425 | configfs_add_default_group() function to the parent config_group |
425 | Each group in that array is populated in the configfs tree at the same | 426 | structure. Each added group is populated in the configfs tree at the same |
426 | time as the parent group. Similarly, they are removed at the same time | 427 | time as the parent group. Similarly, they are removed at the same time |
427 | as the parent. No extra notification is provided. When a ->drop_item() | 428 | as the parent. No extra notification is provided. When a ->drop_item() |
428 | method call notifies the subsystem the parent group is going away, it | 429 | method call notifies the subsystem the parent group is going away, it |
429 | also means every default group child associated with that parent group. | 430 | also means every default group child associated with that parent group. |
430 | 431 | ||
431 | As a consequence of this, default_groups cannot be removed directly via | 432 | As a consequence of this, default groups cannot be removed directly via |
432 | rmdir(2). They also are not considered when rmdir(2) on the parent | 433 | rmdir(2). They also are not considered when rmdir(2) on the parent |
433 | group is checking for children. | 434 | group is checking for children. |
434 | 435 | ||
diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c index 18b112aa577e..41573df1d9fc 100644 --- a/drivers/infiniband/core/cma_configfs.c +++ b/drivers/infiniband/core/cma_configfs.c | |||
@@ -49,8 +49,6 @@ struct cma_dev_group { | |||
49 | char name[IB_DEVICE_NAME_MAX]; | 49 | char name[IB_DEVICE_NAME_MAX]; |
50 | struct config_group device_group; | 50 | struct config_group device_group; |
51 | struct config_group ports_group; | 51 | struct config_group ports_group; |
52 | struct config_group *default_dev_group[2]; | ||
53 | struct config_group **default_ports_group; | ||
54 | struct cma_dev_port_group *ports; | 52 | struct cma_dev_port_group *ports; |
55 | }; | 53 | }; |
56 | 54 | ||
@@ -158,7 +156,6 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group, | |||
158 | unsigned int i; | 156 | unsigned int i; |
159 | unsigned int ports_num; | 157 | unsigned int ports_num; |
160 | struct cma_dev_port_group *ports; | 158 | struct cma_dev_port_group *ports; |
161 | struct config_group **ports_group; | ||
162 | int err; | 159 | int err; |
163 | 160 | ||
164 | ibdev = cma_get_ib_dev(cma_dev); | 161 | ibdev = cma_get_ib_dev(cma_dev); |
@@ -169,9 +166,8 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group, | |||
169 | ports_num = ibdev->phys_port_cnt; | 166 | ports_num = ibdev->phys_port_cnt; |
170 | ports = kcalloc(ports_num, sizeof(*cma_dev_group->ports), | 167 | ports = kcalloc(ports_num, sizeof(*cma_dev_group->ports), |
171 | GFP_KERNEL); | 168 | GFP_KERNEL); |
172 | ports_group = kcalloc(ports_num + 1, sizeof(*ports_group), GFP_KERNEL); | ||
173 | 169 | ||
174 | if (!ports || !ports_group) { | 170 | if (!ports) { |
175 | err = -ENOMEM; | 171 | err = -ENOMEM; |
176 | goto free; | 172 | goto free; |
177 | } | 173 | } |
@@ -185,18 +181,16 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group, | |||
185 | config_group_init_type_name(&ports[i].group, | 181 | config_group_init_type_name(&ports[i].group, |
186 | port_str, | 182 | port_str, |
187 | &cma_port_group_type); | 183 | &cma_port_group_type); |
188 | ports_group[i] = &ports[i].group; | 184 | configfs_add_default_group(&ports[i].group, |
185 | &cma_dev_group->ports_group); | ||
186 | |||
189 | } | 187 | } |
190 | ports_group[i] = NULL; | ||
191 | cma_dev_group->default_ports_group = ports_group; | ||
192 | cma_dev_group->ports = ports; | 188 | cma_dev_group->ports = ports; |
193 | 189 | ||
194 | return 0; | 190 | return 0; |
195 | free: | 191 | free: |
196 | kfree(ports); | 192 | kfree(ports); |
197 | kfree(ports_group); | ||
198 | cma_dev_group->ports = NULL; | 193 | cma_dev_group->ports = NULL; |
199 | cma_dev_group->default_ports_group = NULL; | ||
200 | return err; | 194 | return err; |
201 | } | 195 | } |
202 | 196 | ||
@@ -220,9 +214,7 @@ static void release_cma_ports_group(struct config_item *item) | |||
220 | ports_group); | 214 | ports_group); |
221 | 215 | ||
222 | kfree(cma_dev_group->ports); | 216 | kfree(cma_dev_group->ports); |
223 | kfree(cma_dev_group->default_ports_group); | ||
224 | cma_dev_group->ports = NULL; | 217 | cma_dev_group->ports = NULL; |
225 | cma_dev_group->default_ports_group = NULL; | ||
226 | }; | 218 | }; |
227 | 219 | ||
228 | static struct configfs_item_operations cma_ports_item_ops = { | 220 | static struct configfs_item_operations cma_ports_item_ops = { |
@@ -263,22 +255,17 @@ static struct config_group *make_cma_dev(struct config_group *group, | |||
263 | 255 | ||
264 | strncpy(cma_dev_group->name, name, sizeof(cma_dev_group->name)); | 256 | strncpy(cma_dev_group->name, name, sizeof(cma_dev_group->name)); |
265 | 257 | ||
266 | err = make_cma_ports(cma_dev_group, cma_dev); | ||
267 | if (err) | ||
268 | goto fail; | ||
269 | |||
270 | cma_dev_group->ports_group.default_groups = | ||
271 | cma_dev_group->default_ports_group; | ||
272 | config_group_init_type_name(&cma_dev_group->ports_group, "ports", | 258 | config_group_init_type_name(&cma_dev_group->ports_group, "ports", |
273 | &cma_ports_group_type); | 259 | &cma_ports_group_type); |
274 | 260 | ||
275 | cma_dev_group->device_group.default_groups | 261 | err = make_cma_ports(cma_dev_group, cma_dev); |
276 | = cma_dev_group->default_dev_group; | 262 | if (err) |
277 | cma_dev_group->default_dev_group[0] = &cma_dev_group->ports_group; | 263 | goto fail; |
278 | cma_dev_group->default_dev_group[1] = NULL; | ||
279 | 264 | ||
280 | config_group_init_type_name(&cma_dev_group->device_group, name, | 265 | config_group_init_type_name(&cma_dev_group->device_group, name, |
281 | &cma_device_group_type); | 266 | &cma_device_group_type); |
267 | configfs_add_default_group(&cma_dev_group->ports_group, | ||
268 | &cma_dev_group->device_group); | ||
282 | 269 | ||
283 | cma_deref_dev(cma_dev); | 270 | cma_deref_dev(cma_dev); |
284 | return &cma_dev_group->device_group; | 271 | return &cma_dev_group->device_group; |
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 2f821de63049..a24443ba59ea 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -771,21 +771,11 @@ static int lio_target_init_nodeacl(struct se_node_acl *se_nacl, | |||
771 | { | 771 | { |
772 | struct iscsi_node_acl *acl = | 772 | struct iscsi_node_acl *acl = |
773 | container_of(se_nacl, struct iscsi_node_acl, se_node_acl); | 773 | container_of(se_nacl, struct iscsi_node_acl, se_node_acl); |
774 | struct config_group *stats_cg = &se_nacl->acl_fabric_stat_group; | ||
775 | |||
776 | stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | ||
777 | GFP_KERNEL); | ||
778 | if (!stats_cg->default_groups) { | ||
779 | pr_err("Unable to allocate memory for" | ||
780 | " stats_cg->default_groups\n"); | ||
781 | return -ENOMEM; | ||
782 | } | ||
783 | 774 | ||
784 | stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group; | ||
785 | stats_cg->default_groups[1] = NULL; | ||
786 | config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group, | 775 | config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group, |
787 | "iscsi_sess_stats", &iscsi_stat_sess_cit); | 776 | "iscsi_sess_stats", &iscsi_stat_sess_cit); |
788 | 777 | configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group, | |
778 | &se_nacl->acl_fabric_stat_group); | ||
789 | return 0; | 779 | return 0; |
790 | } | 780 | } |
791 | 781 | ||
@@ -793,17 +783,8 @@ static void lio_target_cleanup_nodeacl( struct se_node_acl *se_nacl) | |||
793 | { | 783 | { |
794 | struct iscsi_node_acl *acl = container_of(se_nacl, | 784 | struct iscsi_node_acl *acl = container_of(se_nacl, |
795 | struct iscsi_node_acl, se_node_acl); | 785 | struct iscsi_node_acl, se_node_acl); |
796 | struct config_item *df_item; | 786 | |
797 | struct config_group *stats_cg; | 787 | configfs_remove_default_groups(&acl->se_node_acl.acl_fabric_stat_group); |
798 | int i; | ||
799 | |||
800 | stats_cg = &acl->se_node_acl.acl_fabric_stat_group; | ||
801 | for (i = 0; stats_cg->default_groups[i]; i++) { | ||
802 | df_item = &stats_cg->default_groups[i]->cg_item; | ||
803 | stats_cg->default_groups[i] = NULL; | ||
804 | config_item_put(df_item); | ||
805 | } | ||
806 | kfree(stats_cg->default_groups); | ||
807 | } | 788 | } |
808 | 789 | ||
809 | /* End items for lio_target_acl_cit */ | 790 | /* End items for lio_target_acl_cit */ |
@@ -1260,42 +1241,37 @@ static struct se_wwn *lio_target_call_coreaddtiqn( | |||
1260 | struct config_group *group, | 1241 | struct config_group *group, |
1261 | const char *name) | 1242 | const char *name) |
1262 | { | 1243 | { |
1263 | struct config_group *stats_cg; | ||
1264 | struct iscsi_tiqn *tiqn; | 1244 | struct iscsi_tiqn *tiqn; |
1265 | 1245 | ||
1266 | tiqn = iscsit_add_tiqn((unsigned char *)name); | 1246 | tiqn = iscsit_add_tiqn((unsigned char *)name); |
1267 | if (IS_ERR(tiqn)) | 1247 | if (IS_ERR(tiqn)) |
1268 | return ERR_CAST(tiqn); | 1248 | return ERR_CAST(tiqn); |
1269 | /* | ||
1270 | * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group. | ||
1271 | */ | ||
1272 | stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; | ||
1273 | |||
1274 | stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6, | ||
1275 | GFP_KERNEL); | ||
1276 | if (!stats_cg->default_groups) { | ||
1277 | pr_err("Unable to allocate memory for" | ||
1278 | " stats_cg->default_groups\n"); | ||
1279 | iscsit_del_tiqn(tiqn); | ||
1280 | return ERR_PTR(-ENOMEM); | ||
1281 | } | ||
1282 | 1249 | ||
1283 | stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group; | ||
1284 | stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group; | ||
1285 | stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group; | ||
1286 | stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group; | ||
1287 | stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group; | ||
1288 | stats_cg->default_groups[5] = NULL; | ||
1289 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group, | 1250 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group, |
1290 | "iscsi_instance", &iscsi_stat_instance_cit); | 1251 | "iscsi_instance", &iscsi_stat_instance_cit); |
1252 | configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group, | ||
1253 | &tiqn->tiqn_wwn.fabric_stat_group); | ||
1254 | |||
1291 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group, | 1255 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group, |
1292 | "iscsi_sess_err", &iscsi_stat_sess_err_cit); | 1256 | "iscsi_sess_err", &iscsi_stat_sess_err_cit); |
1257 | configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group, | ||
1258 | &tiqn->tiqn_wwn.fabric_stat_group); | ||
1259 | |||
1293 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group, | 1260 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group, |
1294 | "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit); | 1261 | "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit); |
1262 | configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group, | ||
1263 | &tiqn->tiqn_wwn.fabric_stat_group); | ||
1264 | |||
1295 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group, | 1265 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group, |
1296 | "iscsi_login_stats", &iscsi_stat_login_cit); | 1266 | "iscsi_login_stats", &iscsi_stat_login_cit); |
1267 | configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group, | ||
1268 | &tiqn->tiqn_wwn.fabric_stat_group); | ||
1269 | |||
1297 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group, | 1270 | config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group, |
1298 | "iscsi_logout_stats", &iscsi_stat_logout_cit); | 1271 | "iscsi_logout_stats", &iscsi_stat_logout_cit); |
1272 | configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group, | ||
1273 | &tiqn->tiqn_wwn.fabric_stat_group); | ||
1274 | |||
1299 | 1275 | ||
1300 | pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn); | 1276 | pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn); |
1301 | pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:" | 1277 | pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:" |
@@ -1307,17 +1283,8 @@ static void lio_target_call_coredeltiqn( | |||
1307 | struct se_wwn *wwn) | 1283 | struct se_wwn *wwn) |
1308 | { | 1284 | { |
1309 | struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); | 1285 | struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); |
1310 | struct config_item *df_item; | 1286 | |
1311 | struct config_group *stats_cg; | 1287 | configfs_remove_default_groups(&tiqn->tiqn_wwn.fabric_stat_group); |
1312 | int i; | ||
1313 | |||
1314 | stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; | ||
1315 | for (i = 0; stats_cg->default_groups[i]; i++) { | ||
1316 | df_item = &stats_cg->default_groups[i]->cg_item; | ||
1317 | stats_cg->default_groups[i] = NULL; | ||
1318 | config_item_put(df_item); | ||
1319 | } | ||
1320 | kfree(stats_cg->default_groups); | ||
1321 | 1288 | ||
1322 | pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n", | 1289 | pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n", |
1323 | tiqn->tiqn); | 1290 | tiqn->tiqn); |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 713c63d9681b..d498533f09ee 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -194,13 +194,11 @@ static struct config_group *target_core_register_fabric( | |||
194 | pr_debug("Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n", | 194 | pr_debug("Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n", |
195 | &tf->tf_wwn_cit); | 195 | &tf->tf_wwn_cit); |
196 | 196 | ||
197 | tf->tf_group.default_groups = tf->tf_default_groups; | ||
198 | tf->tf_group.default_groups[0] = &tf->tf_disc_group; | ||
199 | tf->tf_group.default_groups[1] = NULL; | ||
200 | |||
201 | config_group_init_type_name(&tf->tf_group, name, &tf->tf_wwn_cit); | 197 | config_group_init_type_name(&tf->tf_group, name, &tf->tf_wwn_cit); |
198 | |||
202 | config_group_init_type_name(&tf->tf_disc_group, "discovery_auth", | 199 | config_group_init_type_name(&tf->tf_disc_group, "discovery_auth", |
203 | &tf->tf_discovery_cit); | 200 | &tf->tf_discovery_cit); |
201 | configfs_add_default_group(&tf->tf_disc_group, &tf->tf_group); | ||
204 | 202 | ||
205 | pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" | 203 | pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" |
206 | " %s\n", tf->tf_group.cg_item.ci_name); | 204 | " %s\n", tf->tf_group.cg_item.ci_name); |
@@ -216,9 +214,6 @@ static void target_core_deregister_fabric( | |||
216 | { | 214 | { |
217 | struct target_fabric_configfs *tf = container_of( | 215 | struct target_fabric_configfs *tf = container_of( |
218 | to_config_group(item), struct target_fabric_configfs, tf_group); | 216 | to_config_group(item), struct target_fabric_configfs, tf_group); |
219 | struct config_group *tf_group; | ||
220 | struct config_item *df_item; | ||
221 | int i; | ||
222 | 217 | ||
223 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Looking up %s in" | 218 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Looking up %s in" |
224 | " tf list\n", config_item_name(item)); | 219 | " tf list\n", config_item_name(item)); |
@@ -230,12 +225,7 @@ static void target_core_deregister_fabric( | |||
230 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci" | 225 | pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci" |
231 | " %s\n", config_item_name(item)); | 226 | " %s\n", config_item_name(item)); |
232 | 227 | ||
233 | tf_group = &tf->tf_group; | 228 | configfs_remove_default_groups(&tf->tf_group); |
234 | for (i = 0; tf_group->default_groups[i]; i++) { | ||
235 | df_item = &tf_group->default_groups[i]->cg_item; | ||
236 | tf_group->default_groups[i] = NULL; | ||
237 | config_item_put(df_item); | ||
238 | } | ||
239 | config_item_put(item); | 229 | config_item_put(item); |
240 | } | 230 | } |
241 | 231 | ||
@@ -2151,7 +2141,6 @@ static void target_core_dev_release(struct config_item *item) | |||
2151 | struct se_device *dev = | 2141 | struct se_device *dev = |
2152 | container_of(dev_cg, struct se_device, dev_group); | 2142 | container_of(dev_cg, struct se_device, dev_group); |
2153 | 2143 | ||
2154 | kfree(dev_cg->default_groups); | ||
2155 | target_free_device(dev); | 2144 | target_free_device(dev); |
2156 | } | 2145 | } |
2157 | 2146 | ||
@@ -2819,8 +2808,6 @@ static struct config_group *target_core_make_subdev( | |||
2819 | struct se_hba *hba = item_to_hba(hba_ci); | 2808 | struct se_hba *hba = item_to_hba(hba_ci); |
2820 | struct target_backend *tb = hba->backend; | 2809 | struct target_backend *tb = hba->backend; |
2821 | struct se_device *dev; | 2810 | struct se_device *dev; |
2822 | struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL; | ||
2823 | struct config_group *dev_stat_grp = NULL; | ||
2824 | int errno = -ENOMEM, ret; | 2811 | int errno = -ENOMEM, ret; |
2825 | 2812 | ||
2826 | ret = mutex_lock_interruptible(&hba->hba_access_mutex); | 2813 | ret = mutex_lock_interruptible(&hba->hba_access_mutex); |
@@ -2831,73 +2818,52 @@ static struct config_group *target_core_make_subdev( | |||
2831 | if (!dev) | 2818 | if (!dev) |
2832 | goto out_unlock; | 2819 | goto out_unlock; |
2833 | 2820 | ||
2834 | dev_cg = &dev->dev_group; | 2821 | config_group_init_type_name(&dev->dev_group, name, &tb->tb_dev_cit); |
2835 | |||
2836 | dev_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6, | ||
2837 | GFP_KERNEL); | ||
2838 | if (!dev_cg->default_groups) | ||
2839 | goto out_free_device; | ||
2840 | 2822 | ||
2841 | config_group_init_type_name(dev_cg, name, &tb->tb_dev_cit); | ||
2842 | config_group_init_type_name(&dev->dev_attrib.da_group, "attrib", | 2823 | config_group_init_type_name(&dev->dev_attrib.da_group, "attrib", |
2843 | &tb->tb_dev_attrib_cit); | 2824 | &tb->tb_dev_attrib_cit); |
2825 | configfs_add_default_group(&dev->dev_attrib.da_group, &dev->dev_group); | ||
2826 | |||
2844 | config_group_init_type_name(&dev->dev_pr_group, "pr", | 2827 | config_group_init_type_name(&dev->dev_pr_group, "pr", |
2845 | &tb->tb_dev_pr_cit); | 2828 | &tb->tb_dev_pr_cit); |
2829 | configfs_add_default_group(&dev->dev_pr_group, &dev->dev_group); | ||
2830 | |||
2846 | config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", | 2831 | config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", |
2847 | &tb->tb_dev_wwn_cit); | 2832 | &tb->tb_dev_wwn_cit); |
2833 | configfs_add_default_group(&dev->t10_wwn.t10_wwn_group, | ||
2834 | &dev->dev_group); | ||
2835 | |||
2848 | config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, | 2836 | config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, |
2849 | "alua", &tb->tb_dev_alua_tg_pt_gps_cit); | 2837 | "alua", &tb->tb_dev_alua_tg_pt_gps_cit); |
2838 | configfs_add_default_group(&dev->t10_alua.alua_tg_pt_gps_group, | ||
2839 | &dev->dev_group); | ||
2840 | |||
2850 | config_group_init_type_name(&dev->dev_stat_grps.stat_group, | 2841 | config_group_init_type_name(&dev->dev_stat_grps.stat_group, |
2851 | "statistics", &tb->tb_dev_stat_cit); | 2842 | "statistics", &tb->tb_dev_stat_cit); |
2843 | configfs_add_default_group(&dev->dev_stat_grps.stat_group, | ||
2844 | &dev->dev_group); | ||
2852 | 2845 | ||
2853 | dev_cg->default_groups[0] = &dev->dev_attrib.da_group; | ||
2854 | dev_cg->default_groups[1] = &dev->dev_pr_group; | ||
2855 | dev_cg->default_groups[2] = &dev->t10_wwn.t10_wwn_group; | ||
2856 | dev_cg->default_groups[3] = &dev->t10_alua.alua_tg_pt_gps_group; | ||
2857 | dev_cg->default_groups[4] = &dev->dev_stat_grps.stat_group; | ||
2858 | dev_cg->default_groups[5] = NULL; | ||
2859 | /* | 2846 | /* |
2860 | * Add core/$HBA/$DEV/alua/default_tg_pt_gp | 2847 | * Add core/$HBA/$DEV/alua/default_tg_pt_gp |
2861 | */ | 2848 | */ |
2862 | tg_pt_gp = core_alua_allocate_tg_pt_gp(dev, "default_tg_pt_gp", 1); | 2849 | tg_pt_gp = core_alua_allocate_tg_pt_gp(dev, "default_tg_pt_gp", 1); |
2863 | if (!tg_pt_gp) | 2850 | if (!tg_pt_gp) |
2864 | goto out_free_dev_cg_default_groups; | 2851 | goto out_free_device; |
2865 | dev->t10_alua.default_tg_pt_gp = tg_pt_gp; | 2852 | dev->t10_alua.default_tg_pt_gp = tg_pt_gp; |
2866 | 2853 | ||
2867 | tg_pt_gp_cg = &dev->t10_alua.alua_tg_pt_gps_group; | ||
2868 | tg_pt_gp_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | ||
2869 | GFP_KERNEL); | ||
2870 | if (!tg_pt_gp_cg->default_groups) { | ||
2871 | pr_err("Unable to allocate tg_pt_gp_cg->" | ||
2872 | "default_groups\n"); | ||
2873 | goto out_free_tg_pt_gp; | ||
2874 | } | ||
2875 | |||
2876 | config_group_init_type_name(&tg_pt_gp->tg_pt_gp_group, | 2854 | config_group_init_type_name(&tg_pt_gp->tg_pt_gp_group, |
2877 | "default_tg_pt_gp", &target_core_alua_tg_pt_gp_cit); | 2855 | "default_tg_pt_gp", &target_core_alua_tg_pt_gp_cit); |
2878 | tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group; | 2856 | configfs_add_default_group(&tg_pt_gp->tg_pt_gp_group, |
2879 | tg_pt_gp_cg->default_groups[1] = NULL; | 2857 | &dev->t10_alua.alua_tg_pt_gps_group); |
2858 | |||
2880 | /* | 2859 | /* |
2881 | * Add core/$HBA/$DEV/statistics/ default groups | 2860 | * Add core/$HBA/$DEV/statistics/ default groups |
2882 | */ | 2861 | */ |
2883 | dev_stat_grp = &dev->dev_stat_grps.stat_group; | ||
2884 | dev_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 4, | ||
2885 | GFP_KERNEL); | ||
2886 | if (!dev_stat_grp->default_groups) { | ||
2887 | pr_err("Unable to allocate dev_stat_grp->default_groups\n"); | ||
2888 | goto out_free_tg_pt_gp_cg_default_groups; | ||
2889 | } | ||
2890 | target_stat_setup_dev_default_groups(dev); | 2862 | target_stat_setup_dev_default_groups(dev); |
2891 | 2863 | ||
2892 | mutex_unlock(&hba->hba_access_mutex); | 2864 | mutex_unlock(&hba->hba_access_mutex); |
2893 | return dev_cg; | 2865 | return &dev->dev_group; |
2894 | 2866 | ||
2895 | out_free_tg_pt_gp_cg_default_groups: | ||
2896 | kfree(tg_pt_gp_cg->default_groups); | ||
2897 | out_free_tg_pt_gp: | ||
2898 | core_alua_free_tg_pt_gp(tg_pt_gp); | ||
2899 | out_free_dev_cg_default_groups: | ||
2900 | kfree(dev_cg->default_groups); | ||
2901 | out_free_device: | 2867 | out_free_device: |
2902 | target_free_device(dev); | 2868 | target_free_device(dev); |
2903 | out_unlock: | 2869 | out_unlock: |
@@ -2913,40 +2879,22 @@ static void target_core_drop_subdev( | |||
2913 | struct se_device *dev = | 2879 | struct se_device *dev = |
2914 | container_of(dev_cg, struct se_device, dev_group); | 2880 | container_of(dev_cg, struct se_device, dev_group); |
2915 | struct se_hba *hba; | 2881 | struct se_hba *hba; |
2916 | struct config_item *df_item; | ||
2917 | struct config_group *tg_pt_gp_cg, *dev_stat_grp; | ||
2918 | int i; | ||
2919 | 2882 | ||
2920 | hba = item_to_hba(&dev->se_hba->hba_group.cg_item); | 2883 | hba = item_to_hba(&dev->se_hba->hba_group.cg_item); |
2921 | 2884 | ||
2922 | mutex_lock(&hba->hba_access_mutex); | 2885 | mutex_lock(&hba->hba_access_mutex); |
2923 | 2886 | ||
2924 | dev_stat_grp = &dev->dev_stat_grps.stat_group; | 2887 | configfs_remove_default_groups(&dev->dev_stat_grps.stat_group); |
2925 | for (i = 0; dev_stat_grp->default_groups[i]; i++) { | 2888 | configfs_remove_default_groups(&dev->t10_alua.alua_tg_pt_gps_group); |
2926 | df_item = &dev_stat_grp->default_groups[i]->cg_item; | ||
2927 | dev_stat_grp->default_groups[i] = NULL; | ||
2928 | config_item_put(df_item); | ||
2929 | } | ||
2930 | kfree(dev_stat_grp->default_groups); | ||
2931 | 2889 | ||
2932 | tg_pt_gp_cg = &dev->t10_alua.alua_tg_pt_gps_group; | ||
2933 | for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) { | ||
2934 | df_item = &tg_pt_gp_cg->default_groups[i]->cg_item; | ||
2935 | tg_pt_gp_cg->default_groups[i] = NULL; | ||
2936 | config_item_put(df_item); | ||
2937 | } | ||
2938 | kfree(tg_pt_gp_cg->default_groups); | ||
2939 | /* | 2890 | /* |
2940 | * core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp | 2891 | * core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp |
2941 | * directly from target_core_alua_tg_pt_gp_release(). | 2892 | * directly from target_core_alua_tg_pt_gp_release(). |
2942 | */ | 2893 | */ |
2943 | dev->t10_alua.default_tg_pt_gp = NULL; | 2894 | dev->t10_alua.default_tg_pt_gp = NULL; |
2944 | 2895 | ||
2945 | for (i = 0; dev_cg->default_groups[i]; i++) { | 2896 | configfs_remove_default_groups(dev_cg); |
2946 | df_item = &dev_cg->default_groups[i]->cg_item; | 2897 | |
2947 | dev_cg->default_groups[i] = NULL; | ||
2948 | config_item_put(df_item); | ||
2949 | } | ||
2950 | /* | 2898 | /* |
2951 | * se_dev is released from target_core_dev_item_ops->release() | 2899 | * se_dev is released from target_core_dev_item_ops->release() |
2952 | */ | 2900 | */ |
@@ -3141,8 +3089,6 @@ void target_setup_backend_cits(struct target_backend *tb) | |||
3141 | 3089 | ||
3142 | static int __init target_core_init_configfs(void) | 3090 | static int __init target_core_init_configfs(void) |
3143 | { | 3091 | { |
3144 | struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL; | ||
3145 | struct config_group *lu_gp_cg = NULL; | ||
3146 | struct configfs_subsystem *subsys = &target_core_fabrics; | 3092 | struct configfs_subsystem *subsys = &target_core_fabrics; |
3147 | struct t10_alua_lu_gp *lu_gp; | 3093 | struct t10_alua_lu_gp *lu_gp; |
3148 | int ret; | 3094 | int ret; |
@@ -3161,51 +3107,24 @@ static int __init target_core_init_configfs(void) | |||
3161 | * Create $CONFIGFS/target/core default group for HBA <-> Storage Object | 3107 | * Create $CONFIGFS/target/core default group for HBA <-> Storage Object |
3162 | * and ALUA Logical Unit Group and Target Port Group infrastructure. | 3108 | * and ALUA Logical Unit Group and Target Port Group infrastructure. |
3163 | */ | 3109 | */ |
3164 | target_cg = &subsys->su_group; | 3110 | config_group_init_type_name(&target_core_hbagroup, "core", |
3165 | target_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | 3111 | &target_core_cit); |
3166 | GFP_KERNEL); | 3112 | configfs_add_default_group(&target_core_hbagroup, &subsys->su_group); |
3167 | if (!target_cg->default_groups) { | ||
3168 | pr_err("Unable to allocate target_cg->default_groups\n"); | ||
3169 | ret = -ENOMEM; | ||
3170 | goto out_global; | ||
3171 | } | ||
3172 | 3113 | ||
3173 | config_group_init_type_name(&target_core_hbagroup, | ||
3174 | "core", &target_core_cit); | ||
3175 | target_cg->default_groups[0] = &target_core_hbagroup; | ||
3176 | target_cg->default_groups[1] = NULL; | ||
3177 | /* | 3114 | /* |
3178 | * Create ALUA infrastructure under /sys/kernel/config/target/core/alua/ | 3115 | * Create ALUA infrastructure under /sys/kernel/config/target/core/alua/ |
3179 | */ | 3116 | */ |
3180 | hba_cg = &target_core_hbagroup; | 3117 | config_group_init_type_name(&alua_group, "alua", &target_core_alua_cit); |
3181 | hba_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | 3118 | configfs_add_default_group(&alua_group, &target_core_hbagroup); |
3182 | GFP_KERNEL); | 3119 | |
3183 | if (!hba_cg->default_groups) { | ||
3184 | pr_err("Unable to allocate hba_cg->default_groups\n"); | ||
3185 | ret = -ENOMEM; | ||
3186 | goto out_global; | ||
3187 | } | ||
3188 | config_group_init_type_name(&alua_group, | ||
3189 | "alua", &target_core_alua_cit); | ||
3190 | hba_cg->default_groups[0] = &alua_group; | ||
3191 | hba_cg->default_groups[1] = NULL; | ||
3192 | /* | 3120 | /* |
3193 | * Add ALUA Logical Unit Group and Target Port Group ConfigFS | 3121 | * Add ALUA Logical Unit Group and Target Port Group ConfigFS |
3194 | * groups under /sys/kernel/config/target/core/alua/ | 3122 | * groups under /sys/kernel/config/target/core/alua/ |
3195 | */ | 3123 | */ |
3196 | alua_cg = &alua_group; | 3124 | config_group_init_type_name(&alua_lu_gps_group, "lu_gps", |
3197 | alua_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | 3125 | &target_core_alua_lu_gps_cit); |
3198 | GFP_KERNEL); | 3126 | configfs_add_default_group(&alua_lu_gps_group, &alua_group); |
3199 | if (!alua_cg->default_groups) { | ||
3200 | pr_err("Unable to allocate alua_cg->default_groups\n"); | ||
3201 | ret = -ENOMEM; | ||
3202 | goto out_global; | ||
3203 | } | ||
3204 | 3127 | ||
3205 | config_group_init_type_name(&alua_lu_gps_group, | ||
3206 | "lu_gps", &target_core_alua_lu_gps_cit); | ||
3207 | alua_cg->default_groups[0] = &alua_lu_gps_group; | ||
3208 | alua_cg->default_groups[1] = NULL; | ||
3209 | /* | 3128 | /* |
3210 | * Add core/alua/lu_gps/default_lu_gp | 3129 | * Add core/alua/lu_gps/default_lu_gp |
3211 | */ | 3130 | */ |
@@ -3215,20 +3134,12 @@ static int __init target_core_init_configfs(void) | |||
3215 | goto out_global; | 3134 | goto out_global; |
3216 | } | 3135 | } |
3217 | 3136 | ||
3218 | lu_gp_cg = &alua_lu_gps_group; | ||
3219 | lu_gp_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | ||
3220 | GFP_KERNEL); | ||
3221 | if (!lu_gp_cg->default_groups) { | ||
3222 | pr_err("Unable to allocate lu_gp_cg->default_groups\n"); | ||
3223 | ret = -ENOMEM; | ||
3224 | goto out_global; | ||
3225 | } | ||
3226 | |||
3227 | config_group_init_type_name(&lu_gp->lu_gp_group, "default_lu_gp", | 3137 | config_group_init_type_name(&lu_gp->lu_gp_group, "default_lu_gp", |
3228 | &target_core_alua_lu_gp_cit); | 3138 | &target_core_alua_lu_gp_cit); |
3229 | lu_gp_cg->default_groups[0] = &lu_gp->lu_gp_group; | 3139 | configfs_add_default_group(&lu_gp->lu_gp_group, &alua_lu_gps_group); |
3230 | lu_gp_cg->default_groups[1] = NULL; | 3140 | |
3231 | default_lu_gp = lu_gp; | 3141 | default_lu_gp = lu_gp; |
3142 | |||
3232 | /* | 3143 | /* |
3233 | * Register the target_core_mod subsystem with configfs. | 3144 | * Register the target_core_mod subsystem with configfs. |
3234 | */ | 3145 | */ |
@@ -3267,55 +3178,21 @@ out_global: | |||
3267 | core_alua_free_lu_gp(default_lu_gp); | 3178 | core_alua_free_lu_gp(default_lu_gp); |
3268 | default_lu_gp = NULL; | 3179 | default_lu_gp = NULL; |
3269 | } | 3180 | } |
3270 | if (lu_gp_cg) | ||
3271 | kfree(lu_gp_cg->default_groups); | ||
3272 | if (alua_cg) | ||
3273 | kfree(alua_cg->default_groups); | ||
3274 | if (hba_cg) | ||
3275 | kfree(hba_cg->default_groups); | ||
3276 | kfree(target_cg->default_groups); | ||
3277 | release_se_kmem_caches(); | 3181 | release_se_kmem_caches(); |
3278 | return ret; | 3182 | return ret; |
3279 | } | 3183 | } |
3280 | 3184 | ||
3281 | static void __exit target_core_exit_configfs(void) | 3185 | static void __exit target_core_exit_configfs(void) |
3282 | { | 3186 | { |
3283 | struct config_group *hba_cg, *alua_cg, *lu_gp_cg; | 3187 | configfs_remove_default_groups(&alua_lu_gps_group); |
3284 | struct config_item *item; | 3188 | configfs_remove_default_groups(&alua_group); |
3285 | int i; | 3189 | configfs_remove_default_groups(&target_core_hbagroup); |
3286 | 3190 | ||
3287 | lu_gp_cg = &alua_lu_gps_group; | ||
3288 | for (i = 0; lu_gp_cg->default_groups[i]; i++) { | ||
3289 | item = &lu_gp_cg->default_groups[i]->cg_item; | ||
3290 | lu_gp_cg->default_groups[i] = NULL; | ||
3291 | config_item_put(item); | ||
3292 | } | ||
3293 | kfree(lu_gp_cg->default_groups); | ||
3294 | lu_gp_cg->default_groups = NULL; | ||
3295 | |||
3296 | alua_cg = &alua_group; | ||
3297 | for (i = 0; alua_cg->default_groups[i]; i++) { | ||
3298 | item = &alua_cg->default_groups[i]->cg_item; | ||
3299 | alua_cg->default_groups[i] = NULL; | ||
3300 | config_item_put(item); | ||
3301 | } | ||
3302 | kfree(alua_cg->default_groups); | ||
3303 | alua_cg->default_groups = NULL; | ||
3304 | |||
3305 | hba_cg = &target_core_hbagroup; | ||
3306 | for (i = 0; hba_cg->default_groups[i]; i++) { | ||
3307 | item = &hba_cg->default_groups[i]->cg_item; | ||
3308 | hba_cg->default_groups[i] = NULL; | ||
3309 | config_item_put(item); | ||
3310 | } | ||
3311 | kfree(hba_cg->default_groups); | ||
3312 | hba_cg->default_groups = NULL; | ||
3313 | /* | 3191 | /* |
3314 | * We expect subsys->su_group.default_groups to be released | 3192 | * We expect subsys->su_group.default_groups to be released |
3315 | * by configfs subsystem provider logic.. | 3193 | * by configfs subsystem provider logic.. |
3316 | */ | 3194 | */ |
3317 | configfs_unregister_subsystem(&target_core_fabrics); | 3195 | configfs_unregister_subsystem(&target_core_fabrics); |
3318 | kfree(target_core_fabrics.su_group.default_groups); | ||
3319 | 3196 | ||
3320 | core_alua_free_lu_gp(default_lu_gp); | 3197 | core_alua_free_lu_gp(default_lu_gp); |
3321 | default_lu_gp = NULL; | 3198 | default_lu_gp = NULL; |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index f916d18ccb48..8caef31da415 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -273,18 +273,10 @@ static struct config_group *target_fabric_make_mappedlun( | |||
273 | struct se_portal_group *se_tpg = se_nacl->se_tpg; | 273 | struct se_portal_group *se_tpg = se_nacl->se_tpg; |
274 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; | 274 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
275 | struct se_lun_acl *lacl = NULL; | 275 | struct se_lun_acl *lacl = NULL; |
276 | struct config_item *acl_ci; | ||
277 | struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL; | ||
278 | char *buf; | 276 | char *buf; |
279 | unsigned long long mapped_lun; | 277 | unsigned long long mapped_lun; |
280 | int ret = 0; | 278 | int ret = 0; |
281 | 279 | ||
282 | acl_ci = &group->cg_item; | ||
283 | if (!acl_ci) { | ||
284 | pr_err("Unable to locatel acl_ci\n"); | ||
285 | return NULL; | ||
286 | } | ||
287 | |||
288 | buf = kzalloc(strlen(name) + 1, GFP_KERNEL); | 280 | buf = kzalloc(strlen(name) + 1, GFP_KERNEL); |
289 | if (!buf) { | 281 | if (!buf) { |
290 | pr_err("Unable to allocate memory for name buf\n"); | 282 | pr_err("Unable to allocate memory for name buf\n"); |
@@ -315,37 +307,19 @@ static struct config_group *target_fabric_make_mappedlun( | |||
315 | goto out; | 307 | goto out; |
316 | } | 308 | } |
317 | 309 | ||
318 | lacl_cg = &lacl->se_lun_group; | ||
319 | lacl_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | ||
320 | GFP_KERNEL); | ||
321 | if (!lacl_cg->default_groups) { | ||
322 | pr_err("Unable to allocate lacl_cg->default_groups\n"); | ||
323 | ret = -ENOMEM; | ||
324 | goto out; | ||
325 | } | ||
326 | |||
327 | config_group_init_type_name(&lacl->se_lun_group, name, | 310 | config_group_init_type_name(&lacl->se_lun_group, name, |
328 | &tf->tf_tpg_mappedlun_cit); | 311 | &tf->tf_tpg_mappedlun_cit); |
312 | |||
329 | config_group_init_type_name(&lacl->ml_stat_grps.stat_group, | 313 | config_group_init_type_name(&lacl->ml_stat_grps.stat_group, |
330 | "statistics", &tf->tf_tpg_mappedlun_stat_cit); | 314 | "statistics", &tf->tf_tpg_mappedlun_stat_cit); |
331 | lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group; | 315 | configfs_add_default_group(&lacl->ml_stat_grps.stat_group, |
332 | lacl_cg->default_groups[1] = NULL; | 316 | &lacl->se_lun_group); |
333 | 317 | ||
334 | ml_stat_grp = &lacl->ml_stat_grps.stat_group; | ||
335 | ml_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 3, | ||
336 | GFP_KERNEL); | ||
337 | if (!ml_stat_grp->default_groups) { | ||
338 | pr_err("Unable to allocate ml_stat_grp->default_groups\n"); | ||
339 | ret = -ENOMEM; | ||
340 | goto out; | ||
341 | } | ||
342 | target_stat_setup_mappedlun_default_groups(lacl); | 318 | target_stat_setup_mappedlun_default_groups(lacl); |
343 | 319 | ||
344 | kfree(buf); | 320 | kfree(buf); |
345 | return &lacl->se_lun_group; | 321 | return &lacl->se_lun_group; |
346 | out: | 322 | out: |
347 | if (lacl_cg) | ||
348 | kfree(lacl_cg->default_groups); | ||
349 | kfree(lacl); | 323 | kfree(lacl); |
350 | kfree(buf); | 324 | kfree(buf); |
351 | return ERR_PTR(ret); | 325 | return ERR_PTR(ret); |
@@ -357,25 +331,9 @@ static void target_fabric_drop_mappedlun( | |||
357 | { | 331 | { |
358 | struct se_lun_acl *lacl = container_of(to_config_group(item), | 332 | struct se_lun_acl *lacl = container_of(to_config_group(item), |
359 | struct se_lun_acl, se_lun_group); | 333 | struct se_lun_acl, se_lun_group); |
360 | struct config_item *df_item; | ||
361 | struct config_group *lacl_cg = NULL, *ml_stat_grp = NULL; | ||
362 | int i; | ||
363 | |||
364 | ml_stat_grp = &lacl->ml_stat_grps.stat_group; | ||
365 | for (i = 0; ml_stat_grp->default_groups[i]; i++) { | ||
366 | df_item = &ml_stat_grp->default_groups[i]->cg_item; | ||
367 | ml_stat_grp->default_groups[i] = NULL; | ||
368 | config_item_put(df_item); | ||
369 | } | ||
370 | kfree(ml_stat_grp->default_groups); | ||
371 | 334 | ||
372 | lacl_cg = &lacl->se_lun_group; | 335 | configfs_remove_default_groups(&lacl->ml_stat_grps.stat_group); |
373 | for (i = 0; lacl_cg->default_groups[i]; i++) { | 336 | configfs_remove_default_groups(&lacl->se_lun_group); |
374 | df_item = &lacl_cg->default_groups[i]->cg_item; | ||
375 | lacl_cg->default_groups[i] = NULL; | ||
376 | config_item_put(df_item); | ||
377 | } | ||
378 | kfree(lacl_cg->default_groups); | ||
379 | 337 | ||
380 | config_item_put(item); | 338 | config_item_put(item); |
381 | } | 339 | } |
@@ -424,7 +382,6 @@ static struct config_group *target_fabric_make_nodeacl( | |||
424 | struct se_portal_group, tpg_acl_group); | 382 | struct se_portal_group, tpg_acl_group); |
425 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; | 383 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
426 | struct se_node_acl *se_nacl; | 384 | struct se_node_acl *se_nacl; |
427 | struct config_group *nacl_cg; | ||
428 | 385 | ||
429 | se_nacl = core_tpg_add_initiator_node_acl(se_tpg, name); | 386 | se_nacl = core_tpg_add_initiator_node_acl(se_tpg, name); |
430 | if (IS_ERR(se_nacl)) | 387 | if (IS_ERR(se_nacl)) |
@@ -438,24 +395,28 @@ static struct config_group *target_fabric_make_nodeacl( | |||
438 | } | 395 | } |
439 | } | 396 | } |
440 | 397 | ||
441 | nacl_cg = &se_nacl->acl_group; | ||
442 | nacl_cg->default_groups = se_nacl->acl_default_groups; | ||
443 | nacl_cg->default_groups[0] = &se_nacl->acl_attrib_group; | ||
444 | nacl_cg->default_groups[1] = &se_nacl->acl_auth_group; | ||
445 | nacl_cg->default_groups[2] = &se_nacl->acl_param_group; | ||
446 | nacl_cg->default_groups[3] = &se_nacl->acl_fabric_stat_group; | ||
447 | nacl_cg->default_groups[4] = NULL; | ||
448 | |||
449 | config_group_init_type_name(&se_nacl->acl_group, name, | 398 | config_group_init_type_name(&se_nacl->acl_group, name, |
450 | &tf->tf_tpg_nacl_base_cit); | 399 | &tf->tf_tpg_nacl_base_cit); |
400 | |||
451 | config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib", | 401 | config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib", |
452 | &tf->tf_tpg_nacl_attrib_cit); | 402 | &tf->tf_tpg_nacl_attrib_cit); |
403 | configfs_add_default_group(&se_nacl->acl_attrib_group, | ||
404 | &se_nacl->acl_group); | ||
405 | |||
453 | config_group_init_type_name(&se_nacl->acl_auth_group, "auth", | 406 | config_group_init_type_name(&se_nacl->acl_auth_group, "auth", |
454 | &tf->tf_tpg_nacl_auth_cit); | 407 | &tf->tf_tpg_nacl_auth_cit); |
408 | configfs_add_default_group(&se_nacl->acl_auth_group, | ||
409 | &se_nacl->acl_group); | ||
410 | |||
455 | config_group_init_type_name(&se_nacl->acl_param_group, "param", | 411 | config_group_init_type_name(&se_nacl->acl_param_group, "param", |
456 | &tf->tf_tpg_nacl_param_cit); | 412 | &tf->tf_tpg_nacl_param_cit); |
413 | configfs_add_default_group(&se_nacl->acl_param_group, | ||
414 | &se_nacl->acl_group); | ||
415 | |||
457 | config_group_init_type_name(&se_nacl->acl_fabric_stat_group, | 416 | config_group_init_type_name(&se_nacl->acl_fabric_stat_group, |
458 | "fabric_statistics", &tf->tf_tpg_nacl_stat_cit); | 417 | "fabric_statistics", &tf->tf_tpg_nacl_stat_cit); |
418 | configfs_add_default_group(&se_nacl->acl_fabric_stat_group, | ||
419 | &se_nacl->acl_group); | ||
459 | 420 | ||
460 | return &se_nacl->acl_group; | 421 | return &se_nacl->acl_group; |
461 | } | 422 | } |
@@ -466,16 +427,9 @@ static void target_fabric_drop_nodeacl( | |||
466 | { | 427 | { |
467 | struct se_node_acl *se_nacl = container_of(to_config_group(item), | 428 | struct se_node_acl *se_nacl = container_of(to_config_group(item), |
468 | struct se_node_acl, acl_group); | 429 | struct se_node_acl, acl_group); |
469 | struct config_item *df_item; | 430 | |
470 | struct config_group *nacl_cg; | 431 | configfs_remove_default_groups(&se_nacl->acl_group); |
471 | int i; | 432 | |
472 | |||
473 | nacl_cg = &se_nacl->acl_group; | ||
474 | for (i = 0; nacl_cg->default_groups[i]; i++) { | ||
475 | df_item = &nacl_cg->default_groups[i]->cg_item; | ||
476 | nacl_cg->default_groups[i] = NULL; | ||
477 | config_item_put(df_item); | ||
478 | } | ||
479 | /* | 433 | /* |
480 | * struct se_node_acl free is done in target_fabric_nacl_base_release() | 434 | * struct se_node_acl free is done in target_fabric_nacl_base_release() |
481 | */ | 435 | */ |
@@ -795,7 +749,6 @@ static struct config_group *target_fabric_make_lun( | |||
795 | struct se_portal_group *se_tpg = container_of(group, | 749 | struct se_portal_group *se_tpg = container_of(group, |
796 | struct se_portal_group, tpg_lun_group); | 750 | struct se_portal_group, tpg_lun_group); |
797 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; | 751 | struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; |
798 | struct config_group *lun_cg = NULL, *port_stat_grp = NULL; | ||
799 | unsigned long long unpacked_lun; | 752 | unsigned long long unpacked_lun; |
800 | int errno; | 753 | int errno; |
801 | 754 | ||
@@ -812,31 +765,14 @@ static struct config_group *target_fabric_make_lun( | |||
812 | if (IS_ERR(lun)) | 765 | if (IS_ERR(lun)) |
813 | return ERR_CAST(lun); | 766 | return ERR_CAST(lun); |
814 | 767 | ||
815 | lun_cg = &lun->lun_group; | ||
816 | lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, | ||
817 | GFP_KERNEL); | ||
818 | if (!lun_cg->default_groups) { | ||
819 | pr_err("Unable to allocate lun_cg->default_groups\n"); | ||
820 | kfree(lun); | ||
821 | return ERR_PTR(-ENOMEM); | ||
822 | } | ||
823 | |||
824 | config_group_init_type_name(&lun->lun_group, name, | 768 | config_group_init_type_name(&lun->lun_group, name, |
825 | &tf->tf_tpg_port_cit); | 769 | &tf->tf_tpg_port_cit); |
770 | |||
826 | config_group_init_type_name(&lun->port_stat_grps.stat_group, | 771 | config_group_init_type_name(&lun->port_stat_grps.stat_group, |
827 | "statistics", &tf->tf_tpg_port_stat_cit); | 772 | "statistics", &tf->tf_tpg_port_stat_cit); |
828 | lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group; | 773 | configfs_add_default_group(&lun->port_stat_grps.stat_group, |
829 | lun_cg->default_groups[1] = NULL; | 774 | &lun->lun_group); |
830 | 775 | ||
831 | port_stat_grp = &lun->port_stat_grps.stat_group; | ||
832 | port_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 4, | ||
833 | GFP_KERNEL); | ||
834 | if (!port_stat_grp->default_groups) { | ||
835 | pr_err("Unable to allocate port_stat_grp->default_groups\n"); | ||
836 | kfree(lun_cg->default_groups); | ||
837 | kfree(lun); | ||
838 | return ERR_PTR(-ENOMEM); | ||
839 | } | ||
840 | target_stat_setup_port_default_groups(lun); | 776 | target_stat_setup_port_default_groups(lun); |
841 | 777 | ||
842 | return &lun->lun_group; | 778 | return &lun->lun_group; |
@@ -848,25 +784,9 @@ static void target_fabric_drop_lun( | |||
848 | { | 784 | { |
849 | struct se_lun *lun = container_of(to_config_group(item), | 785 | struct se_lun *lun = container_of(to_config_group(item), |
850 | struct se_lun, lun_group); | 786 | struct se_lun, lun_group); |
851 | struct config_item *df_item; | ||
852 | struct config_group *lun_cg, *port_stat_grp; | ||
853 | int i; | ||
854 | |||
855 | port_stat_grp = &lun->port_stat_grps.stat_group; | ||
856 | for (i = 0; port_stat_grp->default_groups[i]; i++) { | ||
857 | df_item = &port_stat_grp->default_groups[i]->cg_item; | ||
858 | port_stat_grp->default_groups[i] = NULL; | ||
859 | config_item_put(df_item); | ||
860 | } | ||
861 | kfree(port_stat_grp->default_groups); | ||
862 | 787 | ||
863 | lun_cg = &lun->lun_group; | 788 | configfs_remove_default_groups(&lun->port_stat_grps.stat_group); |
864 | for (i = 0; lun_cg->default_groups[i]; i++) { | 789 | configfs_remove_default_groups(&lun->lun_group); |
865 | df_item = &lun_cg->default_groups[i]->cg_item; | ||
866 | lun_cg->default_groups[i] = NULL; | ||
867 | config_item_put(df_item); | ||
868 | } | ||
869 | kfree(lun_cg->default_groups); | ||
870 | 790 | ||
871 | config_item_put(item); | 791 | config_item_put(item); |
872 | } | 792 | } |
@@ -922,32 +842,39 @@ static struct config_group *target_fabric_make_tpg( | |||
922 | se_tpg = tf->tf_ops->fabric_make_tpg(wwn, group, name); | 842 | se_tpg = tf->tf_ops->fabric_make_tpg(wwn, group, name); |
923 | if (!se_tpg || IS_ERR(se_tpg)) | 843 | if (!se_tpg || IS_ERR(se_tpg)) |
924 | return ERR_PTR(-EINVAL); | 844 | return ERR_PTR(-EINVAL); |
925 | /* | ||
926 | * Setup default groups from pre-allocated se_tpg->tpg_default_groups | ||
927 | */ | ||
928 | se_tpg->tpg_group.default_groups = se_tpg->tpg_default_groups; | ||
929 | se_tpg->tpg_group.default_groups[0] = &se_tpg->tpg_lun_group; | ||
930 | se_tpg->tpg_group.default_groups[1] = &se_tpg->tpg_np_group; | ||
931 | se_tpg->tpg_group.default_groups[2] = &se_tpg->tpg_acl_group; | ||
932 | se_tpg->tpg_group.default_groups[3] = &se_tpg->tpg_attrib_group; | ||
933 | se_tpg->tpg_group.default_groups[4] = &se_tpg->tpg_auth_group; | ||
934 | se_tpg->tpg_group.default_groups[5] = &se_tpg->tpg_param_group; | ||
935 | se_tpg->tpg_group.default_groups[6] = NULL; | ||
936 | 845 | ||
937 | config_group_init_type_name(&se_tpg->tpg_group, name, | 846 | config_group_init_type_name(&se_tpg->tpg_group, name, |
938 | &tf->tf_tpg_base_cit); | 847 | &tf->tf_tpg_base_cit); |
848 | |||
939 | config_group_init_type_name(&se_tpg->tpg_lun_group, "lun", | 849 | config_group_init_type_name(&se_tpg->tpg_lun_group, "lun", |
940 | &tf->tf_tpg_lun_cit); | 850 | &tf->tf_tpg_lun_cit); |
851 | configfs_add_default_group(&se_tpg->tpg_lun_group, | ||
852 | &se_tpg->tpg_group); | ||
853 | |||
941 | config_group_init_type_name(&se_tpg->tpg_np_group, "np", | 854 | config_group_init_type_name(&se_tpg->tpg_np_group, "np", |
942 | &tf->tf_tpg_np_cit); | 855 | &tf->tf_tpg_np_cit); |
856 | configfs_add_default_group(&se_tpg->tpg_np_group, | ||
857 | &se_tpg->tpg_group); | ||
858 | |||
943 | config_group_init_type_name(&se_tpg->tpg_acl_group, "acls", | 859 | config_group_init_type_name(&se_tpg->tpg_acl_group, "acls", |
944 | &tf->tf_tpg_nacl_cit); | 860 | &tf->tf_tpg_nacl_cit); |
861 | configfs_add_default_group(&se_tpg->tpg_acl_group, | ||
862 | &se_tpg->tpg_group); | ||
863 | |||
945 | config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", | 864 | config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", |
946 | &tf->tf_tpg_attrib_cit); | 865 | &tf->tf_tpg_attrib_cit); |
866 | configfs_add_default_group(&se_tpg->tpg_attrib_group, | ||
867 | &se_tpg->tpg_group); | ||
868 | |||
947 | config_group_init_type_name(&se_tpg->tpg_auth_group, "auth", | 869 | config_group_init_type_name(&se_tpg->tpg_auth_group, "auth", |
948 | &tf->tf_tpg_auth_cit); | 870 | &tf->tf_tpg_auth_cit); |
871 | configfs_add_default_group(&se_tpg->tpg_auth_group, | ||
872 | &se_tpg->tpg_group); | ||
873 | |||
949 | config_group_init_type_name(&se_tpg->tpg_param_group, "param", | 874 | config_group_init_type_name(&se_tpg->tpg_param_group, "param", |
950 | &tf->tf_tpg_param_cit); | 875 | &tf->tf_tpg_param_cit); |
876 | configfs_add_default_group(&se_tpg->tpg_param_group, | ||
877 | &se_tpg->tpg_group); | ||
951 | 878 | ||
952 | return &se_tpg->tpg_group; | 879 | return &se_tpg->tpg_group; |
953 | } | 880 | } |
@@ -958,19 +885,8 @@ static void target_fabric_drop_tpg( | |||
958 | { | 885 | { |
959 | struct se_portal_group *se_tpg = container_of(to_config_group(item), | 886 | struct se_portal_group *se_tpg = container_of(to_config_group(item), |
960 | struct se_portal_group, tpg_group); | 887 | struct se_portal_group, tpg_group); |
961 | struct config_group *tpg_cg = &se_tpg->tpg_group; | ||
962 | struct config_item *df_item; | ||
963 | int i; | ||
964 | /* | ||
965 | * Release default groups, but do not release tpg_cg->default_groups | ||
966 | * memory as it is statically allocated at se_tpg->tpg_default_groups. | ||
967 | */ | ||
968 | for (i = 0; tpg_cg->default_groups[i]; i++) { | ||
969 | df_item = &tpg_cg->default_groups[i]->cg_item; | ||
970 | tpg_cg->default_groups[i] = NULL; | ||
971 | config_item_put(df_item); | ||
972 | } | ||
973 | 888 | ||
889 | configfs_remove_default_groups(&se_tpg->tpg_group); | ||
974 | config_item_put(item); | 890 | config_item_put(item); |
975 | } | 891 | } |
976 | 892 | ||
@@ -1026,16 +942,12 @@ static struct config_group *target_fabric_make_wwn( | |||
1026 | return ERR_PTR(-EINVAL); | 942 | return ERR_PTR(-EINVAL); |
1027 | 943 | ||
1028 | wwn->wwn_tf = tf; | 944 | wwn->wwn_tf = tf; |
1029 | /* | ||
1030 | * Setup default groups from pre-allocated wwn->wwn_default_groups | ||
1031 | */ | ||
1032 | wwn->wwn_group.default_groups = wwn->wwn_default_groups; | ||
1033 | wwn->wwn_group.default_groups[0] = &wwn->fabric_stat_group; | ||
1034 | wwn->wwn_group.default_groups[1] = NULL; | ||
1035 | 945 | ||
1036 | config_group_init_type_name(&wwn->wwn_group, name, &tf->tf_tpg_cit); | 946 | config_group_init_type_name(&wwn->wwn_group, name, &tf->tf_tpg_cit); |
947 | |||
1037 | config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics", | 948 | config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics", |
1038 | &tf->tf_wwn_fabric_stats_cit); | 949 | &tf->tf_wwn_fabric_stats_cit); |
950 | configfs_add_default_group(&wwn->fabric_stat_group, &wwn->wwn_group); | ||
1039 | 951 | ||
1040 | return &wwn->wwn_group; | 952 | return &wwn->wwn_group; |
1041 | } | 953 | } |
@@ -1046,16 +958,8 @@ static void target_fabric_drop_wwn( | |||
1046 | { | 958 | { |
1047 | struct se_wwn *wwn = container_of(to_config_group(item), | 959 | struct se_wwn *wwn = container_of(to_config_group(item), |
1048 | struct se_wwn, wwn_group); | 960 | struct se_wwn, wwn_group); |
1049 | struct config_item *df_item; | ||
1050 | struct config_group *cg = &wwn->wwn_group; | ||
1051 | int i; | ||
1052 | |||
1053 | for (i = 0; cg->default_groups[i]; i++) { | ||
1054 | df_item = &cg->default_groups[i]->cg_item; | ||
1055 | cg->default_groups[i] = NULL; | ||
1056 | config_item_put(df_item); | ||
1057 | } | ||
1058 | 961 | ||
962 | configfs_remove_default_groups(&wwn->wwn_group); | ||
1059 | config_item_put(item); | 963 | config_item_put(item); |
1060 | } | 964 | } |
1061 | 965 | ||
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index db4412fe6b8a..4a7cf499cdfa 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h | |||
@@ -22,7 +22,6 @@ struct target_fabric_configfs { | |||
22 | struct list_head tf_list; | 22 | struct list_head tf_list; |
23 | struct config_group tf_group; | 23 | struct config_group tf_group; |
24 | struct config_group tf_disc_group; | 24 | struct config_group tf_disc_group; |
25 | struct config_group *tf_default_groups[2]; | ||
26 | const struct target_core_fabric_ops *tf_ops; | 25 | const struct target_core_fabric_ops *tf_ops; |
27 | 26 | ||
28 | struct config_item_type tf_discovery_cit; | 27 | struct config_item_type tf_discovery_cit; |
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 81a6b3e07687..1a39033d2bff 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -407,19 +407,20 @@ static struct config_item_type target_stat_scsi_lu_cit = { | |||
407 | */ | 407 | */ |
408 | void target_stat_setup_dev_default_groups(struct se_device *dev) | 408 | void target_stat_setup_dev_default_groups(struct se_device *dev) |
409 | { | 409 | { |
410 | struct config_group *dev_stat_grp = &dev->dev_stat_grps.stat_group; | ||
411 | |||
412 | config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group, | 410 | config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group, |
413 | "scsi_dev", &target_stat_scsi_dev_cit); | 411 | "scsi_dev", &target_stat_scsi_dev_cit); |
412 | configfs_add_default_group(&dev->dev_stat_grps.scsi_dev_group, | ||
413 | &dev->dev_stat_grps.stat_group); | ||
414 | |||
414 | config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group, | 415 | config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group, |
415 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); | 416 | "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit); |
417 | configfs_add_default_group(&dev->dev_stat_grps.scsi_tgt_dev_group, | ||
418 | &dev->dev_stat_grps.stat_group); | ||
419 | |||
416 | config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group, | 420 | config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group, |
417 | "scsi_lu", &target_stat_scsi_lu_cit); | 421 | "scsi_lu", &target_stat_scsi_lu_cit); |
418 | 422 | configfs_add_default_group(&dev->dev_stat_grps.scsi_lu_group, | |
419 | dev_stat_grp->default_groups[0] = &dev->dev_stat_grps.scsi_dev_group; | 423 | &dev->dev_stat_grps.stat_group); |
420 | dev_stat_grp->default_groups[1] = &dev->dev_stat_grps.scsi_tgt_dev_group; | ||
421 | dev_stat_grp->default_groups[2] = &dev->dev_stat_grps.scsi_lu_group; | ||
422 | dev_stat_grp->default_groups[3] = NULL; | ||
423 | } | 424 | } |
424 | 425 | ||
425 | /* | 426 | /* |
@@ -818,19 +819,20 @@ static struct config_item_type target_stat_scsi_transport_cit = { | |||
818 | */ | 819 | */ |
819 | void target_stat_setup_port_default_groups(struct se_lun *lun) | 820 | void target_stat_setup_port_default_groups(struct se_lun *lun) |
820 | { | 821 | { |
821 | struct config_group *port_stat_grp = &lun->port_stat_grps.stat_group; | ||
822 | |||
823 | config_group_init_type_name(&lun->port_stat_grps.scsi_port_group, | 822 | config_group_init_type_name(&lun->port_stat_grps.scsi_port_group, |
824 | "scsi_port", &target_stat_scsi_port_cit); | 823 | "scsi_port", &target_stat_scsi_port_cit); |
824 | configfs_add_default_group(&lun->port_stat_grps.scsi_port_group, | ||
825 | &lun->port_stat_grps.stat_group); | ||
826 | |||
825 | config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group, | 827 | config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group, |
826 | "scsi_tgt_port", &target_stat_scsi_tgt_port_cit); | 828 | "scsi_tgt_port", &target_stat_scsi_tgt_port_cit); |
829 | configfs_add_default_group(&lun->port_stat_grps.scsi_tgt_port_group, | ||
830 | &lun->port_stat_grps.stat_group); | ||
831 | |||
827 | config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group, | 832 | config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group, |
828 | "scsi_transport", &target_stat_scsi_transport_cit); | 833 | "scsi_transport", &target_stat_scsi_transport_cit); |
829 | 834 | configfs_add_default_group(&lun->port_stat_grps.scsi_transport_group, | |
830 | port_stat_grp->default_groups[0] = &lun->port_stat_grps.scsi_port_group; | 835 | &lun->port_stat_grps.stat_group); |
831 | port_stat_grp->default_groups[1] = &lun->port_stat_grps.scsi_tgt_port_group; | ||
832 | port_stat_grp->default_groups[2] = &lun->port_stat_grps.scsi_transport_group; | ||
833 | port_stat_grp->default_groups[3] = NULL; | ||
834 | } | 836 | } |
835 | 837 | ||
836 | /* | 838 | /* |
@@ -1351,14 +1353,13 @@ static struct config_item_type target_stat_scsi_att_intr_port_cit = { | |||
1351 | */ | 1353 | */ |
1352 | void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl) | 1354 | void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl) |
1353 | { | 1355 | { |
1354 | struct config_group *ml_stat_grp = &lacl->ml_stat_grps.stat_group; | ||
1355 | |||
1356 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group, | 1356 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group, |
1357 | "scsi_auth_intr", &target_stat_scsi_auth_intr_cit); | 1357 | "scsi_auth_intr", &target_stat_scsi_auth_intr_cit); |
1358 | configfs_add_default_group(&lacl->ml_stat_grps.scsi_auth_intr_group, | ||
1359 | &lacl->ml_stat_grps.stat_group); | ||
1360 | |||
1358 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group, | 1361 | config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group, |
1359 | "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit); | 1362 | "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit); |
1360 | 1363 | configfs_add_default_group(&lacl->ml_stat_grps.scsi_att_intr_port_group, | |
1361 | ml_stat_grp->default_groups[0] = &lacl->ml_stat_grps.scsi_auth_intr_group; | 1364 | &lacl->ml_stat_grps.stat_group); |
1362 | ml_stat_grp->default_groups[1] = &lacl->ml_stat_grps.scsi_att_intr_port_group; | ||
1363 | ml_stat_grp->default_groups[2] = NULL; | ||
1364 | } | 1365 | } |
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 590c44989e5e..2f8081f0f795 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c | |||
@@ -49,7 +49,6 @@ struct gadget_info { | |||
49 | struct config_group configs_group; | 49 | struct config_group configs_group; |
50 | struct config_group strings_group; | 50 | struct config_group strings_group; |
51 | struct config_group os_desc_group; | 51 | struct config_group os_desc_group; |
52 | struct config_group *default_groups[5]; | ||
53 | 52 | ||
54 | struct mutex lock; | 53 | struct mutex lock; |
55 | struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1]; | 54 | struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1]; |
@@ -71,7 +70,6 @@ static inline struct gadget_info *to_gadget_info(struct config_item *item) | |||
71 | struct config_usb_cfg { | 70 | struct config_usb_cfg { |
72 | struct config_group group; | 71 | struct config_group group; |
73 | struct config_group strings_group; | 72 | struct config_group strings_group; |
74 | struct config_group *default_groups[2]; | ||
75 | struct list_head string_list; | 73 | struct list_head string_list; |
76 | struct usb_configuration c; | 74 | struct usb_configuration c; |
77 | struct list_head func_list; | 75 | struct list_head func_list; |
@@ -666,13 +664,12 @@ static struct config_group *config_desc_make( | |||
666 | INIT_LIST_HEAD(&cfg->string_list); | 664 | INIT_LIST_HEAD(&cfg->string_list); |
667 | INIT_LIST_HEAD(&cfg->func_list); | 665 | INIT_LIST_HEAD(&cfg->func_list); |
668 | 666 | ||
669 | cfg->group.default_groups = cfg->default_groups; | ||
670 | cfg->default_groups[0] = &cfg->strings_group; | ||
671 | |||
672 | config_group_init_type_name(&cfg->group, name, | 667 | config_group_init_type_name(&cfg->group, name, |
673 | &gadget_config_type); | 668 | &gadget_config_type); |
669 | |||
674 | config_group_init_type_name(&cfg->strings_group, "strings", | 670 | config_group_init_type_name(&cfg->strings_group, "strings", |
675 | &gadget_config_name_strings_type); | 671 | &gadget_config_name_strings_type); |
672 | configfs_add_default_group(&cfg->strings_group, &cfg->group); | ||
676 | 673 | ||
677 | ret = usb_add_config_only(&gi->cdev, &cfg->c); | 674 | ret = usb_add_config_only(&gi->cdev, &cfg->c); |
678 | if (ret) | 675 | if (ret) |
@@ -1149,15 +1146,11 @@ int usb_os_desc_prepare_interf_dir(struct config_group *parent, | |||
1149 | char **names, | 1146 | char **names, |
1150 | struct module *owner) | 1147 | struct module *owner) |
1151 | { | 1148 | { |
1152 | struct config_group **f_default_groups, *os_desc_group, | 1149 | struct config_group *os_desc_group; |
1153 | **interface_groups; | ||
1154 | struct config_item_type *os_desc_type, *interface_type; | 1150 | struct config_item_type *os_desc_type, *interface_type; |
1155 | 1151 | ||
1156 | vla_group(data_chunk); | 1152 | vla_group(data_chunk); |
1157 | vla_item(data_chunk, struct config_group *, f_default_groups, 2); | ||
1158 | vla_item(data_chunk, struct config_group, os_desc_group, 1); | 1153 | vla_item(data_chunk, struct config_group, os_desc_group, 1); |
1159 | vla_item(data_chunk, struct config_group *, interface_groups, | ||
1160 | n_interf + 1); | ||
1161 | vla_item(data_chunk, struct config_item_type, os_desc_type, 1); | 1154 | vla_item(data_chunk, struct config_item_type, os_desc_type, 1); |
1162 | vla_item(data_chunk, struct config_item_type, interface_type, 1); | 1155 | vla_item(data_chunk, struct config_item_type, interface_type, 1); |
1163 | 1156 | ||
@@ -1165,18 +1158,14 @@ int usb_os_desc_prepare_interf_dir(struct config_group *parent, | |||
1165 | if (!vlabuf) | 1158 | if (!vlabuf) |
1166 | return -ENOMEM; | 1159 | return -ENOMEM; |
1167 | 1160 | ||
1168 | f_default_groups = vla_ptr(vlabuf, data_chunk, f_default_groups); | ||
1169 | os_desc_group = vla_ptr(vlabuf, data_chunk, os_desc_group); | 1161 | os_desc_group = vla_ptr(vlabuf, data_chunk, os_desc_group); |
1170 | os_desc_type = vla_ptr(vlabuf, data_chunk, os_desc_type); | 1162 | os_desc_type = vla_ptr(vlabuf, data_chunk, os_desc_type); |
1171 | interface_groups = vla_ptr(vlabuf, data_chunk, interface_groups); | ||
1172 | interface_type = vla_ptr(vlabuf, data_chunk, interface_type); | 1163 | interface_type = vla_ptr(vlabuf, data_chunk, interface_type); |
1173 | 1164 | ||
1174 | parent->default_groups = f_default_groups; | ||
1175 | os_desc_type->ct_owner = owner; | 1165 | os_desc_type->ct_owner = owner; |
1176 | config_group_init_type_name(os_desc_group, "os_desc", os_desc_type); | 1166 | config_group_init_type_name(os_desc_group, "os_desc", os_desc_type); |
1177 | f_default_groups[0] = os_desc_group; | 1167 | configfs_add_default_group(os_desc_group, parent); |
1178 | 1168 | ||
1179 | os_desc_group->default_groups = interface_groups; | ||
1180 | interface_type->ct_group_ops = &interf_grp_ops; | 1169 | interface_type->ct_group_ops = &interf_grp_ops; |
1181 | interface_type->ct_attrs = interf_grp_attrs; | 1170 | interface_type->ct_attrs = interf_grp_attrs; |
1182 | interface_type->ct_owner = owner; | 1171 | interface_type->ct_owner = owner; |
@@ -1189,7 +1178,7 @@ int usb_os_desc_prepare_interf_dir(struct config_group *parent, | |||
1189 | config_group_init_type_name(&d->group, "", interface_type); | 1178 | config_group_init_type_name(&d->group, "", interface_type); |
1190 | config_item_set_name(&d->group.cg_item, "interface.%s", | 1179 | config_item_set_name(&d->group.cg_item, "interface.%s", |
1191 | names[n_interf]); | 1180 | names[n_interf]); |
1192 | interface_groups[n_interf] = &d->group; | 1181 | configfs_add_default_group(&d->group, os_desc_group); |
1193 | } | 1182 | } |
1194 | 1183 | ||
1195 | return 0; | 1184 | return 0; |
@@ -1423,20 +1412,23 @@ static struct config_group *gadgets_make( | |||
1423 | if (!gi) | 1412 | if (!gi) |
1424 | return ERR_PTR(-ENOMEM); | 1413 | return ERR_PTR(-ENOMEM); |
1425 | 1414 | ||
1426 | gi->group.default_groups = gi->default_groups; | 1415 | config_group_init_type_name(&gi->group, name, &gadget_root_type); |
1427 | gi->group.default_groups[0] = &gi->functions_group; | ||
1428 | gi->group.default_groups[1] = &gi->configs_group; | ||
1429 | gi->group.default_groups[2] = &gi->strings_group; | ||
1430 | gi->group.default_groups[3] = &gi->os_desc_group; | ||
1431 | 1416 | ||
1432 | config_group_init_type_name(&gi->functions_group, "functions", | 1417 | config_group_init_type_name(&gi->functions_group, "functions", |
1433 | &functions_type); | 1418 | &functions_type); |
1419 | configfs_add_default_group(&gi->functions_group, &gi->group); | ||
1420 | |||
1434 | config_group_init_type_name(&gi->configs_group, "configs", | 1421 | config_group_init_type_name(&gi->configs_group, "configs", |
1435 | &config_desc_type); | 1422 | &config_desc_type); |
1423 | configfs_add_default_group(&gi->configs_group, &gi->group); | ||
1424 | |||
1436 | config_group_init_type_name(&gi->strings_group, "strings", | 1425 | config_group_init_type_name(&gi->strings_group, "strings", |
1437 | &gadget_strings_strings_type); | 1426 | &gadget_strings_strings_type); |
1427 | configfs_add_default_group(&gi->strings_group, &gi->group); | ||
1428 | |||
1438 | config_group_init_type_name(&gi->os_desc_group, "os_desc", | 1429 | config_group_init_type_name(&gi->os_desc_group, "os_desc", |
1439 | &os_desc_type); | 1430 | &os_desc_type); |
1431 | configfs_add_default_group(&gi->os_desc_group, &gi->group); | ||
1440 | 1432 | ||
1441 | gi->composite.bind = configfs_do_nothing; | 1433 | gi->composite.bind = configfs_do_nothing; |
1442 | gi->composite.unbind = configfs_do_nothing; | 1434 | gi->composite.unbind = configfs_do_nothing; |
@@ -1461,8 +1453,6 @@ static struct config_group *gadgets_make( | |||
1461 | if (!gi->composite.gadget_driver.function) | 1453 | if (!gi->composite.gadget_driver.function) |
1462 | goto err; | 1454 | goto err; |
1463 | 1455 | ||
1464 | config_group_init_type_name(&gi->group, name, | ||
1465 | &gadget_root_type); | ||
1466 | return &gi->group; | 1456 | return &gi->group; |
1467 | err: | 1457 | err: |
1468 | kfree(gi); | 1458 | kfree(gi); |
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 223ccf89d226..142bb7763f2a 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c | |||
@@ -3484,12 +3484,12 @@ static struct usb_function_instance *fsg_alloc_inst(void) | |||
3484 | 3484 | ||
3485 | opts->lun0.lun = opts->common->luns[0]; | 3485 | opts->lun0.lun = opts->common->luns[0]; |
3486 | opts->lun0.lun_id = 0; | 3486 | opts->lun0.lun_id = 0; |
3487 | config_group_init_type_name(&opts->lun0.group, "lun.0", &fsg_lun_type); | ||
3488 | opts->default_groups[0] = &opts->lun0.group; | ||
3489 | opts->func_inst.group.default_groups = opts->default_groups; | ||
3490 | 3487 | ||
3491 | config_group_init_type_name(&opts->func_inst.group, "", &fsg_func_type); | 3488 | config_group_init_type_name(&opts->func_inst.group, "", &fsg_func_type); |
3492 | 3489 | ||
3490 | config_group_init_type_name(&opts->lun0.group, "lun.0", &fsg_lun_type); | ||
3491 | configfs_add_default_group(&opts->lun0.group, &opts->func_inst.group); | ||
3492 | |||
3493 | return &opts->func_inst; | 3493 | return &opts->func_inst; |
3494 | 3494 | ||
3495 | release_buffers: | 3495 | release_buffers: |
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index e587767e374c..f577eec88f8c 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c | |||
@@ -889,7 +889,6 @@ static void rndis_free_inst(struct usb_function_instance *f) | |||
889 | free_netdev(opts->net); | 889 | free_netdev(opts->net); |
890 | } | 890 | } |
891 | 891 | ||
892 | kfree(opts->rndis_os_desc.group.default_groups); /* single VLA chunk */ | ||
893 | kfree(opts); | 892 | kfree(opts); |
894 | } | 893 | } |
895 | 894 | ||
@@ -916,10 +915,10 @@ static struct usb_function_instance *rndis_alloc_inst(void) | |||
916 | 915 | ||
917 | descs[0] = &opts->rndis_os_desc; | 916 | descs[0] = &opts->rndis_os_desc; |
918 | names[0] = "rndis"; | 917 | names[0] = "rndis"; |
919 | usb_os_desc_prepare_interf_dir(&opts->func_inst.group, 1, descs, | ||
920 | names, THIS_MODULE); | ||
921 | config_group_init_type_name(&opts->func_inst.group, "", | 918 | config_group_init_type_name(&opts->func_inst.group, "", |
922 | &rndis_func_type); | 919 | &rndis_func_type); |
920 | usb_os_desc_prepare_interf_dir(&opts->func_inst.group, 1, descs, | ||
921 | names, THIS_MODULE); | ||
923 | 922 | ||
924 | return &opts->func_inst; | 923 | return &opts->func_inst; |
925 | } | 924 | } |
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index ad8c9b05572d..66753ba7a42e 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c | |||
@@ -272,11 +272,6 @@ static struct config_item_type uvcg_default_processing_type = { | |||
272 | 272 | ||
273 | /* struct uvcg_processing {}; */ | 273 | /* struct uvcg_processing {}; */ |
274 | 274 | ||
275 | static struct config_group *uvcg_processing_default_groups[] = { | ||
276 | &uvcg_default_processing.group, | ||
277 | NULL, | ||
278 | }; | ||
279 | |||
280 | /* control/processing */ | 275 | /* control/processing */ |
281 | static struct uvcg_processing_grp { | 276 | static struct uvcg_processing_grp { |
282 | struct config_group group; | 277 | struct config_group group; |
@@ -394,11 +389,6 @@ static struct config_item_type uvcg_default_camera_type = { | |||
394 | 389 | ||
395 | /* struct uvcg_camera {}; */ | 390 | /* struct uvcg_camera {}; */ |
396 | 391 | ||
397 | static struct config_group *uvcg_camera_default_groups[] = { | ||
398 | &uvcg_default_camera.group, | ||
399 | NULL, | ||
400 | }; | ||
401 | |||
402 | /* control/terminal/camera */ | 392 | /* control/terminal/camera */ |
403 | static struct uvcg_camera_grp { | 393 | static struct uvcg_camera_grp { |
404 | struct config_group group; | 394 | struct config_group group; |
@@ -477,11 +467,6 @@ static struct config_item_type uvcg_default_output_type = { | |||
477 | 467 | ||
478 | /* struct uvcg_output {}; */ | 468 | /* struct uvcg_output {}; */ |
479 | 469 | ||
480 | static struct config_group *uvcg_output_default_groups[] = { | ||
481 | &uvcg_default_output.group, | ||
482 | NULL, | ||
483 | }; | ||
484 | |||
485 | /* control/terminal/output */ | 470 | /* control/terminal/output */ |
486 | static struct uvcg_output_grp { | 471 | static struct uvcg_output_grp { |
487 | struct config_group group; | 472 | struct config_group group; |
@@ -491,12 +476,6 @@ static struct config_item_type uvcg_output_grp_type = { | |||
491 | .ct_owner = THIS_MODULE, | 476 | .ct_owner = THIS_MODULE, |
492 | }; | 477 | }; |
493 | 478 | ||
494 | static struct config_group *uvcg_terminal_default_groups[] = { | ||
495 | &uvcg_camera_grp.group, | ||
496 | &uvcg_output_grp.group, | ||
497 | NULL, | ||
498 | }; | ||
499 | |||
500 | /* control/terminal */ | 479 | /* control/terminal */ |
501 | static struct uvcg_terminal_grp { | 480 | static struct uvcg_terminal_grp { |
502 | struct config_group group; | 481 | struct config_group group; |
@@ -619,12 +598,6 @@ static struct config_item_type uvcg_control_class_type = { | |||
619 | .ct_owner = THIS_MODULE, | 598 | .ct_owner = THIS_MODULE, |
620 | }; | 599 | }; |
621 | 600 | ||
622 | static struct config_group *uvcg_control_class_default_groups[] = { | ||
623 | &uvcg_control_class_fs.group, | ||
624 | &uvcg_control_class_ss.group, | ||
625 | NULL, | ||
626 | }; | ||
627 | |||
628 | /* control/class */ | 601 | /* control/class */ |
629 | static struct uvcg_control_class_grp { | 602 | static struct uvcg_control_class_grp { |
630 | struct config_group group; | 603 | struct config_group group; |
@@ -634,14 +607,6 @@ static struct config_item_type uvcg_control_class_grp_type = { | |||
634 | .ct_owner = THIS_MODULE, | 607 | .ct_owner = THIS_MODULE, |
635 | }; | 608 | }; |
636 | 609 | ||
637 | static struct config_group *uvcg_control_default_groups[] = { | ||
638 | &uvcg_control_header_grp.group, | ||
639 | &uvcg_processing_grp.group, | ||
640 | &uvcg_terminal_grp.group, | ||
641 | &uvcg_control_class_grp.group, | ||
642 | NULL, | ||
643 | }; | ||
644 | |||
645 | /* control */ | 610 | /* control */ |
646 | static struct uvcg_control_grp { | 611 | static struct uvcg_control_grp { |
647 | struct config_group group; | 612 | struct config_group group; |
@@ -1780,11 +1745,6 @@ static struct config_item_type uvcg_default_color_matching_type = { | |||
1780 | 1745 | ||
1781 | /* struct uvcg_color_matching {}; */ | 1746 | /* struct uvcg_color_matching {}; */ |
1782 | 1747 | ||
1783 | static struct config_group *uvcg_color_matching_default_groups[] = { | ||
1784 | &uvcg_default_color_matching.group, | ||
1785 | NULL, | ||
1786 | }; | ||
1787 | |||
1788 | /* streaming/color_matching */ | 1748 | /* streaming/color_matching */ |
1789 | static struct uvcg_color_matching_grp { | 1749 | static struct uvcg_color_matching_grp { |
1790 | struct config_group group; | 1750 | struct config_group group; |
@@ -2145,13 +2105,6 @@ static struct config_item_type uvcg_streaming_class_type = { | |||
2145 | .ct_owner = THIS_MODULE, | 2105 | .ct_owner = THIS_MODULE, |
2146 | }; | 2106 | }; |
2147 | 2107 | ||
2148 | static struct config_group *uvcg_streaming_class_default_groups[] = { | ||
2149 | &uvcg_streaming_class_fs.group, | ||
2150 | &uvcg_streaming_class_hs.group, | ||
2151 | &uvcg_streaming_class_ss.group, | ||
2152 | NULL, | ||
2153 | }; | ||
2154 | |||
2155 | /* streaming/class */ | 2108 | /* streaming/class */ |
2156 | static struct uvcg_streaming_class_grp { | 2109 | static struct uvcg_streaming_class_grp { |
2157 | struct config_group group; | 2110 | struct config_group group; |
@@ -2161,15 +2114,6 @@ static struct config_item_type uvcg_streaming_class_grp_type = { | |||
2161 | .ct_owner = THIS_MODULE, | 2114 | .ct_owner = THIS_MODULE, |
2162 | }; | 2115 | }; |
2163 | 2116 | ||
2164 | static struct config_group *uvcg_streaming_default_groups[] = { | ||
2165 | &uvcg_streaming_header_grp.group, | ||
2166 | &uvcg_uncompressed_grp.group, | ||
2167 | &uvcg_mjpeg_grp.group, | ||
2168 | &uvcg_color_matching_grp.group, | ||
2169 | &uvcg_streaming_class_grp.group, | ||
2170 | NULL, | ||
2171 | }; | ||
2172 | |||
2173 | /* streaming */ | 2117 | /* streaming */ |
2174 | static struct uvcg_streaming_grp { | 2118 | static struct uvcg_streaming_grp { |
2175 | struct config_group group; | 2119 | struct config_group group; |
@@ -2179,12 +2123,6 @@ static struct config_item_type uvcg_streaming_grp_type = { | |||
2179 | .ct_owner = THIS_MODULE, | 2123 | .ct_owner = THIS_MODULE, |
2180 | }; | 2124 | }; |
2181 | 2125 | ||
2182 | static struct config_group *uvcg_default_groups[] = { | ||
2183 | &uvcg_control_grp.group, | ||
2184 | &uvcg_streaming_grp.group, | ||
2185 | NULL, | ||
2186 | }; | ||
2187 | |||
2188 | static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item) | 2126 | static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item) |
2189 | { | 2127 | { |
2190 | return container_of(to_config_group(item), struct f_uvc_opts, | 2128 | return container_of(to_config_group(item), struct f_uvc_opts, |
@@ -2273,59 +2211,64 @@ static struct config_item_type uvc_func_type = { | |||
2273 | .ct_owner = THIS_MODULE, | 2211 | .ct_owner = THIS_MODULE, |
2274 | }; | 2212 | }; |
2275 | 2213 | ||
2276 | static inline void uvcg_init_group(struct config_group *g, | ||
2277 | struct config_group **default_groups, | ||
2278 | const char *name, | ||
2279 | struct config_item_type *type) | ||
2280 | { | ||
2281 | g->default_groups = default_groups; | ||
2282 | config_group_init_type_name(g, name, type); | ||
2283 | } | ||
2284 | |||
2285 | int uvcg_attach_configfs(struct f_uvc_opts *opts) | 2214 | int uvcg_attach_configfs(struct f_uvc_opts *opts) |
2286 | { | 2215 | { |
2287 | config_group_init_type_name(&uvcg_control_header_grp.group, | 2216 | config_group_init_type_name(&uvcg_control_header_grp.group, |
2288 | "header", | 2217 | "header", |
2289 | &uvcg_control_header_grp_type); | 2218 | &uvcg_control_header_grp_type); |
2219 | |||
2290 | config_group_init_type_name(&uvcg_default_processing.group, | 2220 | config_group_init_type_name(&uvcg_default_processing.group, |
2291 | "default", | 2221 | "default", &uvcg_default_processing_type); |
2292 | &uvcg_default_processing_type); | 2222 | config_group_init_type_name(&uvcg_processing_grp.group, |
2293 | uvcg_init_group(&uvcg_processing_grp.group, | 2223 | "processing", &uvcg_processing_grp_type); |
2294 | uvcg_processing_default_groups, | 2224 | configfs_add_default_group(&uvcg_default_processing.group, |
2295 | "processing", | 2225 | &uvcg_processing_grp.group); |
2296 | &uvcg_processing_grp_type); | 2226 | |
2297 | config_group_init_type_name(&uvcg_default_camera.group, | 2227 | config_group_init_type_name(&uvcg_default_camera.group, |
2298 | "default", | 2228 | "default", &uvcg_default_camera_type); |
2299 | &uvcg_default_camera_type); | 2229 | config_group_init_type_name(&uvcg_camera_grp.group, |
2300 | uvcg_init_group(&uvcg_camera_grp.group, | 2230 | "camera", &uvcg_camera_grp_type); |
2301 | uvcg_camera_default_groups, | 2231 | configfs_add_default_group(&uvcg_default_camera.group, |
2302 | "camera", | 2232 | &uvcg_camera_grp.group); |
2303 | &uvcg_camera_grp_type); | 2233 | |
2304 | config_group_init_type_name(&uvcg_default_output.group, | 2234 | config_group_init_type_name(&uvcg_default_output.group, |
2305 | "default", | 2235 | "default", &uvcg_default_output_type); |
2306 | &uvcg_default_output_type); | 2236 | config_group_init_type_name(&uvcg_output_grp.group, |
2307 | uvcg_init_group(&uvcg_output_grp.group, | 2237 | "output", &uvcg_output_grp_type); |
2308 | uvcg_output_default_groups, | 2238 | configfs_add_default_group(&uvcg_default_output.group, |
2309 | "output", | 2239 | &uvcg_output_grp.group); |
2310 | &uvcg_output_grp_type); | 2240 | |
2311 | uvcg_init_group(&uvcg_terminal_grp.group, | 2241 | config_group_init_type_name(&uvcg_terminal_grp.group, |
2312 | uvcg_terminal_default_groups, | 2242 | "terminal", &uvcg_terminal_grp_type); |
2313 | "terminal", | 2243 | configfs_add_default_group(&uvcg_camera_grp.group, |
2314 | &uvcg_terminal_grp_type); | 2244 | &uvcg_terminal_grp.group); |
2245 | configfs_add_default_group(&uvcg_output_grp.group, | ||
2246 | &uvcg_terminal_grp.group); | ||
2247 | |||
2315 | config_group_init_type_name(&uvcg_control_class_fs.group, | 2248 | config_group_init_type_name(&uvcg_control_class_fs.group, |
2316 | "fs", | 2249 | "fs", &uvcg_control_class_type); |
2317 | &uvcg_control_class_type); | ||
2318 | config_group_init_type_name(&uvcg_control_class_ss.group, | 2250 | config_group_init_type_name(&uvcg_control_class_ss.group, |
2319 | "ss", | 2251 | "ss", &uvcg_control_class_type); |
2320 | &uvcg_control_class_type); | 2252 | config_group_init_type_name(&uvcg_control_class_grp.group, |
2321 | uvcg_init_group(&uvcg_control_class_grp.group, | ||
2322 | uvcg_control_class_default_groups, | ||
2323 | "class", | 2253 | "class", |
2324 | &uvcg_control_class_grp_type); | 2254 | &uvcg_control_class_grp_type); |
2325 | uvcg_init_group(&uvcg_control_grp.group, | 2255 | configfs_add_default_group(&uvcg_control_class_fs.group, |
2326 | uvcg_control_default_groups, | 2256 | &uvcg_control_class_grp.group); |
2257 | configfs_add_default_group(&uvcg_control_class_ss.group, | ||
2258 | &uvcg_control_class_grp.group); | ||
2259 | |||
2260 | config_group_init_type_name(&uvcg_control_grp.group, | ||
2327 | "control", | 2261 | "control", |
2328 | &uvcg_control_grp_type); | 2262 | &uvcg_control_grp_type); |
2263 | configfs_add_default_group(&uvcg_control_header_grp.group, | ||
2264 | &uvcg_control_grp.group); | ||
2265 | configfs_add_default_group(&uvcg_processing_grp.group, | ||
2266 | &uvcg_control_grp.group); | ||
2267 | configfs_add_default_group(&uvcg_terminal_grp.group, | ||
2268 | &uvcg_control_grp.group); | ||
2269 | configfs_add_default_group(&uvcg_control_class_grp.group, | ||
2270 | &uvcg_control_grp.group); | ||
2271 | |||
2329 | config_group_init_type_name(&uvcg_streaming_header_grp.group, | 2272 | config_group_init_type_name(&uvcg_streaming_header_grp.group, |
2330 | "header", | 2273 | "header", |
2331 | &uvcg_streaming_header_grp_type); | 2274 | &uvcg_streaming_header_grp_type); |
@@ -2338,30 +2281,47 @@ int uvcg_attach_configfs(struct f_uvc_opts *opts) | |||
2338 | config_group_init_type_name(&uvcg_default_color_matching.group, | 2281 | config_group_init_type_name(&uvcg_default_color_matching.group, |
2339 | "default", | 2282 | "default", |
2340 | &uvcg_default_color_matching_type); | 2283 | &uvcg_default_color_matching_type); |
2341 | uvcg_init_group(&uvcg_color_matching_grp.group, | 2284 | config_group_init_type_name(&uvcg_color_matching_grp.group, |
2342 | uvcg_color_matching_default_groups, | ||
2343 | "color_matching", | 2285 | "color_matching", |
2344 | &uvcg_color_matching_grp_type); | 2286 | &uvcg_color_matching_grp_type); |
2287 | configfs_add_default_group(&uvcg_default_color_matching.group, | ||
2288 | &uvcg_color_matching_grp.group); | ||
2289 | |||
2345 | config_group_init_type_name(&uvcg_streaming_class_fs.group, | 2290 | config_group_init_type_name(&uvcg_streaming_class_fs.group, |
2346 | "fs", | 2291 | "fs", &uvcg_streaming_class_type); |
2347 | &uvcg_streaming_class_type); | ||
2348 | config_group_init_type_name(&uvcg_streaming_class_hs.group, | 2292 | config_group_init_type_name(&uvcg_streaming_class_hs.group, |
2349 | "hs", | 2293 | "hs", &uvcg_streaming_class_type); |
2350 | &uvcg_streaming_class_type); | ||
2351 | config_group_init_type_name(&uvcg_streaming_class_ss.group, | 2294 | config_group_init_type_name(&uvcg_streaming_class_ss.group, |
2352 | "ss", | 2295 | "ss", &uvcg_streaming_class_type); |
2353 | &uvcg_streaming_class_type); | 2296 | config_group_init_type_name(&uvcg_streaming_class_grp.group, |
2354 | uvcg_init_group(&uvcg_streaming_class_grp.group, | 2297 | "class", &uvcg_streaming_class_grp_type); |
2355 | uvcg_streaming_class_default_groups, | 2298 | configfs_add_default_group(&uvcg_streaming_class_fs.group, |
2356 | "class", | 2299 | &uvcg_streaming_class_grp.group); |
2357 | &uvcg_streaming_class_grp_type); | 2300 | configfs_add_default_group(&uvcg_streaming_class_hs.group, |
2358 | uvcg_init_group(&uvcg_streaming_grp.group, | 2301 | &uvcg_streaming_class_grp.group); |
2359 | uvcg_streaming_default_groups, | 2302 | configfs_add_default_group(&uvcg_streaming_class_ss.group, |
2360 | "streaming", | 2303 | &uvcg_streaming_class_grp.group); |
2361 | &uvcg_streaming_grp_type); | 2304 | |
2362 | uvcg_init_group(&opts->func_inst.group, | 2305 | config_group_init_type_name(&uvcg_streaming_grp.group, |
2363 | uvcg_default_groups, | 2306 | "streaming", &uvcg_streaming_grp_type); |
2307 | configfs_add_default_group(&uvcg_streaming_header_grp.group, | ||
2308 | &uvcg_streaming_grp.group); | ||
2309 | configfs_add_default_group(&uvcg_uncompressed_grp.group, | ||
2310 | &uvcg_streaming_grp.group); | ||
2311 | configfs_add_default_group(&uvcg_mjpeg_grp.group, | ||
2312 | &uvcg_streaming_grp.group); | ||
2313 | configfs_add_default_group(&uvcg_color_matching_grp.group, | ||
2314 | &uvcg_streaming_grp.group); | ||
2315 | configfs_add_default_group(&uvcg_streaming_class_grp.group, | ||
2316 | &uvcg_streaming_grp.group); | ||
2317 | |||
2318 | config_group_init_type_name(&opts->func_inst.group, | ||
2364 | "", | 2319 | "", |
2365 | &uvc_func_type); | 2320 | &uvc_func_type); |
2321 | configfs_add_default_group(&uvcg_control_grp.group, | ||
2322 | &opts->func_inst.group); | ||
2323 | configfs_add_default_group(&uvcg_streaming_grp.group, | ||
2324 | &opts->func_inst.group); | ||
2325 | |||
2366 | return 0; | 2326 | return 0; |
2367 | } | 2327 | } |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index f419519ec41f..b51ce6778145 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -701,23 +701,29 @@ static int populate_groups(struct config_group *group) | |||
701 | { | 701 | { |
702 | struct config_group *new_group; | 702 | struct config_group *new_group; |
703 | int ret = 0; | 703 | int ret = 0; |
704 | int i; | ||
705 | |||
706 | if (group->default_groups) { | ||
707 | for (i = 0; group->default_groups[i]; i++) { | ||
708 | new_group = group->default_groups[i]; | ||
709 | 704 | ||
710 | ret = create_default_group(group, new_group); | 705 | list_for_each_entry(new_group, &group->default_groups, group_entry) { |
711 | if (ret) { | 706 | ret = create_default_group(group, new_group); |
712 | detach_groups(group); | 707 | if (ret) { |
713 | break; | 708 | detach_groups(group); |
714 | } | 709 | break; |
715 | } | 710 | } |
716 | } | 711 | } |
717 | 712 | ||
718 | return ret; | 713 | return ret; |
719 | } | 714 | } |
720 | 715 | ||
716 | void configfs_remove_default_groups(struct config_group *group) | ||
717 | { | ||
718 | struct config_group *g, *n; | ||
719 | |||
720 | list_for_each_entry_safe(g, n, &group->default_groups, group_entry) { | ||
721 | list_del(&g->group_entry); | ||
722 | config_item_put(&g->cg_item); | ||
723 | } | ||
724 | } | ||
725 | EXPORT_SYMBOL(configfs_remove_default_groups); | ||
726 | |||
721 | /* | 727 | /* |
722 | * All of link_obj/unlink_obj/link_group/unlink_group require that | 728 | * All of link_obj/unlink_obj/link_group/unlink_group require that |
723 | * subsys->su_mutex is held. | 729 | * subsys->su_mutex is held. |
@@ -766,15 +772,10 @@ static void link_obj(struct config_item *parent_item, struct config_item *item) | |||
766 | 772 | ||
767 | static void unlink_group(struct config_group *group) | 773 | static void unlink_group(struct config_group *group) |
768 | { | 774 | { |
769 | int i; | ||
770 | struct config_group *new_group; | 775 | struct config_group *new_group; |
771 | 776 | ||
772 | if (group->default_groups) { | 777 | list_for_each_entry(new_group, &group->default_groups, group_entry) |
773 | for (i = 0; group->default_groups[i]; i++) { | 778 | unlink_group(new_group); |
774 | new_group = group->default_groups[i]; | ||
775 | unlink_group(new_group); | ||
776 | } | ||
777 | } | ||
778 | 779 | ||
779 | group->cg_subsys = NULL; | 780 | group->cg_subsys = NULL; |
780 | unlink_obj(&group->cg_item); | 781 | unlink_obj(&group->cg_item); |
@@ -782,7 +783,6 @@ static void unlink_group(struct config_group *group) | |||
782 | 783 | ||
783 | static void link_group(struct config_group *parent_group, struct config_group *group) | 784 | static void link_group(struct config_group *parent_group, struct config_group *group) |
784 | { | 785 | { |
785 | int i; | ||
786 | struct config_group *new_group; | 786 | struct config_group *new_group; |
787 | struct configfs_subsystem *subsys = NULL; /* gcc is a turd */ | 787 | struct configfs_subsystem *subsys = NULL; /* gcc is a turd */ |
788 | 788 | ||
@@ -796,12 +796,8 @@ static void link_group(struct config_group *parent_group, struct config_group *g | |||
796 | BUG(); | 796 | BUG(); |
797 | group->cg_subsys = subsys; | 797 | group->cg_subsys = subsys; |
798 | 798 | ||
799 | if (group->default_groups) { | 799 | list_for_each_entry(new_group, &group->default_groups, group_entry) |
800 | for (i = 0; group->default_groups[i]; i++) { | 800 | link_group(group, new_group); |
801 | new_group = group->default_groups[i]; | ||
802 | link_group(group, new_group); | ||
803 | } | ||
804 | } | ||
805 | } | 801 | } |
806 | 802 | ||
807 | /* | 803 | /* |
diff --git a/fs/configfs/item.c b/fs/configfs/item.c index b863a09cd2f1..8b2a994042dd 100644 --- a/fs/configfs/item.c +++ b/fs/configfs/item.c | |||
@@ -182,6 +182,7 @@ void config_group_init(struct config_group *group) | |||
182 | { | 182 | { |
183 | config_item_init(&group->cg_item); | 183 | config_item_init(&group->cg_item); |
184 | INIT_LIST_HEAD(&group->cg_children); | 184 | INIT_LIST_HEAD(&group->cg_children); |
185 | INIT_LIST_HEAD(&group->default_groups); | ||
185 | } | 186 | } |
186 | EXPORT_SYMBOL(config_group_init); | 187 | EXPORT_SYMBOL(config_group_init); |
187 | 188 | ||
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index 8e294fbbac39..519112168a9e 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -346,7 +346,6 @@ static struct config_group *make_cluster(struct config_group *g, | |||
346 | void *gps = NULL; | 346 | void *gps = NULL; |
347 | 347 | ||
348 | cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS); | 348 | cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS); |
349 | gps = kcalloc(3, sizeof(struct config_group *), GFP_NOFS); | ||
350 | sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS); | 349 | sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS); |
351 | cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS); | 350 | cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS); |
352 | 351 | ||
@@ -357,10 +356,8 @@ static struct config_group *make_cluster(struct config_group *g, | |||
357 | config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); | 356 | config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); |
358 | config_group_init_type_name(&cms->cs_group, "comms", &comms_type); | 357 | config_group_init_type_name(&cms->cs_group, "comms", &comms_type); |
359 | 358 | ||
360 | cl->group.default_groups = gps; | 359 | configfs_add_default_group(&sps->ss_group, &cl->group); |
361 | cl->group.default_groups[0] = &sps->ss_group; | 360 | configfs_add_default_group(&cms->cs_group, &cl->group); |
362 | cl->group.default_groups[1] = &cms->cs_group; | ||
363 | cl->group.default_groups[2] = NULL; | ||
364 | 361 | ||
365 | cl->cl_tcp_port = dlm_config.ci_tcp_port; | 362 | cl->cl_tcp_port = dlm_config.ci_tcp_port; |
366 | cl->cl_buffer_size = dlm_config.ci_buffer_size; | 363 | cl->cl_buffer_size = dlm_config.ci_buffer_size; |
@@ -383,7 +380,6 @@ static struct config_group *make_cluster(struct config_group *g, | |||
383 | 380 | ||
384 | fail: | 381 | fail: |
385 | kfree(cl); | 382 | kfree(cl); |
386 | kfree(gps); | ||
387 | kfree(sps); | 383 | kfree(sps); |
388 | kfree(cms); | 384 | kfree(cms); |
389 | return ERR_PTR(-ENOMEM); | 385 | return ERR_PTR(-ENOMEM); |
@@ -392,14 +388,8 @@ static struct config_group *make_cluster(struct config_group *g, | |||
392 | static void drop_cluster(struct config_group *g, struct config_item *i) | 388 | static void drop_cluster(struct config_group *g, struct config_item *i) |
393 | { | 389 | { |
394 | struct dlm_cluster *cl = config_item_to_cluster(i); | 390 | struct dlm_cluster *cl = config_item_to_cluster(i); |
395 | struct config_item *tmp; | ||
396 | int j; | ||
397 | 391 | ||
398 | for (j = 0; cl->group.default_groups[j]; j++) { | 392 | configfs_remove_default_groups(&cl->group); |
399 | tmp = &cl->group.default_groups[j]->cg_item; | ||
400 | cl->group.default_groups[j] = NULL; | ||
401 | config_item_put(tmp); | ||
402 | } | ||
403 | 393 | ||
404 | space_list = NULL; | 394 | space_list = NULL; |
405 | comm_list = NULL; | 395 | comm_list = NULL; |
@@ -410,7 +400,6 @@ static void drop_cluster(struct config_group *g, struct config_item *i) | |||
410 | static void release_cluster(struct config_item *i) | 400 | static void release_cluster(struct config_item *i) |
411 | { | 401 | { |
412 | struct dlm_cluster *cl = config_item_to_cluster(i); | 402 | struct dlm_cluster *cl = config_item_to_cluster(i); |
413 | kfree(cl->group.default_groups); | ||
414 | kfree(cl); | 403 | kfree(cl); |
415 | } | 404 | } |
416 | 405 | ||
@@ -418,21 +407,17 @@ static struct config_group *make_space(struct config_group *g, const char *name) | |||
418 | { | 407 | { |
419 | struct dlm_space *sp = NULL; | 408 | struct dlm_space *sp = NULL; |
420 | struct dlm_nodes *nds = NULL; | 409 | struct dlm_nodes *nds = NULL; |
421 | void *gps = NULL; | ||
422 | 410 | ||
423 | sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS); | 411 | sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS); |
424 | gps = kcalloc(2, sizeof(struct config_group *), GFP_NOFS); | ||
425 | nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS); | 412 | nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS); |
426 | 413 | ||
427 | if (!sp || !gps || !nds) | 414 | if (!sp || !nds) |
428 | goto fail; | 415 | goto fail; |
429 | 416 | ||
430 | config_group_init_type_name(&sp->group, name, &space_type); | 417 | config_group_init_type_name(&sp->group, name, &space_type); |
431 | config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); | ||
432 | 418 | ||
433 | sp->group.default_groups = gps; | 419 | config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); |
434 | sp->group.default_groups[0] = &nds->ns_group; | 420 | configfs_add_default_group(&nds->ns_group, &sp->group); |
435 | sp->group.default_groups[1] = NULL; | ||
436 | 421 | ||
437 | INIT_LIST_HEAD(&sp->members); | 422 | INIT_LIST_HEAD(&sp->members); |
438 | mutex_init(&sp->members_lock); | 423 | mutex_init(&sp->members_lock); |
@@ -441,7 +426,6 @@ static struct config_group *make_space(struct config_group *g, const char *name) | |||
441 | 426 | ||
442 | fail: | 427 | fail: |
443 | kfree(sp); | 428 | kfree(sp); |
444 | kfree(gps); | ||
445 | kfree(nds); | 429 | kfree(nds); |
446 | return ERR_PTR(-ENOMEM); | 430 | return ERR_PTR(-ENOMEM); |
447 | } | 431 | } |
@@ -449,24 +433,16 @@ static struct config_group *make_space(struct config_group *g, const char *name) | |||
449 | static void drop_space(struct config_group *g, struct config_item *i) | 433 | static void drop_space(struct config_group *g, struct config_item *i) |
450 | { | 434 | { |
451 | struct dlm_space *sp = config_item_to_space(i); | 435 | struct dlm_space *sp = config_item_to_space(i); |
452 | struct config_item *tmp; | ||
453 | int j; | ||
454 | 436 | ||
455 | /* assert list_empty(&sp->members) */ | 437 | /* assert list_empty(&sp->members) */ |
456 | 438 | ||
457 | for (j = 0; sp->group.default_groups[j]; j++) { | 439 | configfs_remove_default_groups(&sp->group); |
458 | tmp = &sp->group.default_groups[j]->cg_item; | ||
459 | sp->group.default_groups[j] = NULL; | ||
460 | config_item_put(tmp); | ||
461 | } | ||
462 | |||
463 | config_item_put(i); | 440 | config_item_put(i); |
464 | } | 441 | } |
465 | 442 | ||
466 | static void release_space(struct config_item *i) | 443 | static void release_space(struct config_item *i) |
467 | { | 444 | { |
468 | struct dlm_space *sp = config_item_to_space(i); | 445 | struct dlm_space *sp = config_item_to_space(i); |
469 | kfree(sp->group.default_groups); | ||
470 | kfree(sp); | 446 | kfree(sp); |
471 | } | 447 | } |
472 | 448 | ||
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index ebe543894db0..b17d180bdc16 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -630,7 +630,6 @@ static void o2nm_cluster_release(struct config_item *item) | |||
630 | { | 630 | { |
631 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | 631 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); |
632 | 632 | ||
633 | kfree(cluster->cl_group.default_groups); | ||
634 | kfree(cluster); | 633 | kfree(cluster); |
635 | } | 634 | } |
636 | 635 | ||
@@ -666,7 +665,6 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g | |||
666 | struct o2nm_cluster *cluster = NULL; | 665 | struct o2nm_cluster *cluster = NULL; |
667 | struct o2nm_node_group *ns = NULL; | 666 | struct o2nm_node_group *ns = NULL; |
668 | struct config_group *o2hb_group = NULL, *ret = NULL; | 667 | struct config_group *o2hb_group = NULL, *ret = NULL; |
669 | void *defs = NULL; | ||
670 | 668 | ||
671 | /* this runs under the parent dir's i_mutex; there can be only | 669 | /* this runs under the parent dir's i_mutex; there can be only |
672 | * one caller in here at a time */ | 670 | * one caller in here at a time */ |
@@ -675,20 +673,18 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g | |||
675 | 673 | ||
676 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); | 674 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); |
677 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); | 675 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); |
678 | defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); | ||
679 | o2hb_group = o2hb_alloc_hb_set(); | 676 | o2hb_group = o2hb_alloc_hb_set(); |
680 | if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) | 677 | if (cluster == NULL || ns == NULL || o2hb_group == NULL) |
681 | goto out; | 678 | goto out; |
682 | 679 | ||
683 | config_group_init_type_name(&cluster->cl_group, name, | 680 | config_group_init_type_name(&cluster->cl_group, name, |
684 | &o2nm_cluster_type); | 681 | &o2nm_cluster_type); |
682 | configfs_add_default_group(&ns->ns_group, &cluster->cl_group); | ||
683 | |||
685 | config_group_init_type_name(&ns->ns_group, "node", | 684 | config_group_init_type_name(&ns->ns_group, "node", |
686 | &o2nm_node_group_type); | 685 | &o2nm_node_group_type); |
686 | configfs_add_default_group(o2hb_group, &cluster->cl_group); | ||
687 | 687 | ||
688 | cluster->cl_group.default_groups = defs; | ||
689 | cluster->cl_group.default_groups[0] = &ns->ns_group; | ||
690 | cluster->cl_group.default_groups[1] = o2hb_group; | ||
691 | cluster->cl_group.default_groups[2] = NULL; | ||
692 | rwlock_init(&cluster->cl_nodes_lock); | 688 | rwlock_init(&cluster->cl_nodes_lock); |
693 | cluster->cl_node_ip_tree = RB_ROOT; | 689 | cluster->cl_node_ip_tree = RB_ROOT; |
694 | cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT; | 690 | cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT; |
@@ -704,7 +700,6 @@ out: | |||
704 | kfree(cluster); | 700 | kfree(cluster); |
705 | kfree(ns); | 701 | kfree(ns); |
706 | o2hb_free_hb_set(o2hb_group); | 702 | o2hb_free_hb_set(o2hb_group); |
707 | kfree(defs); | ||
708 | ret = ERR_PTR(-ENOMEM); | 703 | ret = ERR_PTR(-ENOMEM); |
709 | } | 704 | } |
710 | 705 | ||
@@ -714,18 +709,11 @@ out: | |||
714 | static void o2nm_cluster_group_drop_item(struct config_group *group, struct config_item *item) | 709 | static void o2nm_cluster_group_drop_item(struct config_group *group, struct config_item *item) |
715 | { | 710 | { |
716 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | 711 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); |
717 | int i; | ||
718 | struct config_item *killme; | ||
719 | 712 | ||
720 | BUG_ON(o2nm_single_cluster != cluster); | 713 | BUG_ON(o2nm_single_cluster != cluster); |
721 | o2nm_single_cluster = NULL; | 714 | o2nm_single_cluster = NULL; |
722 | 715 | ||
723 | for (i = 0; cluster->cl_group.default_groups[i]; i++) { | 716 | configfs_remove_default_groups(&cluster->cl_group); |
724 | killme = &cluster->cl_group.default_groups[i]->cg_item; | ||
725 | cluster->cl_group.default_groups[i] = NULL; | ||
726 | config_item_put(killme); | ||
727 | } | ||
728 | |||
729 | config_item_put(item); | 717 | config_item_put(item); |
730 | } | 718 | } |
731 | 719 | ||
diff --git a/include/linux/configfs.h b/include/linux/configfs.h index f8165c129ccb..485fe5519448 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h | |||
@@ -96,7 +96,8 @@ struct config_group { | |||
96 | struct config_item cg_item; | 96 | struct config_item cg_item; |
97 | struct list_head cg_children; | 97 | struct list_head cg_children; |
98 | struct configfs_subsystem *cg_subsys; | 98 | struct configfs_subsystem *cg_subsys; |
99 | struct config_group **default_groups; | 99 | struct list_head default_groups; |
100 | struct list_head group_entry; | ||
100 | }; | 101 | }; |
101 | 102 | ||
102 | extern void config_group_init(struct config_group *group); | 103 | extern void config_group_init(struct config_group *group); |
@@ -123,6 +124,12 @@ extern struct config_item *config_group_find_item(struct config_group *, | |||
123 | const char *); | 124 | const char *); |
124 | 125 | ||
125 | 126 | ||
127 | static inline void configfs_add_default_group(struct config_group *new_group, | ||
128 | struct config_group *group) | ||
129 | { | ||
130 | list_add_tail(&new_group->group_entry, &group->default_groups); | ||
131 | } | ||
132 | |||
126 | struct configfs_attribute { | 133 | struct configfs_attribute { |
127 | const char *ca_name; | 134 | const char *ca_name; |
128 | struct module *ca_owner; | 135 | struct module *ca_owner; |
@@ -251,6 +258,8 @@ int configfs_register_group(struct config_group *parent_group, | |||
251 | struct config_group *group); | 258 | struct config_group *group); |
252 | void configfs_unregister_group(struct config_group *group); | 259 | void configfs_unregister_group(struct config_group *group); |
253 | 260 | ||
261 | void configfs_remove_default_groups(struct config_group *group); | ||
262 | |||
254 | struct config_group * | 263 | struct config_group * |
255 | configfs_register_default_group(struct config_group *parent_group, | 264 | configfs_register_default_group(struct config_group *parent_group, |
256 | const char *name, | 265 | const char *name, |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index e8c8c08bf575..1b09cac06508 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -560,7 +560,6 @@ struct se_node_acl { | |||
560 | struct config_group acl_auth_group; | 560 | struct config_group acl_auth_group; |
561 | struct config_group acl_param_group; | 561 | struct config_group acl_param_group; |
562 | struct config_group acl_fabric_stat_group; | 562 | struct config_group acl_fabric_stat_group; |
563 | struct config_group *acl_default_groups[5]; | ||
564 | struct list_head acl_list; | 563 | struct list_head acl_list; |
565 | struct list_head acl_sess_list; | 564 | struct list_head acl_sess_list; |
566 | struct completion acl_free_comp; | 565 | struct completion acl_free_comp; |
@@ -887,7 +886,6 @@ struct se_portal_group { | |||
887 | const struct target_core_fabric_ops *se_tpg_tfo; | 886 | const struct target_core_fabric_ops *se_tpg_tfo; |
888 | struct se_wwn *se_tpg_wwn; | 887 | struct se_wwn *se_tpg_wwn; |
889 | struct config_group tpg_group; | 888 | struct config_group tpg_group; |
890 | struct config_group *tpg_default_groups[7]; | ||
891 | struct config_group tpg_lun_group; | 889 | struct config_group tpg_lun_group; |
892 | struct config_group tpg_np_group; | 890 | struct config_group tpg_np_group; |
893 | struct config_group tpg_acl_group; | 891 | struct config_group tpg_acl_group; |
@@ -923,7 +921,6 @@ static inline struct se_portal_group *param_to_tpg(struct config_item *item) | |||
923 | struct se_wwn { | 921 | struct se_wwn { |
924 | struct target_fabric_configfs *wwn_tf; | 922 | struct target_fabric_configfs *wwn_tf; |
925 | struct config_group wwn_group; | 923 | struct config_group wwn_group; |
926 | struct config_group *wwn_default_groups[2]; | ||
927 | struct config_group fabric_stat_group; | 924 | struct config_group fabric_stat_group; |
928 | }; | 925 | }; |
929 | 926 | ||