summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2019-05-26 10:34:11 -0400
committerJan Kara <jack@suse.cz>2019-06-20 08:47:54 -0400
commit7377f5bec13332bc470856f337935be6cabbcf24 (patch)
treeb2906da2c692ddddfcd63ba74c8ee1e1747ec508
parent49246466a98996e78b68a0041807dbd2628c53fe (diff)
fsnotify: get rid of fsnotify_nameremove()
For all callers of fsnotify_{unlink,rmdir}(), we made sure that d_parent and d_name are stable. Therefore, fsnotify_{unlink,rmdir}() do not need the safety measures in fsnotify_nameremove() to stabilize parent and name. We can now simplify those hooks and get rid of fsnotify_nameremove(). Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/notify/fsnotify.c41
-rw-r--r--include/linux/fsnotify.h6
-rw-r--r--include/linux/fsnotify_backend.h4
3 files changed, 2 insertions, 49 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 4eb2ebfac468..2ecef6155fc0 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -95,47 +95,6 @@ void fsnotify_sb_delete(struct super_block *sb)
95} 95}
96 96
97/* 97/*
98 * fsnotify_nameremove - a filename was removed from a directory
99 *
100 * This is mostly called under parent vfs inode lock so name and
101 * dentry->d_parent should be stable. However there are some corner cases where
102 * inode lock is not held. So to be on the safe side and be reselient to future
103 * callers and out of tree users of d_delete(), we do not assume that d_parent
104 * and d_name are stable and we use dget_parent() and
105 * take_dentry_name_snapshot() to grab stable references.
106 */
107void fsnotify_nameremove(struct dentry *dentry, int isdir)
108{
109 struct dentry *parent;
110 struct name_snapshot name;
111 __u32 mask = FS_DELETE;
112
113 /* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */
114 if (IS_ROOT(dentry))
115 return;
116
117 if (isdir)
118 mask |= FS_ISDIR;
119
120 parent = dget_parent(dentry);
121 /* Avoid unneeded take_dentry_name_snapshot() */
122 if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) &&
123 !(dentry->d_sb->s_fsnotify_mask & FS_DELETE))
124 goto out_dput;
125
126 take_dentry_name_snapshot(&name, dentry);
127
128 fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
129 &name.name, 0);
130
131 release_dentry_name_snapshot(&name);
132
133out_dput:
134 dput(parent);
135}
136EXPORT_SYMBOL(fsnotify_nameremove);
137
138/*
139 * Given an inode, first check if we care what happens to our children. Inotify 98 * Given an inode, first check if we care what happens to our children. Inotify
140 * and dnotify both tell their parents about events. If we care about any event 99 * and dnotify both tell their parents about events. If we care about any event
141 * on a child we run all of our children and set a dentry flag saying that the 100 * on a child we run all of our children and set a dentry flag saying that the
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 0145073c2b42..a2d5d175d3c1 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -198,8 +198,7 @@ static inline void fsnotify_unlink(struct inode *dir, struct dentry *dentry)
198 /* Expected to be called before d_delete() */ 198 /* Expected to be called before d_delete() */
199 WARN_ON_ONCE(d_is_negative(dentry)); 199 WARN_ON_ONCE(d_is_negative(dentry));
200 200
201 /* TODO: call fsnotify_dirent() */ 201 fsnotify_dirent(dir, dentry, FS_DELETE);
202 fsnotify_nameremove(dentry, 0);
203} 202}
204 203
205/* 204/*
@@ -222,8 +221,7 @@ static inline void fsnotify_rmdir(struct inode *dir, struct dentry *dentry)
222 /* Expected to be called before d_delete() */ 221 /* Expected to be called before d_delete() */
223 WARN_ON_ONCE(d_is_negative(dentry)); 222 WARN_ON_ONCE(d_is_negative(dentry));
224 223
225 /* TODO: call fsnotify_dirent() */ 224 fsnotify_dirent(dir, dentry, FS_DELETE | FS_ISDIR);
226 fsnotify_nameremove(dentry, 1);
227} 225}
228 226
229/* 227/*
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index a9f9dcc1e515..c28f6ed1f59b 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -355,7 +355,6 @@ extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u
355extern void __fsnotify_inode_delete(struct inode *inode); 355extern void __fsnotify_inode_delete(struct inode *inode);
356extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); 356extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
357extern void fsnotify_sb_delete(struct super_block *sb); 357extern void fsnotify_sb_delete(struct super_block *sb);
358extern void fsnotify_nameremove(struct dentry *dentry, int isdir);
359extern u32 fsnotify_get_cookie(void); 358extern u32 fsnotify_get_cookie(void);
360 359
361static inline int fsnotify_inode_watches_children(struct inode *inode) 360static inline int fsnotify_inode_watches_children(struct inode *inode)
@@ -525,9 +524,6 @@ static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
525static inline void fsnotify_sb_delete(struct super_block *sb) 524static inline void fsnotify_sb_delete(struct super_block *sb)
526{} 525{}
527 526
528static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
529{}
530
531static inline void fsnotify_update_flags(struct dentry *dentry) 527static inline void fsnotify_update_flags(struct dentry *dentry)
532{} 528{}
533 529