inotify: allow users to request not to recieve events on unlinked children
An inotify watch on a directory will send events for children even if those children have been unlinked. This patch add a new inotify flag IN_EXCL_UNLINK which allows a watch to specificy they don't care about unlinked children. This should fix performance problems seen by tasks which add a watch to /tmp and then are overrun with events when other processes are reading and writing to unlinked files they created in /tmp. https://bugzilla.kernel.org/show_bug.cgi?id=16296 Requested-by: Matthias Clasen <mclasen@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
* General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/dcache.h> /* d_unlinked */
|
||||
#include <linux/fs.h> /* struct inode */
|
||||
#include <linux/fsnotify_backend.h>
|
||||
#include <linux/inotify.h>
|
||||
@@ -157,6 +158,14 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
|
||||
mask = (mask & ~FS_EVENT_ON_CHILD);
|
||||
send = (fsn_mark->mask & mask);
|
||||
|
||||
if (send && (fsn_mark->mask & FS_EXCL_UNLINK) &&
|
||||
(data_type == FSNOTIFY_EVENT_PATH)) {
|
||||
struct path *path = data;
|
||||
|
||||
if (d_unlinked(path->dentry))
|
||||
send = false;
|
||||
}
|
||||
|
||||
/* find took a reference */
|
||||
fsnotify_put_mark(fsn_mark);
|
||||
|
||||
|
Reference in New Issue
Block a user