diff mbox series

fs: nfs: dir.c: Fix sparse error

Message ID 20191210054639.30003-1-madhuparnabhowmik04@gmail.com (mailing list archive)
State New, archived
Headers show
Series fs: nfs: dir.c: Fix sparse error | expand

Commit Message

Madhuparna Bhowmik Dec. 10, 2019, 5:46 a.m. UTC
From: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>

This patch fixes the following sparse error:
fs/nfs/dir.c:2353:14: error: incompatible types in comparison expression (different address spaces):
fs/nfs/dir.c:2353:14:    struct list_head [noderef] <asn:4> *
fs/nfs/dir.c:2353:14:    struct list_head *

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>
---
 fs/nfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

kernel test robot Dec. 11, 2019, 1:01 a.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nfs/linux-next]
[cannot apply to v5.5-rc1 next-20191210]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/madhuparnabhowmik04-gmail-com/fs-nfs-dir-c-Fix-sparse-error/20191210-173307
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: s390-debug_defconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 7.5.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.5.0 make.cross ARCH=s390 

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 include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from fs/nfs/dir.c:21:
   fs/nfs/dir.c: In function 'nfs_access_get_cached_rcu':
>> fs/nfs/dir.c:2353:23: error: implicit declaration of function 'list_tail_rcu'; did you mean 'list_del_rcu'? [-Werror=implicit-function-declaration]
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
                          ^
   include/linux/rcupdate.h:319:10: note: in definition of macro '__rcu_dereference_check'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
             ^
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
>> fs/nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:319:9: error: invalid type argument of unary '*' (have 'int')
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
            ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
>> fs/nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   include/linux/rcupdate.h:319:35: error: invalid type argument of unary '*' (have 'int')
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                      ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
>> fs/nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:11:0,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from fs/nfs/dir.c:21:
   include/linux/compiler.h:263:20: error: lvalue required as unary '&' operand
      __read_once_size(&(x), __u.__c, sizeof(x));  \
                       ^
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
    #define READ_ONCE(x) __READ_ONCE(x, 1)
                         ^~~~~~~~~~~
>> include/linux/rcupdate.h:319:48: note: in expansion of macro 'READ_ONCE'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                                   ^~~~~~~~~
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
>> fs/nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   include/linux/compiler.h:265:28: error: lvalue required as unary '&' operand
      __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
                               ^
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
    #define READ_ONCE(x) __READ_ONCE(x, 1)
                         ^~~~~~~~~~~
>> include/linux/rcupdate.h:319:48: note: in expansion of macro 'READ_ONCE'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                                   ^~~~~~~~~
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
>> fs/nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   In file included from include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from fs/nfs/dir.c:21:
   include/linux/rcupdate.h:322:11: error: invalid type argument of unary '*' (have 'int')
     ((typeof(*p) __force __kernel *)(________p1)); \
              ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from fs//nfs/dir.c:21:
   fs//nfs/dir.c: In function 'nfs_access_get_cached_rcu':
   fs//nfs/dir.c:2353:23: error: implicit declaration of function 'list_tail_rcu'; did you mean 'list_del_rcu'? [-Werror=implicit-function-declaration]
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
                          ^
   include/linux/rcupdate.h:319:10: note: in definition of macro '__rcu_dereference_check'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
             ^
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:319:9: error: invalid type argument of unary '*' (have 'int')
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
            ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   include/linux/rcupdate.h:319:35: error: invalid type argument of unary '*' (have 'int')
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                      ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:11:0,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from fs//nfs/dir.c:21:
   include/linux/compiler.h:263:20: error: lvalue required as unary '&' operand
      __read_once_size(&(x), __u.__c, sizeof(x));  \
                       ^
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
    #define READ_ONCE(x) __READ_ONCE(x, 1)
                         ^~~~~~~~~~~
>> include/linux/rcupdate.h:319:48: note: in expansion of macro 'READ_ONCE'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                                   ^~~~~~~~~
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   include/linux/compiler.h:265:28: error: lvalue required as unary '&' operand
      __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
                               ^
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
    #define READ_ONCE(x) __READ_ONCE(x, 1)
                         ^~~~~~~~~~~
>> include/linux/rcupdate.h:319:48: note: in expansion of macro 'READ_ONCE'
     typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                                   ^~~~~~~~~
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   In file included from include/linux/rbtree.h:22:0,
                    from include/linux/mm_types.h:10,
                    from include/linux/mmzone.h:21,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:13,
                    from fs//nfs/dir.c:21:
   include/linux/rcupdate.h:322:11: error: invalid type argument of unary '*' (have 'int')
     ((typeof(*p) __force __kernel *)(________p1)); \
              ^
>> include/linux/rcupdate.h:456:2: note: in expansion of macro '__rcu_dereference_check'
     __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
     ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/rcupdate.h:514:28: note: in expansion of macro 'rcu_dereference_check'
    #define rcu_dereference(p) rcu_dereference_check(p, 0)
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//nfs/dir.c:2353:7: note: in expansion of macro 'rcu_dereference'
     lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
          ^~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +2353 fs/nfs/dir.c

  2339	
  2340	static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res)
  2341	{
  2342		/* Only check the most recently returned cache entry,
  2343		 * but do it without locking.
  2344		 */
  2345		struct nfs_inode *nfsi = NFS_I(inode);
  2346		struct nfs_access_entry *cache;
  2347		int err = -ECHILD;
  2348		struct list_head *lh;
  2349	
  2350		rcu_read_lock();
  2351		if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)
  2352			goto out;
> 2353		lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
  2354		cache = list_entry(lh, struct nfs_access_entry, lru);
  2355		if (lh == &nfsi->access_cache_entry_lru ||
  2356		    cred != cache->cred)
  2357			cache = NULL;
  2358		if (cache == NULL)
  2359			goto out;
  2360		if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
  2361			goto out;
  2362		res->cred = cache->cred;
  2363		res->mask = cache->mask;
  2364		err = 0;
  2365	out:
  2366		rcu_read_unlock();
  2367		return err;
  2368	}
  2369	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Madhuparna Bhowmik Dec. 11, 2019, 7:48 a.m. UTC | #2
This build error is because the macro list_tail_rcu() is
not yet present in the mainline kernel.

This patch is dependent on the patch : https://lore.kernel.org/linux-kernel-mentees/CAF65HP2SC89k9HJZfcLgeOMRPBKRyasCMiLo2gZgBKycjHuU6A@mail.gmail.com/T/#t


Thank you,
Madhuparna
Paul E. McKenney Dec. 12, 2019, 4:14 a.m. UTC | #3
On Wed, Dec 11, 2019 at 01:18:42PM +0530, madhuparnabhowmik04@gmail.com wrote:
> This build error is because the macro list_tail_rcu() is
> not yet present in the mainline kernel.
> 
> This patch is dependent on the patch : https://lore.kernel.org/linux-kernel-mentees/CAF65HP2SC89k9HJZfcLgeOMRPBKRyasCMiLo2gZgBKycjHuU6A@mail.gmail.com/T/#t

If the NFS folks are OK with it, I would be happy to take it in -rcu,
where the list_tail_rcu() patch is currently located.

							Thanx, Paul
Trond Myklebust Dec. 12, 2019, 1:45 p.m. UTC | #4
On Wed, 2019-12-11 at 20:14 -0800, Paul E. McKenney wrote:
> On Wed, Dec 11, 2019 at 01:18:42PM +0530, 
> madhuparnabhowmik04@gmail.com wrote:
> > This build error is because the macro list_tail_rcu() is
> > not yet present in the mainline kernel.
> > 
> > This patch is dependent on the patch : 
> > https://lore.kernel.org/linux-kernel-mentees/CAF65HP2SC89k9HJZfcLgeOMRPBKRyasCMiLo2gZgBKycjHuU6A@mail.gmail.com/T/#t
> 
> If the NFS folks are OK with it, I would be happy to take it in -rcu,
> where the list_tail_rcu() patch is currently located.
> 
> 							Thanx, Paul

That would be fine with me.

Cheers
  Trond
Paul E. McKenney Dec. 12, 2019, 6:03 p.m. UTC | #5
On Thu, Dec 12, 2019 at 01:45:29PM +0000, Trond Myklebust wrote:
> On Wed, 2019-12-11 at 20:14 -0800, Paul E. McKenney wrote:
> > On Wed, Dec 11, 2019 at 01:18:42PM +0530, 
> > madhuparnabhowmik04@gmail.com wrote:
> > > This build error is because the macro list_tail_rcu() is
> > > not yet present in the mainline kernel.
> > > 
> > > This patch is dependent on the patch : 
> > > https://lore.kernel.org/linux-kernel-mentees/CAF65HP2SC89k9HJZfcLgeOMRPBKRyasCMiLo2gZgBKycjHuU6A@mail.gmail.com/T/#t
> > 
> > If the NFS folks are OK with it, I would be happy to take it in -rcu,
> > where the list_tail_rcu() patch is currently located.
> 
> That would be fine with me.

Very good!  I have queued it.

							Thanx, Paul
diff mbox series

Patch

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index e180033e35cf..b69370b6d317 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2350,7 +2350,7 @@  static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
 	rcu_read_lock();
 	if (nfsi->cache_validity & NFS_INO_INVALID_ACCESS)
 		goto out;
-	lh = rcu_dereference(nfsi->access_cache_entry_lru.prev);
+	lh = rcu_dereference(list_tail_rcu(&nfsi->access_cache_entry_lru));
 	cache = list_entry(lh, struct nfs_access_entry, lru);
 	if (lh == &nfsi->access_cache_entry_lru ||
 	    cred != cache->cred)