Commit 3fe6c5ce1176cf661dbe71fc43b627c1a742a89a

Authored by Satyam Sharma
Committed by Mark Fasheh
1 parent 9b1d9aa4e9

[PATCH] configfs+dlm: Rename config_group_find_obj and state semantics clearly

Configfs being based upon sysfs code, config_group_find_obj() is probably
so named because of the similar kset_find_obj() in sysfs. However,
"kobject"s in sysfs become "config_item"s in configfs, so let's call it
config_group_find_item() instead, for sake of uniformity, and make
corresponding change in the users of this function.

BTW a crucial difference between kset_find_obj and config_group_find_item
is in locking expectations. kset_find_obj does its locking by itself, but
config_group_find_item expects the *caller* to do the locking. The reason
for this: kset's have their own locks, config_group's don't but instead
rely on the subsystem mutex. And, subsystem needn't necessarily be around
when config_group_find_item() is called.

So let's state these locking semantics explicitly, and rectify the comment,
otherwise bugs could continue to occur in future, as they did in the past
(refer commit d82b8191e238 in gfs2-2.6-fixes.git).

[ I also took the opportunity to fix some bad whitespace and
double-empty lines. --Joel ]

[ Conflict in fs/dlm/config.c with commit
  3168b0780d06ace875696f8a648d04d6089654e5 manually resolved. --Mark ]

Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Cc: David Teigland <teigland@redhat.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

Showing 3 changed files with 11 additions and 16 deletions Side-by-side Diff

... ... @@ -183,27 +183,25 @@
183 183 INIT_LIST_HEAD(&group->cg_children);
184 184 }
185 185  
186   -
187 186 /**
188   - * config_group_find_obj - search for item in group.
  187 + * config_group_find_item - search for item in group.
189 188 * @group: group we're looking in.
190 189 * @name: item's name.
191 190 *
192   - * Lock group via @group->cg_subsys, and iterate over @group->cg_list,
193   - * looking for a matching config_item. If matching item is found
194   - * take a reference and return the item.
  191 + * Iterate over @group->cg_list, looking for a matching config_item.
  192 + * If matching item is found take a reference and return the item.
  193 + * Caller must have locked group via @group->cg_subsys->su_mtx.
195 194 */
196   -struct config_item *config_group_find_obj(struct config_group *group,
197   - const char * name)
  195 +struct config_item *config_group_find_item(struct config_group *group,
  196 + const char *name)
198 197 {
199 198 struct list_head * entry;
200 199 struct config_item * ret = NULL;
201 200  
202   - /* XXX LOCKING! */
203 201 list_for_each(entry,&group->cg_children) {
204 202 struct config_item * item = to_item(entry);
205 203 if (config_item_name(item) &&
206   - !strcmp(config_item_name(item), name)) {
  204 + !strcmp(config_item_name(item), name)) {
207 205 ret = config_item_get(item);
208 206 break;
209 207 }
... ... @@ -215,5 +213,5 @@
215 213 EXPORT_SYMBOL(config_group_init);
216 214 EXPORT_SYMBOL(config_item_get);
217 215 EXPORT_SYMBOL(config_item_put);
218   -EXPORT_SYMBOL(config_group_find_obj);
  216 +EXPORT_SYMBOL(config_group_find_item);
... ... @@ -752,7 +752,7 @@
752 752 return NULL;
753 753  
754 754 down(&space_list->cg_subsys->su_sem);
755   - i = config_group_find_obj(space_list, name);
  755 + i = config_group_find_item(space_list, name);
756 756 up(&space_list->cg_subsys->su_sem);
757 757  
758 758 return to_space(i);
include/linux/configfs.h
... ... @@ -86,12 +86,10 @@
86 86 struct configfs_attribute **ct_attrs;
87 87 };
88 88  
89   -
90 89 /**
91 90 * group - a group of config_items of a specific type, belonging
92 91 * to a specific subsystem.
93 92 */
94   -
95 93 struct config_group {
96 94 struct config_item cg_item;
97 95 struct list_head cg_children;
98 96  
... ... @@ -99,13 +97,11 @@
99 97 struct config_group **default_groups;
100 98 };
101 99  
102   -
103 100 extern void config_group_init(struct config_group *group);
104 101 extern void config_group_init_type_name(struct config_group *group,
105 102 const char *name,
106 103 struct config_item_type *type);
107 104  
108   -
109 105 static inline struct config_group *to_config_group(struct config_item *item)
110 106 {
111 107 return item ? container_of(item,struct config_group,cg_item) : NULL;
... ... @@ -121,7 +117,8 @@
121 117 config_item_put(&group->cg_item);
122 118 }
123 119  
124   -extern struct config_item *config_group_find_obj(struct config_group *, const char *);
  120 +extern struct config_item *config_group_find_item(struct config_group *,
  121 + const char *);
125 122  
126 123  
127 124 struct configfs_attribute {