[PATCH 3/5] fsnotify: have fsnotify() take a qstr instead of a string

Jeff Layton
2019-04-26T18:29:05Z

This means that kernfs_notify_workfn has to grow a strlen as well.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/kernfs/file.c | 6 ++++--
fs/notify/fsnotify.c | 8 ++++----
include/linux/fsnotify.h | 10 +++++-----
include/linux/fsnotify_backend.h | 4 ++--
4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index ae948aaa4c53..a43283c515f4 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -885,6 +885,8 @@ static void kernfs_notify_workfn(struct work_struct *work)
list_for_each_entry(info, &kernfs_root(kn)->supers, node) {
struct kernfs_node *parent;
struct inode *inode;
+ const struct qstr name = { .name = kn->name,
+ .len = strlen(kn->name) };

/*
* We want fsnotify_modify() on @kn but as the
@@ -903,7 +905,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
p_inode = ilookup(info->sb, parent->id.ino);
if (p_inode) {
fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
- inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
+ inode, FSNOTIFY_EVENT_INODE, &name, 0);
iput(p_inode);
}

@@ -911,7 +913,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
}

fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
- kn->name, 0);
+ &name, 0);
iput(inode);
}

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index fb22f76329ae..9cbb5ae11d2f 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -179,10 +179,10 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
take_dentry_name_snapshot(&name, dentry);
if (path)
ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
- name.name.name, 0);
+ &name.name, 0);
else
ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
- name.name.name, 0);
+ &name.name, 0);
release_dentry_name_snapshot(&name);
}

@@ -325,7 +325,7 @@ static void fsnotify_iter_next(struct fsnotify_iter_info *iter_info)
* notification event in whatever means they feel necessary.
*/
int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
- const unsigned char *file_name, u32 cookie)
+ const struct qstr *file_name, u32 cookie)
{
struct fsnotify_iter_info iter_info = {};
struct super_block *sb = to_tell->i_sb;
@@ -379,7 +379,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
*/
while (fsnotify_iter_select_report_types(&iter_info)) {
ret = send_to_group(to_tell, mask, data, data_is, cookie,
- file_name, &iter_info);
+ file_name->name, &iter_info);

if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS))
goto out;
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 2de90a7e388b..66e322df78a3 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -27,7 +27,7 @@ static inline int fsnotify_dirent(struct inode *dir, struct dentry *dentry,
__u32 mask)
{
return fsnotify(dir, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
- dentry->d_name.name, 0);
+ &dentry->d_name, 0);
}

/* Notify this dentry's parent about a child's events. */
@@ -122,9 +122,9 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
}

fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE,
- old_name->name, fs_cookie);
+ old_name, fs_cookie);
fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE,
- moved->d_name.name, fs_cookie);
+ &moved->d_name, fs_cookie);

if (target)
fsnotify_link_count(target);
@@ -177,7 +177,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
take_dentry_name_snapshot(&name, dentry);

fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
- name.name.name, 0);
+ &name.name, 0);

release_dentry_name_snapshot(&name);
dput(parent);
@@ -217,7 +217,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
fsnotify_link_count(inode);
audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE);

- fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0);
+ fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, &new_dentry->d_name, 0);
}

/*
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index dfc28fcb4de8..7eb7821766d5 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -350,7 +350,7 @@ struct fsnotify_mark {

/* main fsnotify call to send events */
extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
- const unsigned char *name, u32 cookie);
+ const struct qstr *name, u32 cookie);
extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
extern void __fsnotify_inode_delete(struct inode *inode);
extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
@@ -505,7 +505,7 @@ 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 unsigned char *name, u32 cookie)
+ const struct qstr *name, u32 cookie)
{
return 0;
}
--
2.20.1