Commit d4c60811 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'fsnotify_for_v5.2-rc1' of...

Merge tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull fsnotify fixes from Jan Kara:
 "Two fsnotify fixes"

* tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  fsnotify: fix unlink performance regression
  fsnotify: Clarify connector assignment in fsnotify_add_mark_list()
parents 29c079ca 4d8e7055
...@@ -107,6 +107,47 @@ void fsnotify_sb_delete(struct super_block *sb) ...@@ -107,6 +107,47 @@ void fsnotify_sb_delete(struct super_block *sb)
fsnotify_clear_marks_by_sb(sb); fsnotify_clear_marks_by_sb(sb);
} }
/*
* fsnotify_nameremove - a filename was removed from a directory
*
* This is mostly called under parent vfs inode lock so name and
* dentry->d_parent should be stable. However there are some corner cases where
* inode lock is not held. So to be on the safe side and be reselient to future
* callers and out of tree users of d_delete(), we do not assume that d_parent
* and d_name are stable and we use dget_parent() and
* take_dentry_name_snapshot() to grab stable references.
*/
void fsnotify_nameremove(struct dentry *dentry, int isdir)
{
struct dentry *parent;
struct name_snapshot name;
__u32 mask = FS_DELETE;
/* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */
if (IS_ROOT(dentry))
return;
if (isdir)
mask |= FS_ISDIR;
parent = dget_parent(dentry);
/* Avoid unneeded take_dentry_name_snapshot() */
if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) &&
!(dentry->d_sb->s_fsnotify_mask & FS_DELETE))
goto out_dput;
take_dentry_name_snapshot(&name, dentry);
fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
&name.name, 0);
release_dentry_name_snapshot(&name);
out_dput:
dput(parent);
}
EXPORT_SYMBOL(fsnotify_nameremove);
/* /*
* Given an inode, first check if we care what happens to our children. Inotify * Given an inode, first check if we care what happens to our children. Inotify
* and dnotify both tell their parents about events. If we care about any event * and dnotify both tell their parents about events. If we care about any event
......
...@@ -619,6 +619,11 @@ static int fsnotify_add_mark_list(struct fsnotify_mark *mark, ...@@ -619,6 +619,11 @@ static int fsnotify_add_mark_list(struct fsnotify_mark *mark,
/* mark should be the last entry. last is the current last entry */ /* mark should be the last entry. last is the current last entry */
hlist_add_behind_rcu(&mark->obj_list, &last->obj_list); hlist_add_behind_rcu(&mark->obj_list, &last->obj_list);
added: added:
/*
* Since connector is attached to object using cmpxchg() we are
* guaranteed that connector initialization is fully visible by anyone
* seeing mark->connector set.
*/
WRITE_ONCE(mark->connector, conn); WRITE_ONCE(mark->connector, conn);
out_err: out_err:
spin_unlock(&conn->lock); spin_unlock(&conn->lock);
......
...@@ -151,39 +151,6 @@ static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt) ...@@ -151,39 +151,6 @@ static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt)
__fsnotify_vfsmount_delete(mnt); __fsnotify_vfsmount_delete(mnt);
} }
/*
* fsnotify_nameremove - a filename was removed from a directory
*
* This is mostly called under parent vfs inode lock so name and
* dentry->d_parent should be stable. However there are some corner cases where
* inode lock is not held. So to be on the safe side and be reselient to future
* callers and out of tree users of d_delete(), we do not assume that d_parent
* and d_name are stable and we use dget_parent() and
* take_dentry_name_snapshot() to grab stable references.
*/
static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
{
struct dentry *parent;
struct name_snapshot name;
__u32 mask = FS_DELETE;
/* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */
if (IS_ROOT(dentry))
return;
if (isdir)
mask |= FS_ISDIR;
parent = dget_parent(dentry);
take_dentry_name_snapshot(&name, dentry);
fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
&name.name, 0);
release_dentry_name_snapshot(&name);
dput(parent);
}
/* /*
* fsnotify_inoderemove - an inode is going away * fsnotify_inoderemove - an inode is going away
*/ */
......
...@@ -355,6 +355,7 @@ extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u ...@@ -355,6 +355,7 @@ extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u
extern void __fsnotify_inode_delete(struct inode *inode); extern void __fsnotify_inode_delete(struct inode *inode);
extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
extern void fsnotify_sb_delete(struct super_block *sb); extern void fsnotify_sb_delete(struct super_block *sb);
extern void fsnotify_nameremove(struct dentry *dentry, int isdir);
extern u32 fsnotify_get_cookie(void); extern u32 fsnotify_get_cookie(void);
static inline int fsnotify_inode_watches_children(struct inode *inode) static inline int fsnotify_inode_watches_children(struct inode *inode)
...@@ -524,6 +525,9 @@ static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt) ...@@ -524,6 +525,9 @@ static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
static inline void fsnotify_sb_delete(struct super_block *sb) static inline void fsnotify_sb_delete(struct super_block *sb)
{} {}
static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
{}
static inline void fsnotify_update_flags(struct dentry *dentry) static inline void fsnotify_update_flags(struct dentry *dentry)
{} {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment