aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/inotify/inotify_user.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-12-17 20:27:10 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:20 -0400
commit7050c48826d5adb2210bddfb6a67aa13bbe984ed (patch)
tree21a2f73a9953f1125aea81e02ef547afbe33661a /fs/notify/inotify/inotify_user.c
parent6f3a539e3bd8ed2eafa532443723d56896153a00 (diff)
inotify: do not reuse watch descriptors
Prior to 2.6.31 inotify would not reuse watch descriptors until all of them had been used at least once. After the rewrite inotify would reuse watch descriptors. The selinux utility 'restorecond' was found to have problems when watch descriptors were reused. This patch reverts to the pre inotify rewrite behavior to not reuse watch descriptors. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/inotify/inotify_user.c')
-rw-r--r--fs/notify/inotify/inotify_user.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index a0e40f7c9781..ce21ebaee89e 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -358,7 +358,7 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns
358} 358}
359 359
360static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, 360static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
361 int last_wd, 361 int *last_wd,
362 struct inotify_inode_mark_entry *ientry) 362 struct inotify_inode_mark_entry *ientry)
363{ 363{
364 int ret; 364 int ret;
@@ -368,11 +368,13 @@ static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
368 return -ENOMEM; 368 return -ENOMEM;
369 369
370 spin_lock(idr_lock); 370 spin_lock(idr_lock);
371 ret = idr_get_new_above(idr, ientry, last_wd + 1, 371 ret = idr_get_new_above(idr, ientry, *last_wd + 1,
372 &ientry->wd); 372 &ientry->wd);
373 /* we added the mark to the idr, take a reference */ 373 /* we added the mark to the idr, take a reference */
374 if (!ret) 374 if (!ret) {
375 fsnotify_get_mark(&ientry->fsn_entry); 375 fsnotify_get_mark(&ientry->fsn_entry);
376 *last_wd = ientry->wd;
377 }
376 spin_unlock(idr_lock); 378 spin_unlock(idr_lock);
377 } while (ret == -EAGAIN); 379 } while (ret == -EAGAIN);
378 380
@@ -647,7 +649,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
647 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) 649 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches)
648 goto out_err; 650 goto out_err;
649 651
650 ret = inotify_add_to_idr(idr, idr_lock, group->inotify_data.last_wd, 652 ret = inotify_add_to_idr(idr, idr_lock, &group->inotify_data.last_wd,
651 tmp_ientry); 653 tmp_ientry);
652 if (ret) 654 if (ret)
653 goto out_err; 655 goto out_err;
@@ -660,9 +662,6 @@ static int inotify_new_watch(struct fsnotify_group *group,
660 goto out_err; 662 goto out_err;
661 } 663 }
662 664
663 /* update the idr hint, who cares about races, it's just a hint */
664 group->inotify_data.last_wd = tmp_ientry->wd;
665
666 /* increment the number of watches the user has */ 665 /* increment the number of watches the user has */
667 atomic_inc(&group->inotify_data.user->inotify_watches); 666 atomic_inc(&group->inotify_data.user->inotify_watches);
668 667