diff options
Diffstat (limited to 'fs')
-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 |
4 files changed, 33 insertions, 72 deletions
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) { struct config_group *new_group; int ret = 0; - int i; - - if (group->default_groups) { - for (i = 0; group->default_groups[i]; i++) { - new_group = group->default_groups[i]; - ret = create_default_group(group, new_group); - if (ret) { - detach_groups(group); - break; - } + list_for_each_entry(new_group, &group->default_groups, group_entry) { + ret = create_default_group(group, new_group); + if (ret) { + detach_groups(group); + break; } } return ret; } +void configfs_remove_default_groups(struct config_group *group) +{ + struct config_group *g, *n; + + list_for_each_entry_safe(g, n, &group->default_groups, group_entry) { + list_del(&g->group_entry); + config_item_put(&g->cg_item); + } +} +EXPORT_SYMBOL(configfs_remove_default_groups); + /* * All of link_obj/unlink_obj/link_group/unlink_group require that * subsys->su_mutex is held. @@ -766,15 +772,10 @@ static void link_obj(struct config_item *parent_item, struct config_item *item) static void unlink_group(struct config_group *group) { - int i; struct config_group *new_group; - if (group->default_groups) { - for (i = 0; group->default_groups[i]; i++) { - new_group = group->default_groups[i]; - unlink_group(new_group); - } - } + list_for_each_entry(new_group, &group->default_groups, group_entry) + unlink_group(new_group); group->cg_subsys = NULL; unlink_obj(&group->cg_item); @@ -782,7 +783,6 @@ static void unlink_group(struct config_group *group) static void link_group(struct config_group *parent_group, struct config_group *group) { - int i; struct config_group *new_group; struct configfs_subsystem *subsys = NULL; /* gcc is a turd */ @@ -796,12 +796,8 @@ static void link_group(struct config_group *parent_group, struct config_group *g BUG(); group->cg_subsys = subsys; - if (group->default_groups) { - for (i = 0; group->default_groups[i]; i++) { - new_group = group->default_groups[i]; - link_group(group, new_group); - } - } + list_for_each_entry(new_group, &group->default_groups, group_entry) + link_group(group, new_group); } /* 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) { config_item_init(&group->cg_item); INIT_LIST_HEAD(&group->cg_children); + INIT_LIST_HEAD(&group->default_groups); } EXPORT_SYMBOL(config_group_init); 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, void *gps = NULL; cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS); - gps = kcalloc(3, sizeof(struct config_group *), GFP_NOFS); sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS); cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS); @@ -357,10 +356,8 @@ static struct config_group *make_cluster(struct config_group *g, config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); config_group_init_type_name(&cms->cs_group, "comms", &comms_type); - cl->group.default_groups = gps; - cl->group.default_groups[0] = &sps->ss_group; - cl->group.default_groups[1] = &cms->cs_group; - cl->group.default_groups[2] = NULL; + configfs_add_default_group(&sps->ss_group, &cl->group); + configfs_add_default_group(&cms->cs_group, &cl->group); cl->cl_tcp_port = dlm_config.ci_tcp_port; cl->cl_buffer_size = dlm_config.ci_buffer_size; @@ -383,7 +380,6 @@ static struct config_group *make_cluster(struct config_group *g, fail: kfree(cl); - kfree(gps); kfree(sps); kfree(cms); return ERR_PTR(-ENOMEM); @@ -392,14 +388,8 @@ static struct config_group *make_cluster(struct config_group *g, static void drop_cluster(struct config_group *g, struct config_item *i) { struct dlm_cluster *cl = config_item_to_cluster(i); - struct config_item *tmp; - int j; - for (j = 0; cl->group.default_groups[j]; j++) { - tmp = &cl->group.default_groups[j]->cg_item; - cl->group.default_groups[j] = NULL; - config_item_put(tmp); - } + configfs_remove_default_groups(&cl->group); space_list = NULL; comm_list = NULL; @@ -410,7 +400,6 @@ static void drop_cluster(struct config_group *g, struct config_item *i) static void release_cluster(struct config_item *i) { struct dlm_cluster *cl = config_item_to_cluster(i); - kfree(cl->group.default_groups); kfree(cl); } @@ -418,21 +407,17 @@ static struct config_group *make_space(struct config_group *g, const char *name) { struct dlm_space *sp = NULL; struct dlm_nodes *nds = NULL; - void *gps = NULL; sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS); - gps = kcalloc(2, sizeof(struct config_group *), GFP_NOFS); nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS); - if (!sp || !gps || !nds) + if (!sp || !nds) goto fail; config_group_init_type_name(&sp->group, name, &space_type); - config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); - sp->group.default_groups = gps; - sp->group.default_groups[0] = &nds->ns_group; - sp->group.default_groups[1] = NULL; + config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); + configfs_add_default_group(&nds->ns_group, &sp->group); INIT_LIST_HEAD(&sp->members); mutex_init(&sp->members_lock); @@ -441,7 +426,6 @@ static struct config_group *make_space(struct config_group *g, const char *name) fail: kfree(sp); - kfree(gps); kfree(nds); return ERR_PTR(-ENOMEM); } @@ -449,24 +433,16 @@ static struct config_group *make_space(struct config_group *g, const char *name) static void drop_space(struct config_group *g, struct config_item *i) { struct dlm_space *sp = config_item_to_space(i); - struct config_item *tmp; - int j; /* assert list_empty(&sp->members) */ - for (j = 0; sp->group.default_groups[j]; j++) { - tmp = &sp->group.default_groups[j]->cg_item; - sp->group.default_groups[j] = NULL; - config_item_put(tmp); - } - + configfs_remove_default_groups(&sp->group); config_item_put(i); } static void release_space(struct config_item *i) { struct dlm_space *sp = config_item_to_space(i); - kfree(sp->group.default_groups); kfree(sp); } 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) { struct o2nm_cluster *cluster = to_o2nm_cluster(item); - kfree(cluster->cl_group.default_groups); kfree(cluster); } @@ -666,7 +665,6 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g struct o2nm_cluster *cluster = NULL; struct o2nm_node_group *ns = NULL; struct config_group *o2hb_group = NULL, *ret = NULL; - void *defs = NULL; /* this runs under the parent dir's i_mutex; there can be only * one caller in here at a time */ @@ -675,20 +673,18 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); - defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); o2hb_group = o2hb_alloc_hb_set(); - if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) + if (cluster == NULL || ns == NULL || o2hb_group == NULL) goto out; config_group_init_type_name(&cluster->cl_group, name, &o2nm_cluster_type); + configfs_add_default_group(&ns->ns_group, &cluster->cl_group); + config_group_init_type_name(&ns->ns_group, "node", &o2nm_node_group_type); + configfs_add_default_group(o2hb_group, &cluster->cl_group); - cluster->cl_group.default_groups = defs; - cluster->cl_group.default_groups[0] = &ns->ns_group; - cluster->cl_group.default_groups[1] = o2hb_group; - cluster->cl_group.default_groups[2] = NULL; rwlock_init(&cluster->cl_nodes_lock); cluster->cl_node_ip_tree = RB_ROOT; cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT; @@ -704,7 +700,6 @@ out: kfree(cluster); kfree(ns); o2hb_free_hb_set(o2hb_group); - kfree(defs); ret = ERR_PTR(-ENOMEM); } @@ -714,18 +709,11 @@ out: static void o2nm_cluster_group_drop_item(struct config_group *group, struct config_item *item) { struct o2nm_cluster *cluster = to_o2nm_cluster(item); - int i; - struct config_item *killme; BUG_ON(o2nm_single_cluster != cluster); o2nm_single_cluster = NULL; - for (i = 0; cluster->cl_group.default_groups[i]; i++) { - killme = &cluster->cl_group.default_groups[i]->cg_item; - cluster->cl_group.default_groups[i] = NULL; - config_item_put(killme); - } - + configfs_remove_default_groups(&cluster->cl_group); config_item_put(item); } |