From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [Bugme-new] [Bug 12754] New: inotify doesn't free memory allocated to watches Date: Tue, 24 Feb 2009 15:40:23 -0800 Message-ID: <20090224154023.c003c35c.akpm@linux-foundation.org> References: <20090224130523.f6c4c450.akpm@linux-foundation.org> <20090224213800.GI28946@ZenIV.linux.org.uk> <20090224232337.GJ28946@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: russell@rickstewart.com, bugme-daemon@bugzilla.kernel.org, linux-fsdevel@vger.kernel.org, john@johnmccutchan.com, rlove@rlove.org To: Al Viro Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:39253 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754156AbZBXXkd (ORCPT ); Tue, 24 Feb 2009 18:40:33 -0500 In-Reply-To: <20090224232337.GJ28946@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, 24 Feb 2009 23:23:37 +0000 Al Viro wrote: > On Tue, Feb 24, 2009 at 09:38:00PM +0000, Al Viro wrote: > > On Tue, Feb 24, 2009 at 01:05:23PM -0800, Andrew Morton wrote: > > > > > > We have webcams that take photos every 5 minutes. I run a daemon > > > > that detects the creation of a new webcam photo then makes a thumbnail > > > > of it. Eventually it stopped working. I figured out that I could > > > > not create new watches: inotify_add_watch reported "No space left on device". > > > > I create all the watches with the ONESHOT parameter so they are deleted > > > > as soon as they are triggered. When I make it display the watch number > > > > it's always 3. A new watch is added only when the old watch has been > > > > triggered. inotify isn't recovering the memory from deleted watches. > > IN_ONESHOT means that they will be *removed* as they are triggered. You still > have to call put_inotify_watch() from your ->handle_event() when you get > IN_ONESHOT in the mask. IOW, check your ->handle_event(); unless it does > that put_inotify_watch(), you are leaking. y:/usr/src/linux-2.6.29-rc6> grep -rl inotify_operations . ./Documentation/filesystems/inotify.txt ./kernel/audit.c ./kernel/audit_tree.c ./fs/notify/inotify/inotify_user.c ./fs/notify/inotify/inotify.c ./include/linux/inotify.h I assume it's inotify_dev_queue_event()? if (mask & IN_IGNORED || w->mask & IN_ONESHOT) put_inotify_watch(w); /* final put */