Skip to content

Commit

Permalink
fsnotify: simplify arguments passing to fsnotify_parent()
Browse files Browse the repository at this point in the history
Instead of passing both dentry and path and having to figure out which
one to use, pass data/data_type to simplify the code.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Amir Goldstein <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
amir73il authored and jankara committed Mar 23, 2020
1 parent aa93bdc commit 017de65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
15 changes: 4 additions & 11 deletions fs/notify/fsnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,13 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
}

/* Notify this dentry's parent about a child's events. */
int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
int data_type)
{
struct dentry *parent;
struct inode *p_inode;
int ret = 0;

if (!dentry)
dentry = path->dentry;

if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
return 0;

Expand All @@ -168,20 +166,15 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
mask |= FS_EVENT_ON_CHILD;

take_dentry_name_snapshot(&name, dentry);
if (path)
ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
&name.name, 0);
else
ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
&name.name, 0);
ret = fsnotify(p_inode, mask, data, data_type, &name.name, 0);
release_dentry_name_snapshot(&name);
}

dput(parent);

return ret;
}
EXPORT_SYMBOL_GPL(__fsnotify_parent);
EXPORT_SYMBOL_GPL(fsnotify_parent);

static int send_to_group(struct inode *to_tell,
__u32 mask, const void *data,
Expand Down
14 changes: 2 additions & 12 deletions include/linux/fsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
fsnotify_name(dir, mask, d_inode(dentry), &dentry->d_name, 0);
}

/* Notify this dentry's parent about a child's events. */
static inline int fsnotify_parent(const struct path *path,
struct dentry *dentry, __u32 mask)
{
if (!dentry)
dentry = path->dentry;

return __fsnotify_parent(path, dentry, mask);
}

/*
* Simple wrappers to consolidate calls fsnotify_parent()/fsnotify() when
* an event is on a file/dentry.
Expand All @@ -59,7 +49,7 @@ static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
if (S_ISDIR(inode->i_mode))
mask |= FS_ISDIR;

fsnotify_parent(NULL, dentry, mask);
fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
}

Expand All @@ -75,7 +65,7 @@ static inline int fsnotify_file(struct file *file, __u32 mask)
if (S_ISDIR(inode->i_mode))
mask |= FS_ISDIR;

ret = fsnotify_parent(path, NULL, mask);
ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
if (ret)
return ret;

Expand Down
14 changes: 8 additions & 6 deletions include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ struct fsnotify_mark {
/* called from the vfs helpers */

/* main fsnotify call to send events */
extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
const struct qstr *name, u32 cookie);
extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
int data_type, const struct qstr *name, u32 cookie);
extern int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
int data_type);
extern void __fsnotify_inode_delete(struct inode *inode);
extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
extern void fsnotify_sb_delete(struct super_block *sb);
Expand Down Expand Up @@ -533,13 +534,14 @@ static inline void fsnotify_init_event(struct fsnotify_event *event,

#else

static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
const struct qstr *name, u32 cookie)
static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
int data_type, const struct qstr *name, u32 cookie)
{
return 0;
}

static inline int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
const void *data, int data_type)
{
return 0;
}
Expand Down

0 comments on commit 017de65

Please sign in to comment.