diff mbox series

[v2,05/16] fsnotify: simplify arguments passing to fsnotify_parent()

Message ID 20200217131455.31107-6-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show
Series Fanotify event with name info | expand

Commit Message

Amir Goldstein Feb. 17, 2020, 1:14 p.m. UTC
Instead of passing both dentry and path and having to figure out which
one to use, pass data/data_type to simplify the code.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/notify/fsnotify.c             | 15 ++++-----------
 include/linux/fsnotify.h         | 14 ++------------
 include/linux/fsnotify_backend.h | 13 +++++++------
 3 files changed, 13 insertions(+), 29 deletions(-)

Comments

kernel test robot Feb. 19, 2020, 10:50 a.m. UTC | #1
Hi Amir,

I love your patch! Yet something to improve:

[auto build test ERROR on 11a48a5a18c63fd7621bb050228cebf13566e4d8]

url:    https://github.com/0day-ci/linux/commits/Amir-Goldstein/Fanotify-event-with-name-info/20200219-160517
base:    11a48a5a18c63fd7621bb050228cebf13566e4d8
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h: In function 'fsnotify_dentry':
>> include/linux/fsnotify.h:52:18: warning: passing argument 1 of 'fsnotify_parent' makes integer from pointer without a cast [-Wint-conversion]
     fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
                     ^~~~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected '__u32 {aka unsigned int}' but argument is of type 'struct dentry *'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
>> include/linux/fsnotify.h:52:26: warning: passing argument 2 of 'fsnotify_parent' makes pointer from integer without a cast [-Wint-conversion]
     fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
                             ^~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected 'const void *' but argument is of type '__u32 {aka unsigned int}'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h:52:32: warning: passing argument 3 of 'fsnotify_parent' makes integer from pointer without a cast [-Wint-conversion]
     fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
                                   ^~~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected 'int' but argument is of type 'struct inode *'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
>> include/linux/fsnotify.h:52:2: error: too many arguments to function 'fsnotify_parent'
     fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
     ^~~~~~~~~~~~~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: declared here
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h: In function 'fsnotify_file':
   include/linux/fsnotify.h:68:24: warning: passing argument 1 of 'fsnotify_parent' makes integer from pointer without a cast [-Wint-conversion]
     ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
                           ^~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected '__u32 {aka unsigned int}' but argument is of type 'struct dentry * const'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h:68:38: warning: passing argument 2 of 'fsnotify_parent' makes pointer from integer without a cast [-Wint-conversion]
     ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
                                         ^~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected 'const void *' but argument is of type '__u32 {aka unsigned int}'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h:68:44: warning: passing argument 3 of 'fsnotify_parent' makes integer from pointer without a cast [-Wint-conversion]
     ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
                                               ^~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: expected 'int' but argument is of type 'const struct path *'
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~
   In file included from fs///attr.c:15:0:
   include/linux/fsnotify.h:68:8: error: too many arguments to function 'fsnotify_parent'
     ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
           ^~~~~~~~~~~~~~~
   In file included from include/linux/fsnotify.h:15:0,
                    from fs///attr.c:15:
   include/linux/fsnotify_backend.h:543:19: note: declared here
    static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
                      ^~~~~~~~~~~~~~~

vim +/fsnotify_parent +52 include/linux/fsnotify.h

    40	
    41	/*
    42	 * Simple wrappers to consolidate calls fsnotify_parent()/fsnotify() when
    43	 * an event is on a file/dentry.
    44	 */
    45	static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
    46	{
    47		struct inode *inode = d_inode(dentry);
    48	
    49		if (S_ISDIR(inode->i_mode))
    50			mask |= FS_ISDIR;
    51	
  > 52		fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
    53		fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
    54	}
    55	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Amir Goldstein Feb. 19, 2020, 11:11 a.m. UTC | #2
On Mon, Feb 17, 2020 at 3:15 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> Instead of passing both dentry and path and having to figure out which
> one to use, pass data/data_type to simplify the code.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  fs/notify/fsnotify.c             | 15 ++++-----------
>  include/linux/fsnotify.h         | 14 ++------------
>  include/linux/fsnotify_backend.h | 13 +++++++------
>  3 files changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
> index a5d6467f89a0..193530f57963 100644
> --- a/fs/notify/fsnotify.c
> +++ b/fs/notify/fsnotify.c
> @@ -143,15 +143,13 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
>  }
>
>  /* Notify this dentry's parent about a child's events. */
> -int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
> +int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
> +                   int data_type)
>  {
>         struct dentry *parent;
>         struct inode *p_inode;
>         int ret = 0;
>
> -       if (!dentry)
> -               dentry = path->dentry;
> -
>         if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
>                 return 0;
>
> @@ -168,12 +166,7 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
>                 mask |= FS_EVENT_ON_CHILD;
>
>                 take_dentry_name_snapshot(&name, dentry);
> -               if (path)
> -                       ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
> -                                      &name.name, 0);
> -               else
> -                       ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
> -                                      &name.name, 0);
> +               ret = fsnotify(p_inode, mask, data, data_type, &name.name, 0);
>                 release_dentry_name_snapshot(&name);
>         }
>
> @@ -181,7 +174,7 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
>
>         return ret;
>  }
> -EXPORT_SYMBOL_GPL(__fsnotify_parent);
> +EXPORT_SYMBOL_GPL(fsnotify_parent);
>
>  static int send_to_group(struct inode *to_tell,
>                          __u32 mask, const void *data,
> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
> index 420aca9fd5f4..af30e0a56f2e 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -38,16 +38,6 @@ static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
>         fsnotify_name(dir, mask, d_inode(dentry), &dentry->d_name, 0);
>  }
>
> -/* Notify this dentry's parent about a child's events. */
> -static inline int fsnotify_parent(const struct path *path,
> -                                 struct dentry *dentry, __u32 mask)
> -{
> -       if (!dentry)
> -               dentry = path->dentry;
> -
> -       return __fsnotify_parent(path, dentry, mask);
> -}
> -
>  /*
>   * Simple wrappers to consolidate calls fsnotify_parent()/fsnotify() when
>   * an event is on a file/dentry.
> @@ -59,7 +49,7 @@ static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
>         if (S_ISDIR(inode->i_mode))
>                 mask |= FS_ISDIR;
>
> -       fsnotify_parent(NULL, dentry, mask);
> +       fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
>         fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
>  }
>
> @@ -75,7 +65,7 @@ static inline int fsnotify_file(struct file *file, __u32 mask)
>         if (S_ISDIR(inode->i_mode))
>                 mask |= FS_ISDIR;
>
> -       ret = fsnotify_parent(path, NULL, mask);
> +       ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
>         if (ret)
>                 return ret;
>
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 5cc838db422a..b1f418cc28e1 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -376,9 +376,10 @@ struct fsnotify_mark {
>  /* called from the vfs helpers */
>
>  /* main fsnotify call to send events */
> -extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
> -                   const struct qstr *name, u32 cookie);
> -extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
> +extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
> +                   int data_type, const struct qstr *name, u32 cookie);
> +extern int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
> +                          int data_type);
>  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);
> @@ -533,13 +534,13 @@ static inline void fsnotify_init_event(struct fsnotify_event *event,
>
>  #else
>
> -static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
> -                          const struct qstr *name, u32 cookie)
> +static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
> +                          int data_type, const struct qstr *name, u32 cookie)
>  {
>         return 0;
>  }
>
> -static inline int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
> +static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)

This should be:

+static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
const void *data, int data_type)

Will squash the fix.

Thanks kbuild test robot,
Amir.
diff mbox series

Patch

diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index a5d6467f89a0..193530f57963 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -143,15 +143,13 @@  void __fsnotify_update_child_dentry_flags(struct inode *inode)
 }
 
 /* Notify this dentry's parent about a child's events. */
-int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
+int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
+		    int data_type)
 {
 	struct dentry *parent;
 	struct inode *p_inode;
 	int ret = 0;
 
-	if (!dentry)
-		dentry = path->dentry;
-
 	if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
 		return 0;
 
@@ -168,12 +166,7 @@  int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
 		mask |= FS_EVENT_ON_CHILD;
 
 		take_dentry_name_snapshot(&name, dentry);
-		if (path)
-			ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
-				       &name.name, 0);
-		else
-			ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
-				       &name.name, 0);
+		ret = fsnotify(p_inode, mask, data, data_type, &name.name, 0);
 		release_dentry_name_snapshot(&name);
 	}
 
@@ -181,7 +174,7 @@  int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(__fsnotify_parent);
+EXPORT_SYMBOL_GPL(fsnotify_parent);
 
 static int send_to_group(struct inode *to_tell,
 			 __u32 mask, const void *data,
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 420aca9fd5f4..af30e0a56f2e 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -38,16 +38,6 @@  static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
 	fsnotify_name(dir, mask, d_inode(dentry), &dentry->d_name, 0);
 }
 
-/* Notify this dentry's parent about a child's events. */
-static inline int fsnotify_parent(const struct path *path,
-				  struct dentry *dentry, __u32 mask)
-{
-	if (!dentry)
-		dentry = path->dentry;
-
-	return __fsnotify_parent(path, dentry, mask);
-}
-
 /*
  * Simple wrappers to consolidate calls fsnotify_parent()/fsnotify() when
  * an event is on a file/dentry.
@@ -59,7 +49,7 @@  static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask)
 	if (S_ISDIR(inode->i_mode))
 		mask |= FS_ISDIR;
 
-	fsnotify_parent(NULL, dentry, mask);
+	fsnotify_parent(dentry, mask, inode, FSNOTIFY_EVENT_INODE);
 	fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
 }
 
@@ -75,7 +65,7 @@  static inline int fsnotify_file(struct file *file, __u32 mask)
 	if (S_ISDIR(inode->i_mode))
 		mask |= FS_ISDIR;
 
-	ret = fsnotify_parent(path, NULL, mask);
+	ret = fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH);
 	if (ret)
 		return ret;
 
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 5cc838db422a..b1f418cc28e1 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -376,9 +376,10 @@  struct fsnotify_mark {
 /* called from the vfs helpers */
 
 /* main fsnotify call to send events */
-extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
-		    const struct qstr *name, u32 cookie);
-extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
+extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
+		    int data_type, const struct qstr *name, u32 cookie);
+extern int fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data,
+			   int data_type);
 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);
@@ -533,13 +534,13 @@  static inline void fsnotify_init_event(struct fsnotify_event *event,
 
 #else
 
-static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
-			   const struct qstr *name, u32 cookie)
+static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data,
+			   int data_type, const struct qstr *name, u32 cookie)
 {
 	return 0;
 }
 
-static inline int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask)
+static inline int fsnotify_parent(__u32 mask, const void *data, int data_type)
 {
 	return 0;
 }