Skip to content

Commit 843c482

Browse files
committed
Merge: fsnotify: fix sending inotify event with unexpected filename
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/56 JIRA: https://issues.redhat.com/browse/RHEL-68847 Added upstream patch for a hang when using "tail -f" on a file under certain conditions. Signed-off-by: Ian Kent <ikent@redhat.com> Approved-by: Carlos Maiolino <cmaiolino@redhat.com> Approved-by: Paulo Alcantara <paalcant@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents e33f04f + 0bafcea commit 843c482

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

fs/notify/fsnotify.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,19 @@ static int fsnotify_handle_event(struct fsnotify_group *group, __u32 mask,
333333
if (!inode_mark)
334334
return 0;
335335

336-
if (mask & FS_EVENT_ON_CHILD) {
337-
/*
338-
* Some events can be sent on both parent dir and child marks
339-
* (e.g. FS_ATTRIB). If both parent dir and child are
340-
* watching, report the event once to parent dir with name (if
341-
* interested) and once to child without name (if interested).
342-
* The child watcher is expecting an event without a file name
343-
* and without the FS_EVENT_ON_CHILD flag.
344-
*/
345-
mask &= ~FS_EVENT_ON_CHILD;
336+
/*
337+
* Some events can be sent on both parent dir and child marks (e.g.
338+
* FS_ATTRIB). If both parent dir and child are watching, report the
339+
* event once to parent dir with name (if interested) and once to child
340+
* without name (if interested).
341+
*
342+
* In any case regardless whether the parent is watching or not, the
343+
* child watcher is expecting an event without the FS_EVENT_ON_CHILD
344+
* flag. The file name is expected if and only if this is a directory
345+
* event.
346+
*/
347+
mask &= ~FS_EVENT_ON_CHILD;
348+
if (!(mask & ALL_FSNOTIFY_DIRENT_EVENTS)) {
346349
dir = NULL;
347350
name = NULL;
348351
}

0 commit comments

Comments
 (0)