diff options
author | Jeff Layton <jlayton@redhat.com> | 2013-04-29 19:21:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:41 -0400 |
commit | a66c04b4534f9b25e1241dff9a9d94dff9fd66f8 (patch) | |
tree | ce3b9b76dc749a7857715813a96a3533f44e2f1d /fs | |
parent | 398c33aaa4edb05339fed3720847ea6a06987ff1 (diff) |
inotify: convert inotify_add_to_idr() to use idr_alloc_cyclic()
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index e0f7c1241a6a..8562bd3af947 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -359,7 +359,6 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns | |||
359 | } | 359 | } |
360 | 360 | ||
361 | static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, | 361 | static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, |
362 | int *last_wd, | ||
363 | struct inotify_inode_mark *i_mark) | 362 | struct inotify_inode_mark *i_mark) |
364 | { | 363 | { |
365 | int ret; | 364 | int ret; |
@@ -367,11 +366,10 @@ static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, | |||
367 | idr_preload(GFP_KERNEL); | 366 | idr_preload(GFP_KERNEL); |
368 | spin_lock(idr_lock); | 367 | spin_lock(idr_lock); |
369 | 368 | ||
370 | ret = idr_alloc(idr, i_mark, *last_wd + 1, 0, GFP_NOWAIT); | 369 | ret = idr_alloc_cyclic(idr, i_mark, 1, 0, GFP_NOWAIT); |
371 | if (ret >= 0) { | 370 | if (ret >= 0) { |
372 | /* we added the mark to the idr, take a reference */ | 371 | /* we added the mark to the idr, take a reference */ |
373 | i_mark->wd = ret; | 372 | i_mark->wd = ret; |
374 | *last_wd = i_mark->wd; | ||
375 | fsnotify_get_mark(&i_mark->fsn_mark); | 373 | fsnotify_get_mark(&i_mark->fsn_mark); |
376 | } | 374 | } |
377 | 375 | ||
@@ -638,8 +636,7 @@ static int inotify_new_watch(struct fsnotify_group *group, | |||
638 | if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) | 636 | if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) |
639 | goto out_err; | 637 | goto out_err; |
640 | 638 | ||
641 | ret = inotify_add_to_idr(idr, idr_lock, &group->inotify_data.last_wd, | 639 | ret = inotify_add_to_idr(idr, idr_lock, tmp_i_mark); |
642 | tmp_i_mark); | ||
643 | if (ret) | 640 | if (ret) |
644 | goto out_err; | 641 | goto out_err; |
645 | 642 | ||
@@ -697,7 +694,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events) | |||
697 | 694 | ||
698 | spin_lock_init(&group->inotify_data.idr_lock); | 695 | spin_lock_init(&group->inotify_data.idr_lock); |
699 | idr_init(&group->inotify_data.idr); | 696 | idr_init(&group->inotify_data.idr); |
700 | group->inotify_data.last_wd = 0; | ||
701 | group->inotify_data.user = get_current_user(); | 697 | group->inotify_data.user = get_current_user(); |
702 | 698 | ||
703 | if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > | 699 | if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > |