Skip to content

Commit

Permalink
inotify: convert inotify_add_to_idr() to use idr_alloc_cyclic()
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: John McCutchan <john@johnmccutchan.com>
Cc: Robert Love <rlove@rlove.org>
Cc: Eric Paris <eparis@parisplace.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jeff Layton authored and Linus Torvalds committed Apr 30, 2013
1 parent 398c33a commit a66c04b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
8 changes: 2 additions & 6 deletions fs/notify/inotify/inotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,17 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns
}

static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
int *last_wd,
struct inotify_inode_mark *i_mark)
{
int ret;

idr_preload(GFP_KERNEL);
spin_lock(idr_lock);

ret = idr_alloc(idr, i_mark, *last_wd + 1, 0, GFP_NOWAIT);
ret = idr_alloc_cyclic(idr, i_mark, 1, 0, GFP_NOWAIT);
if (ret >= 0) {
/* we added the mark to the idr, take a reference */
i_mark->wd = ret;
*last_wd = i_mark->wd;
fsnotify_get_mark(&i_mark->fsn_mark);
}

Expand Down Expand Up @@ -638,8 +636,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches)
goto out_err;

ret = inotify_add_to_idr(idr, idr_lock, &group->inotify_data.last_wd,
tmp_i_mark);
ret = inotify_add_to_idr(idr, idr_lock, tmp_i_mark);
if (ret)
goto out_err;

Expand Down Expand Up @@ -697,7 +694,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)

spin_lock_init(&group->inotify_data.idr_lock);
idr_init(&group->inotify_data.idr);
group->inotify_data.last_wd = 0;
group->inotify_data.user = get_current_user();

if (atomic_inc_return(&group->inotify_data.user->inotify_devs) >
Expand Down
1 change: 0 additions & 1 deletion include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ struct fsnotify_group {
struct inotify_group_private_data {
spinlock_t idr_lock;
struct idr idr;
u32 last_wd;
struct user_struct *user;
} inotify_data;
#endif
Expand Down

0 comments on commit a66c04b

Please sign in to comment.