Note that in fnsotify_move() and fsnotify_link() we are guaranteed that dentry->d_name won't change during the fsnotify() evaluation (by having the parent directory locked exclusive), so we don't need to fetch dentry->d_name.name in the callers. In fsnotify_dirent() the same stability of dentry->d_name is also true, but it's a bit more convoluted - there is one callchain (devpts_pty_new() -> fsnotify_create() -> fsnotify_dirent()) where the parent is _not_ locked, but on devpts ->d_name of everything is unchanging; it has neither explicit nor implicit renames.
Unified · Split
| @@ -885,6 +885,7 @@ repeat: · 884 unmodified lines | |||
| 885 | list_for_each_entry(info, &kernfs_root(kn)->supers, node) { | 885 | list_for_each_entry(info, &kernfs_root(kn)->supers, node) { |
| 886 | struct kernfs_node *parent; | 886 | struct kernfs_node *parent; |
| 887 | struct inode *inode; | 887 | struct inode *inode; |
| 888 | struct qstr name; | ||
| 888 | 889 | ||
| 889 | /* | 890 | /* |
| 890 | * We want fsnotify_modify() on @kn but as the | 891 | * We want fsnotify_modify() on @kn but as the |
| @@ -896,6 +897,7 @@ repeat: · 5 unmodified lines | |||
| 896 | if (!inode) | 897 | if (!inode) |
| 897 | continue; | 898 | continue; |
| 898 | 899 | ||
| 900 | name = (struct qstr)QSTR_INIT(kn->name, strlen(kn->name)); | ||
| 899 | parent = kernfs_get_parent(kn); | 901 | parent = kernfs_get_parent(kn); |
| 900 | if (parent) { | 902 | if (parent) { |
| 901 | struct inode *p_inode; | 903 | struct inode *p_inode; |
| @@ -903,7 +905,7 @@ repeat: · 1 unmodified line | |||
| 903 | p_inode = ilookup(info->sb, parent->id.ino); | 905 | p_inode = ilookup(info->sb, parent->id.ino); |
| 904 | if (p_inode) { | 906 | if (p_inode) { |
| 905 | fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, | 907 | fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD, |
| 906 | inode, FSNOTIFY_EVENT_INODE, kn->name, 0); | 908 | inode, FSNOTIFY_EVENT_INODE, &name, 0); |
| 907 | iput(p_inode); | 909 | iput(p_inode); |
| 908 | } | 910 | } |
| 909 | 911 | ||
| @@ -911,7 +913,7 @@ repeat: · 1 unmodified line | |||
| 911 | } | 913 | } |
| 912 | 914 | ||
| 913 | fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, | 915 | fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, |
| 914 | kn->name, 0); | 916 | &name, 0); |
| 915 | iput(inode); | 917 | iput(inode); |
| 916 | } | 918 | } |
| 917 | 919 | ||
| @@ -179,10 +179,10 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask · 178 unmodified lines | |||
| 179 | take_dentry_name_snapshot(&name, dentry); | 179 | take_dentry_name_snapshot(&name, dentry); |
| 180 | if (path) | 180 | if (path) |
| 181 | ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, | 181 | ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, |
| 182 | name.name.name, 0); | 182 | &name.name, 0); |
| 183 | else | 183 | else |
| 184 | ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, | 184 | ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, |
| 185 | name.name.name, 0); | 185 | &name.name, 0); |
| 186 | release_dentry_name_snapshot(&name); | 186 | release_dentry_name_snapshot(&name); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -325,7 +325,7 @@ static void fsnotify_iter_next(struct fsnotify_iter_info *iter_info) · 136 unmodified lines | |||
| 325 | * notification event in whatever means they feel necessary. | 325 | * notification event in whatever means they feel necessary. |
| 326 | */ | 326 | */ |
| 327 | int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, | 327 | int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 328 | const unsigned char *file_name, u32 cookie) | 328 | const struct qstr *file_name, u32 cookie) |
| 329 | { | 329 | { |
| 330 | struct fsnotify_iter_info iter_info = {}; | 330 | struct fsnotify_iter_info iter_info = {}; |
| 331 | struct super_block *sb = to_tell->i_sb; | 331 | 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, · 47 unmodified lines | |||
| 379 | */ | 379 | */ |
| 380 | while (fsnotify_iter_select_report_types(&iter_info)) { | 380 | while (fsnotify_iter_select_report_types(&iter_info)) { |
| 381 | ret = send_to_group(to_tell, mask, data, data_is, cookie, | 381 | ret = send_to_group(to_tell, mask, data, data_is, cookie, |
| 382 | file_name, &iter_info); | 382 | file_name->name, &iter_info); |
| 383 | 383 | ||
| 384 | if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS)) | 384 | if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS)) |
| 385 | goto out; | 385 | goto out; |
| @@ -27,7 +27,7 @@ static inline int fsnotify_dirent(struct inode *dir, struct dentry *dentry, · 26 unmodified lines | |||
| 27 | __u32 mask) | 27 | __u32 mask) |
| 28 | { | 28 | { |
| 29 | return fsnotify(dir, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, | 29 | return fsnotify(dir, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, |
| 30 | dentry->d_name.name, 0); | 30 | &dentry->d_name, 0); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /* Notify this dentry's parent about a child's events. */ | 33 | /* Notify this dentry's parent about a child's events. */ |
| @@ -111,7 +111,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, · 77 unmodified lines | |||
| 111 | __u32 old_dir_mask = FS_MOVED_FROM; | 111 | __u32 old_dir_mask = FS_MOVED_FROM; |
| 112 | __u32 new_dir_mask = FS_MOVED_TO; | 112 | __u32 new_dir_mask = FS_MOVED_TO; |
| 113 | __u32 mask = FS_MOVE_SELF; | 113 | __u32 mask = FS_MOVE_SELF; |
| 114 | const unsigned char *new_name = moved->d_name.name; | 114 | const struct qstr *new_name = &moved->d_name; |
| 115 | 115 | ||
| 116 | if (old_dir == new_dir) | 116 | if (old_dir == new_dir) |
| 117 | old_dir_mask |= FS_DN_RENAME; | 117 | old_dir_mask |= FS_DN_RENAME; |
| @@ -122,7 +122,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, · 4 unmodified lines | |||
| 122 | mask |= FS_ISDIR; | 122 | mask |= FS_ISDIR; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name->name, | 125 | fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name, |
| 126 | fs_cookie); | 126 | fs_cookie); |
| 127 | fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name, | 127 | fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name, |
| 128 | fs_cookie); | 128 | fs_cookie); |
| @@ -178,7 +178,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) · 49 unmodified lines | |||
| 178 | take_dentry_name_snapshot(&name, dentry); | 178 | take_dentry_name_snapshot(&name, dentry); |
| 179 | 179 | ||
| 180 | fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, | 180 | fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, |
| 181 | name.name.name, 0); | 181 | &name.name, 0); |
| 182 | 182 | ||
| 183 | release_dentry_name_snapshot(&name); | 183 | release_dentry_name_snapshot(&name); |
| 184 | dput(parent); | 184 | dput(parent); |
| @@ -218,7 +218,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct · 33 unmodified lines | |||
| 218 | fsnotify_link_count(inode); | 218 | fsnotify_link_count(inode); |
| 219 | audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE); | 219 | audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE); |
| 220 | 220 | ||
| 221 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); | 221 | fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, &new_dentry->d_name, 0); |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | /* | 224 | /* |
| @@ -350,7 +350,7 @@ struct fsnotify_mark { · 349 unmodified lines | |||
| 350 | 350 | ||
| 351 | /* main fsnotify call to send events */ | 351 | /* main fsnotify call to send events */ |
| 352 | extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, | 352 | extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 353 | const unsigned char *name, u32 cookie); | 353 | const struct qstr *name, u32 cookie); |
| 354 | extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask); | 354 | extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask); |
| 355 | extern void __fsnotify_inode_delete(struct inode *inode); | 355 | extern void __fsnotify_inode_delete(struct inode *inode); |
| 356 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); | 356 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); |
| @@ -505,7 +505,7 @@ static inline void fsnotify_init_event(struct fsnotify_event *event, · 148 unmodified lines | |||
| 505 | #else | 505 | #else |
| 506 | 506 | ||
| 507 | static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, | 507 | static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 508 | const unsigned char *name, u32 cookie) | 508 | const struct qstr *name, u32 cookie) |
| 509 | { | 509 | { |
| 510 | return 0; | 510 | return 0; |
| 511 | } | 511 | } |