fsnotify usually calls fanotify_handle_event() once for watching parent and once for watching child, even though both events are exactly the same and will most likely get merged before user reads them. Add support for handling both event flavors with a single callback instead of two callbacks when marks iterator contains both inode and child entries. fanotify will queue a single event in that case and the unneeded merge will be avoided. Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- fs/notify/fanotify/fanotify.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index c107974d6830..1ec760960c93 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -263,8 +263,11 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group, /* * If the event is for a child and this mark doesn't care about * events on a child, don't send it! + * The special object type "child" always cares about events on + * a child, because it refers to the child inode itself. */ if (event_mask & FS_EVENT_ON_CHILD && + type != FSNOTIFY_OBJ_TYPE_CHILD && (type != FSNOTIFY_OBJ_TYPE_INODE || !(mark->mask & FS_EVENT_ON_CHILD))) continue; -- 2.17.1