fanotify: merge duplicate events on parent and child
authorAmir Goldstein <amir73il@gmail.com>
Thu, 19 Mar 2020 15:10:16 +0000 (17:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 May 2020 05:58:30 +0000 (07:58 +0200)
commit9bd5a84ceba320abe25f752a0bd390e3308f7b2c
treeccbc5e76f695d4309f3d2e20213dab508f0d90f1
parent4638e0ff0fa4bc88330f28e756bbcce114afe281
fanotify: merge duplicate events on parent and child

[ Upstream commit f367a62a7cad2447d835a9f14fc63997a9137246 ]

With inotify, when a watch is set on a directory and on its child, an
event on the child is reported twice, once with wd of the parent watch
and once with wd of the child watch without the filename.

With fanotify, when a watch is set on a directory and on its child, an
event on the child is reported twice, but it has the exact same
information - either an open file descriptor of the child or an encoded
fid of the child.

The reason that the two identical events are not merged is because the
object id used for merging events in the queue is the child inode in one
event and parent inode in the other.

For events with path or dentry data, use the victim inode instead of the
watched inode as the object id for event merging, so that the event
reported on parent will be merged with the event reported on the child.

Link: https://lore.kernel.org/r/20200319151022.31456-9-amir73il@gmail.com
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/notify/fanotify/fanotify.c