Skip to content

Commit 957f7b4

Browse files
amir73iljankara
authored andcommitted
inotify: do not set FS_EVENT_ON_CHILD in non-dir mark mask
FS_EVENT_ON_CHILD has currently no meaning for non-dir inode marks. In the following patches we want to use that bit to mean that mark's notification group cares about parent and name information. So stop setting FS_EVENT_ON_CHILD for non-dir marks. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 40a100d commit 957f7b4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/notify/inotify/inotify_user.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,17 @@ struct ctl_table inotify_table[] = {
7575
};
7676
#endif /* CONFIG_SYSCTL */
7777

78-
static inline __u32 inotify_arg_to_mask(u32 arg)
78+
static inline __u32 inotify_arg_to_mask(struct inode *inode, u32 arg)
7979
{
8080
__u32 mask;
8181

8282
/*
83-
* everything should accept their own ignored, cares about children,
84-
* and should receive events when the inode is unmounted
83+
* Everything should accept their own ignored and should receive events
84+
* when the inode is unmounted. All directories care about children.
8585
*/
86-
mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD | FS_UNMOUNT);
86+
mask = (FS_IN_IGNORED | FS_UNMOUNT);
87+
if (S_ISDIR(inode->i_mode))
88+
mask |= FS_EVENT_ON_CHILD;
8789

8890
/* mask off the flags used to open the fd */
8991
mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK));
@@ -512,7 +514,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
512514
int create = (arg & IN_MASK_CREATE);
513515
int ret;
514516

515-
mask = inotify_arg_to_mask(arg);
517+
mask = inotify_arg_to_mask(inode, arg);
516518

517519
fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
518520
if (!fsn_mark)
@@ -565,7 +567,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
565567
struct idr *idr = &group->inotify_data.idr;
566568
spinlock_t *idr_lock = &group->inotify_data.idr_lock;
567569

568-
mask = inotify_arg_to_mask(arg);
570+
mask = inotify_arg_to_mask(inode, arg);
569571

570572
tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
571573
if (unlikely(!tmp_i_mark))

0 commit comments

Comments
 (0)