mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] inotify: fix the running away counter of user watches
@ 2009-07-27 17:25 Alex Riesen
  2009-07-28  6:08 ` Alex Riesen
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Riesen @ 2009-07-27 17:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: fs_other, Russell Bell, Andrew Morton, Al Viro, josef,
	Eric Paris, Robert Love, John McCutchan

The counter of userspace inotify watches is incremented when a watch is
added, but was never decremented. This patch uses the fsnotify callback
(freeing_marks, which in turn calls inotify_ignored_and_remove_idr of
inotify userspace interface) called when an fsnotify mark is removed.

The bug has been reported in

    http://bugzilla.kernel.org/show_bug.cgi?id=12754

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Sorry for long Cc:, I'm a little confused about "fs_other@" (and the
list of participants) in the bug report.

The patch works in my limited testing. I just did:

    # echo 10 >/proc/sys/fs/inotify/max_user_watches
    # inotify-watch -r /lib # to max the counter
    Ctrl-C
    # inotify-watch /bin/true # must work

in a clean environment (init=/bin/bash).

But I don't know whether it safe to access the counter in this
callback, nor am I sure the patch is enough.

 fs/notify/inotify/inotify_user.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index ff27a29..c2d94df 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -404,6 +404,7 @@ skip_send_ignore:
 
 	/* removed from idr, drop that reference */
 	fsnotify_put_mark(entry);
+	atomic_dec(&group->inotify_data.user->inotify_watches);
 }
 
 /* ding dong the mark is dead */
-- 
1.6.4.rc3.56.g32a7



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-28  6:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-27 17:25 [PATCH] inotify: fix the running away counter of user watches Alex Riesen
2009-07-28  6:08 ` Alex Riesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®