summaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2019-05-05 05:15:49 -0400
committerJan Kara <jack@suse.cz>2019-05-09 06:44:00 -0400
commit4d8e7055a4058ee191296699803c5090e14f0dff (patch)
treea7e72b2ea6aea71fc5f82dbe6a52a224d4f23dc2 /fs/notify
parent11a6f8e2db26519b6468686411deafab81c14741 (diff)
fsnotify: fix unlink performance regression
__fsnotify_parent() has an optimization in place to avoid unneeded take_dentry_name_snapshot(). When fsnotify_nameremove() was changed not to call __fsnotify_parent(), we left out the optimization. Kernel test robot reported a 5% performance regression in concurrent unlink() workload. Reported-by: kernel test robot <rong.a.chen@intel.com> Link: https://lore.kernel.org/lkml/20190505062153.GG29809@shao2-debian/ Link: https://lore.kernel.org/linux-fsdevel/20190104090357.GD22409@quack2.suse.cz/ Fixes: 5f02a8776384 ("fsnotify: annotate directory entry modification events") CC: stable@vger.kernel.org Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fsnotify.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index df06f3da166c..e8d3f349b7f2 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -108,6 +108,47 @@ void fsnotify_sb_delete(struct super_block *sb)
108} 108}
109 109
110/* 110/*
111 * fsnotify_nameremove - a filename was removed from a directory
112 *
113 * This is mostly called under parent vfs inode lock so name and
114 * dentry->d_parent should be stable. However there are some corner cases where
115 * inode lock is not held. So to be on the safe side and be reselient to future
116 * callers and out of tree users of d_delete(), we do not assume that d_parent
117 * and d_name are stable and we use dget_parent() and
118 * take_dentry_name_snapshot() to grab stable references.
119 */
120void fsnotify_nameremove(struct dentry *dentry, int isdir)
121{
122 struct dentry *parent;
123 struct name_snapshot name;
124 __u32 mask = FS_DELETE;
125
126 /* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */
127 if (IS_ROOT(dentry))
128 return;
129
130 if (isdir)
131 mask |= FS_ISDIR;
132
133 parent = dget_parent(dentry);
134 /* Avoid unneeded take_dentry_name_snapshot() */
135 if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) &&
136 !(dentry->d_sb->s_fsnotify_mask & FS_DELETE))
137 goto out_dput;
138
139 take_dentry_name_snapshot(&name, dentry);
140
141 fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
142 name.name, 0);
143
144 release_dentry_name_snapshot(&name);
145
146out_dput:
147 dput(parent);
148}
149EXPORT_SYMBOL(fsnotify_nameremove);
150
151/*
111 * Given an inode, first check if we care what happens to our children. Inotify 152 * Given an inode, first check if we care what happens to our children. Inotify
112 * and dnotify both tell their parents about events. If we care about any event 153 * and dnotify both tell their parents about events. If we care about any event
113 * on a child we run all of our children and set a dentry flag saying that the 154 * on a child we run all of our children and set a dentry flag saying that the