LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Ulisses Furquim" <ulissesf@gmail.com>
To: "Clem Taylor" <clem.taylor@gmail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, "Amy Griffis" <amy.griffis@hp.com>
Subject: Re: inotify_add_watch() returning ENOSPC in 2.6.24 [watch descriptor leak?]
Date: Thu, 7 Feb 2008 15:54:12 -0300	[thread overview]
Message-ID: <d23110170802071054s6fef54c9q182a9ed2e180052@mail.gmail.com> (raw)
In-Reply-To: <ecb4efd10802061140g929e699y8d79f1317c30478d@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

Hi,

On Feb 6, 2008 4:40 PM, Clem Taylor <clem.taylor@gmail.com> wrote:
> I also tested on a 2.6.20 x86 desktop machine. It took ~8k iterations
> to fail, which matched max_user_watches. Once the program fails, it
> will fail right away if it is re-run.

Yeah, I had the same results, and it fails afterwards because it
reaches the maximum number of watches per user.

> Attached is a simple example that shows off the problem. On a system
> with a problem, it will only run for about
> fs.inotify.max_user_watches iterations. If everything is working, it
> should run forever.

Ok, I had a go with it and found the problem. We weren't releasing
one-shot watches because the test for them was wrong. We're using the
event's mask to test for one-shot watches when we should've been using
the watch's mask.

Patch against latest Linus git repo attached.

Regards,

-- Ulisses

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 1033 bytes --]

From 6fcf3bb6227a4949aeee2741dc73eb3c55a3bfef Mon Sep 17 00:00:00 2001
From: Ulisses Furquim <ulissesf@gmail.com>
Date: Thu, 7 Feb 2008 15:19:19 -0300
Subject: [PATCH] inotify: fix check for one-shot watches before destroying them

As the IN_ONESHOT bit is never set when an event is sent we must check it
in the watch's mask and not in the event's mask.

Signed-off-by: Ulisses Furquim <ulissesf@gmail.com>
---
 fs/inotify_user.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index a336c97..3ab09a6 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -283,7 +283,7 @@ static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask,
 	/* we can safely put the watch as we don't reference it while
 	 * generating the event
 	 */
-	if (mask & IN_IGNORED || mask & IN_ONESHOT)
+	if (mask & IN_IGNORED || w->mask & IN_ONESHOT)
 		put_inotify_watch(w); /* final put */
 
 	/* coalescing: drop this event if it is a dupe of the previous */
-- 
1.5.4


  parent reply	other threads:[~2008-02-07 18:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06  1:49 Clem Taylor
2008-02-06  9:51 ` Andrew Morton
2008-02-06 19:40   ` Clem Taylor
2008-02-07  3:04     ` Amy Griffis
2008-02-07 18:54     ` Ulisses Furquim [this message]
2008-02-07 21:24       ` Clem Taylor
2008-02-07 21:44         ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d23110170802071054s6fef54c9q182a9ed2e180052@mail.gmail.com \
    --to=ulissesf@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=amy.griffis@hp.com \
    --cc=clem.taylor@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: inotify_add_watch() returning ENOSPC in 2.6.24 [watch descriptor leak?]' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).