diff options
author | Eric Paris <eparis@redhat.com> | 2009-12-17 21:24:22 -0500 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-07-28 09:58:50 -0400 |
commit | 74be0cc82835aecad332a29896b0f212ba893403 (patch) | |
tree | eaae59c73ba52ff8cab8ee845e989d9877603f4c /fs | |
parent | cac69dad32899c6f4c66bb4f9baf69b0d3c7d3d1 (diff) |
fsnotify: remove group_num altogether
The original fsnotify interface has a group-num which was intended to be
able to find a group after it was added. I no longer think this is a
necessary thing to do and so we remove the group_num.
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/notify/dnotify/dnotify.c | 3 | ||||
-rw-r--r-- | fs/notify/group.c | 48 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 11 |
3 files changed, 4 insertions, 58 deletions
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index a213b83a59cf..1f46aeac3387 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c | |||
@@ -433,8 +433,7 @@ static int __init dnotify_init(void) | |||
433 | dnotify_struct_cache = KMEM_CACHE(dnotify_struct, SLAB_PANIC); | 433 | dnotify_struct_cache = KMEM_CACHE(dnotify_struct, SLAB_PANIC); |
434 | dnotify_mark_entry_cache = KMEM_CACHE(dnotify_mark_entry, SLAB_PANIC); | 434 | dnotify_mark_entry_cache = KMEM_CACHE(dnotify_mark_entry, SLAB_PANIC); |
435 | 435 | ||
436 | dnotify_group = fsnotify_obtain_group(DNOTIFY_GROUP_NUM, | 436 | dnotify_group = fsnotify_obtain_group(0, &dnotify_fsnotify_ops); |
437 | 0, &dnotify_fsnotify_ops); | ||
438 | if (IS_ERR(dnotify_group)) | 437 | if (IS_ERR(dnotify_group)) |
439 | panic("unable to allocate fsnotify group for dnotify\n"); | 438 | panic("unable to allocate fsnotify group for dnotify\n"); |
440 | return 0; | 439 | return 0; |
diff --git a/fs/notify/group.c b/fs/notify/group.c index 777ca8212255..62fb8961a57b 100644 --- a/fs/notify/group.c +++ b/fs/notify/group.c | |||
@@ -78,15 +78,6 @@ void fsnotify_recalc_group_mask(struct fsnotify_group *group) | |||
78 | } | 78 | } |
79 | 79 | ||
80 | /* | 80 | /* |
81 | * Take a reference to a group so things found under the fsnotify_grp_mutex | ||
82 | * can't get freed under us | ||
83 | */ | ||
84 | static void fsnotify_get_group(struct fsnotify_group *group) | ||
85 | { | ||
86 | atomic_inc(&group->refcnt); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Final freeing of a group | 81 | * Final freeing of a group |
91 | */ | 82 | */ |
92 | void fsnotify_final_destroy_group(struct fsnotify_group *group) | 83 | void fsnotify_final_destroy_group(struct fsnotify_group *group) |
@@ -171,40 +162,14 @@ void fsnotify_put_group(struct fsnotify_group *group) | |||
171 | } | 162 | } |
172 | 163 | ||
173 | /* | 164 | /* |
174 | * Simply run the fsnotify_groups list and find a group which matches | ||
175 | * the given parameters. If a group is found we take a reference to that | ||
176 | * group. | ||
177 | */ | ||
178 | static struct fsnotify_group *fsnotify_find_group(unsigned int group_num, __u32 mask, | ||
179 | const struct fsnotify_ops *ops) | ||
180 | { | ||
181 | struct fsnotify_group *group_iter; | ||
182 | struct fsnotify_group *group = NULL; | ||
183 | |||
184 | BUG_ON(!mutex_is_locked(&fsnotify_grp_mutex)); | ||
185 | |||
186 | list_for_each_entry_rcu(group_iter, &fsnotify_groups, group_list) { | ||
187 | if (group_iter->group_num == group_num) { | ||
188 | if ((group_iter->mask == mask) && | ||
189 | (group_iter->ops == ops)) { | ||
190 | fsnotify_get_group(group_iter); | ||
191 | group = group_iter; | ||
192 | } else | ||
193 | group = ERR_PTR(-EEXIST); | ||
194 | } | ||
195 | } | ||
196 | return group; | ||
197 | } | ||
198 | |||
199 | /* | ||
200 | * Either finds an existing group which matches the group_num, mask, and ops or | 165 | * Either finds an existing group which matches the group_num, mask, and ops or |
201 | * creates a new group and adds it to the global group list. In either case we | 166 | * creates a new group and adds it to the global group list. In either case we |
202 | * take a reference for the group returned. | 167 | * take a reference for the group returned. |
203 | */ | 168 | */ |
204 | struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask, | 169 | struct fsnotify_group *fsnotify_obtain_group(__u32 mask, |
205 | const struct fsnotify_ops *ops) | 170 | const struct fsnotify_ops *ops) |
206 | { | 171 | { |
207 | struct fsnotify_group *group, *tgroup; | 172 | struct fsnotify_group *group; |
208 | 173 | ||
209 | /* very low use, simpler locking if we just always alloc */ | 174 | /* very low use, simpler locking if we just always alloc */ |
210 | group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL); | 175 | group = kzalloc(sizeof(struct fsnotify_group), GFP_KERNEL); |
@@ -214,7 +179,6 @@ struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask, | |||
214 | atomic_set(&group->refcnt, 1); | 179 | atomic_set(&group->refcnt, 1); |
215 | 180 | ||
216 | group->on_group_list = 0; | 181 | group->on_group_list = 0; |
217 | group->group_num = group_num; | ||
218 | group->mask = mask; | 182 | group->mask = mask; |
219 | 183 | ||
220 | mutex_init(&group->notification_mutex); | 184 | mutex_init(&group->notification_mutex); |
@@ -230,14 +194,6 @@ struct fsnotify_group *fsnotify_obtain_group(unsigned int group_num, __u32 mask, | |||
230 | group->ops = ops; | 194 | group->ops = ops; |
231 | 195 | ||
232 | mutex_lock(&fsnotify_grp_mutex); | 196 | mutex_lock(&fsnotify_grp_mutex); |
233 | tgroup = fsnotify_find_group(group_num, mask, ops); | ||
234 | if (tgroup) { | ||
235 | /* group already exists */ | ||
236 | mutex_unlock(&fsnotify_grp_mutex); | ||
237 | /* destroy the new one we made */ | ||
238 | fsnotify_put_group(group); | ||
239 | return tgroup; | ||
240 | } | ||
241 | 197 | ||
242 | /* group not found, add a new one */ | 198 | /* group not found, add a new one */ |
243 | list_add_rcu(&group->group_list, &fsnotify_groups); | 199 | list_add_rcu(&group->group_list, &fsnotify_groups); |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index cbe16df326f8..cae317f5bd9d 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -51,12 +51,6 @@ int inotify_max_user_watches __read_mostly; | |||
51 | static struct kmem_cache *inotify_inode_mark_cachep __read_mostly; | 51 | static struct kmem_cache *inotify_inode_mark_cachep __read_mostly; |
52 | struct kmem_cache *event_priv_cachep __read_mostly; | 52 | struct kmem_cache *event_priv_cachep __read_mostly; |
53 | 53 | ||
54 | /* | ||
55 | * When inotify registers a new group it increments this and uses that | ||
56 | * value as an offset to set the fsnotify group "name" and priority. | ||
57 | */ | ||
58 | static atomic_t inotify_grp_num; | ||
59 | |||
60 | #ifdef CONFIG_SYSCTL | 54 | #ifdef CONFIG_SYSCTL |
61 | 55 | ||
62 | #include <linux/sysctl.h> | 56 | #include <linux/sysctl.h> |
@@ -700,11 +694,8 @@ retry: | |||
700 | static struct fsnotify_group *inotify_new_group(struct user_struct *user, unsigned int max_events) | 694 | static struct fsnotify_group *inotify_new_group(struct user_struct *user, unsigned int max_events) |
701 | { | 695 | { |
702 | struct fsnotify_group *group; | 696 | struct fsnotify_group *group; |
703 | unsigned int grp_num; | ||
704 | 697 | ||
705 | /* fsnotify_obtain_group took a reference to group, we put this when we kill the file in the end */ | 698 | group = fsnotify_obtain_group(0, &inotify_fsnotify_ops); |
706 | grp_num = (INOTIFY_GROUP_NUM - atomic_inc_return(&inotify_grp_num)); | ||
707 | group = fsnotify_obtain_group(grp_num, 0, &inotify_fsnotify_ops); | ||
708 | if (IS_ERR(group)) | 699 | if (IS_ERR(group)) |
709 | return group; | 700 | return group; |
710 | 701 | ||