fsnotify: send event to parent and child with single callback
authorAmir Goldstein <amir73il@gmail.com>
Thu, 16 Jul 2020 08:42:22 +0000 (11:42 +0300)
committerJan Kara <jack@suse.cz>
Mon, 27 Jul 2020 19:24:52 +0000 (21:24 +0200)
commit497b0c5a7c0688c1b100a9c2e267337f677c198e
tree2ed4f29d98b1a8b99ebea359b7980645a96fa6d1
parentc8f3446c66d810e21af61cf889e7b0e3bc921b9d
fsnotify: send event to parent and child with single callback

Instead of calling fsnotify() twice, once with parent inode and once
with child inode, if event should be sent to parent inode, send it
with both parent and child inodes marks in object type iterator and call
the backend handle_event() callback only once.

The parent inode is assigned to the standard "inode" iterator type and
the child inode is assigned to the special "child" iterator type.

In that case, the bit FS_EVENT_ON_CHILD will be set in the event mask,
the dir argument to handle_event will be the parent inode, the file_name
argument to handle_event is non NULL and refers to the name of the child
and the child inode can be accessed with fsnotify_data_inode().

This will allow fanotify to make decisions based on child or parent's
ignored mask.  For example, when a parent is interested in a specific
event on its children, but a specific child wishes to ignore this event,
the event will not be reported.  This is not what happens with current
code, but according to man page, it is the expected behavior.

Link: https://lore.kernel.org/r/20200716084230.30611-15-amir73il@gmail.com
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/kernfs/file.c
fs/notify/fanotify/fanotify.c
fs/notify/fsnotify.c