Merge tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 May 2019 22:08:16 +0000 (15:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 May 2019 22:08:16 +0000 (15:08 -0700)
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()

1  2 
fs/notify/fsnotify.c
include/linux/fsnotify.h
include/linux/fsnotify_backend.h

diff --combined fs/notify/fsnotify.c
index 5433e37fb0c52e7629a6d209325252900d0f6f24,e8d3f349b7f2c92dfbaa4e53578b5ed2bbb2284e..8c7cbac7183c13e923fe26b0ed2f052b00fe5e8a
@@@ -107,6 -107,47 +107,47 @@@ void fsnotify_sb_delete(struct super_bl
        fsnotify_clear_marks_by_sb(sb);
  }
  
 -               name.name, 0);
+ /*
+  * 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
   * and dnotify both tell their parents about events.  If we care about any event
@@@ -179,10 -220,10 +220,10 @@@ int __fsnotify_parent(const struct pat
                take_dentry_name_snapshot(&name, dentry);
                if (path)
                        ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
 -                                     name.name, 0);
 +                                     &name.name, 0);
                else
                        ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
 -                                     name.name, 0);
 +                                     &name.name, 0);
                release_dentry_name_snapshot(&name);
        }
  
@@@ -195,7 -236,7 +236,7 @@@ EXPORT_SYMBOL_GPL(__fsnotify_parent)
  static int send_to_group(struct inode *to_tell,
                         __u32 mask, const void *data,
                         int data_is, u32 cookie,
 -                       const unsigned char *file_name,
 +                       const struct qstr *file_name,
                         struct fsnotify_iter_info *iter_info)
  {
        struct fsnotify_group *group = NULL;
@@@ -325,7 -366,7 +366,7 @@@ static void fsnotify_iter_next(struct f
   * notification event in whatever means they feel necessary.
   */
  int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 -           const unsigned char *file_name, u32 cookie)
 +           const struct qstr *file_name, u32 cookie)
  {
        struct fsnotify_iter_info iter_info = {};
        struct super_block *sb = to_tell->i_sb;
diff --combined include/linux/fsnotify.h
index 0c0ef3078a220a0f0ff6993162360a97a8b47eb7,e30d6132c63387f8ef58f024287d2b9cf3005eb7..94972e8eb6d1e018f5005e43fdd8d71ac76d59e7
@@@ -27,7 -27,7 +27,7 @@@ static inline int fsnotify_dirent(struc
                                  __u32 mask)
  {
        return fsnotify(dir, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
 -                      dentry->d_name.name, 0);
 +                      &dentry->d_name, 0);
  }
  
  /* Notify this dentry's parent about a child's events. */
@@@ -102,7 -102,7 +102,7 @@@ static inline void fsnotify_link_count(
   * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
   */
  static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
 -                               const unsigned char *old_name,
 +                               const struct qstr *old_name,
                                 int isdir, struct inode *target,
                                 struct dentry *moved)
  {
        __u32 old_dir_mask = FS_MOVED_FROM;
        __u32 new_dir_mask = FS_MOVED_TO;
        __u32 mask = FS_MOVE_SELF;
 -      const unsigned char *new_name = moved->d_name.name;
 +      const struct qstr *new_name = &moved->d_name;
  
        if (old_dir == new_dir)
                old_dir_mask |= FS_DN_RENAME;
@@@ -151,39 -151,6 +151,6 @@@ static inline void fsnotify_vfsmount_de
        __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
   */
@@@ -218,7 -185,7 +185,7 @@@ static inline void fsnotify_link(struc
        fsnotify_link_count(inode);
        audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE);
  
 -      fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0);
 +      fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, &new_dentry->d_name, 0);
  }
  
  /*
index c28f6ed1f59b82302b0a733090fecfb42bc1436c,094b38f2d9a159596413f04e49a10940d628386c..a9f9dcc1e5151353a9664fa99fb9eb7b1c3ed46d
@@@ -117,7 -117,7 +117,7 @@@ struct fsnotify_ops 
        int (*handle_event)(struct fsnotify_group *group,
                            struct inode *inode,
                            u32 mask, const void *data, int data_type,
 -                          const unsigned char *file_name, u32 cookie,
 +                          const struct qstr *file_name, u32 cookie,
                            struct fsnotify_iter_info *iter_info);
        void (*free_group_priv)(struct fsnotify_group *group);
        void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
@@@ -350,11 -350,12 +350,12 @@@ struct fsnotify_mark 
  
  /* main fsnotify call to send events */
  extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 -                  const unsigned char *name, u32 cookie);
 +                  const struct qstr *name, u32 cookie);
  extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
  extern void __fsnotify_inode_delete(struct inode *inode);
  extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
  extern void fsnotify_sb_delete(struct super_block *sb);
+ extern void fsnotify_nameremove(struct dentry *dentry, int isdir);
  extern u32 fsnotify_get_cookie(void);
  
  static inline int fsnotify_inode_watches_children(struct inode *inode)
@@@ -505,7 -506,7 +506,7 @@@ static inline void fsnotify_init_event(
  #else
  
  static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 -                         const unsigned char *name, u32 cookie)
 +                         const struct qstr *name, u32 cookie)
  {
        return 0;
  }
@@@ -524,6 -525,9 +525,9 @@@ static inline void __fsnotify_vfsmount_
  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)
  {}