Re: inotify_add_watch() returning ENOSPC in 2.6.24 [watch descriptor leak?]

From: Ulisses Furquim
Date: Thu Feb 07 2008 - 13:54:36 EST


Hi,

On Feb 6, 2008 4:40 PM, Clem Taylor <clem.taylor@xxxxxxxxx> 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: patch
Description: Binary data