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



I'm trying to move a MIPS based embedded system from 2.6.16.16 to
2.6.24. Most things seem to be working, but I'm having troubles with
inotify. The code is using inotify to detect a file written to /tmp
(tmpfs). The writer creates a file with a temporary name and then
rename()s the tmp file over the file I'm monitoring.

With 2.6.16.16, everything works fine, but with 2.6.24, the inotify
process runs for a while (~100 events) and then inotify_add_watch()
returns ENOSPC. Once this happens, I can't add new watches, even if I
kill the process and restart it. fs.inotify.max_user_instances and
fs.inotify.max_user_watches are both 128, so I'd imagine I'm hitting
this limit. For some reason the watches aren't getting cleaned up
(even after the process is killed).

In a loop, the code is doing:
wd = inotify_add_watch(fd, file, IN_CLOSE_WRITE|IN_DELETE_SELF|IN_ONESHOT);
blocking read on notify fd

Has something changed in the inotify() API since 2.6.16.16, or could
this be a leak?

--Clem
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [RFC][PATCH] inotify 0.9.4
    ... Here is release 0.9.4 of inotify. ... -fix for more than 1024 watches (rml) ... So assuming a device has 8192 watches, ... Each inotify watch pins the inode of a directory/file in memory, ...
    (Linux-Kernel)
  • Re: [patch] inotify.
    ... > Below find an updated inotify, with a doubt the world's great inotify ... I wonder if its worth walking the watches as they're added and removed ... is watching the inode rather than queueing events on all the devices. ... to roll some compound rename event. ...
    (Linux-Kernel)
  • [PATCH 0/3] Inotify cleanup and idr race
    ... the modification of old watches, thus making it easier to verify they are ... unrecoverable situation) and it should fix a race in idr removal which could ... If anyone is able to reproduce inotify or fsnotify problems with -rc7 + these ... fix locking around inotify watching in the idr ...
    (Linux-Kernel)
  • Re: v2.6.31-rc6 inotify not reporting deleted files
    ... Eric Paris writes: ... uses inotify and watches a file and takes action when that file has been ... I will go verify I can cook up a reproducer, ...
    (Linux-Kernel)
  • Re: pyinotify issue
    ... Error: cannot watch. ... my kernel version was too old and did not allow inotify to be ... Then pyinotify worked once and failed for all consecutive retries. ... pyinotify still seems to max out my number of user watches... ...
    (comp.lang.python)