From: Linus Torvalds Date: Mon, 13 May 2019 22:08:16 +0000 (-0700) Subject: Merge tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel... X-Git-Tag: v5.15~6379 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4c608115c6203efbab14befab90a6d1b61177d8;p=platform%2Fkernel%2Flinux-starfive.git Merge tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite./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() --- d4c608115c6203efbab14befab90a6d1b61177d8 diff --cc fs/notify/fsnotify.c index 5433e37,e8d3f34..8c7cbac --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@@ -108,6 -108,47 +108,47 @@@ void fsnotify_sb_delete(struct super_bl } /* + * 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); ++ &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 * and dnotify both tell their parents about events. If we care about any event * on a child we run all of our children and set a dentry flag saying that the