All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
@ 2025-06-18 18:36 Benjamin Coddington
  2025-06-19 13:05 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Coddington @ 2025-06-18 18:36 UTC (permalink / raw)
  To: trondmy, anna; +Cc: linux-nfs

We found a few different systems hung up in writeback waiting on the same
page lock, and one task waiting on the NFS_LAYOUT_DRAIN bit in
pnfs_update_layout(), however the pnfs_layout_hdr's plh_outstanding count
was zero.

It seems most likely that this is another race between the waiter and waker
similar to commit ed0172af5d6f ("SUNRPC: Fix a race to wake a sync task").
Fix it up by applying the advised barrier.

Fixes: 880265c77ac4 ("pNFS: Avoid a live lock condition in pnfs_update_layout()")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/pnfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5f582713bf05..321d946503cd 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2043,6 +2043,7 @@ static void nfs_layoutget_end(struct pnfs_layout_hdr *lo)
 {
 	if (atomic_dec_and_test(&lo->plh_outstanding) &&
 	    test_and_clear_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags))
+		smp_mb__after_atomic();
 		wake_up_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN);
 }
 
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
  2025-06-18 18:36 [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN Benjamin Coddington
@ 2025-06-19 13:05 ` kernel test robot
  2025-06-19 15:00   ` Benjamin Coddington
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-06-19 13:05 UTC (permalink / raw)
  To: Benjamin Coddington, trondmy, anna; +Cc: oe-kbuild-all, linux-nfs

Hi Benjamin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trondmy-nfs/linux-next]
[also build test WARNING on linus/master v6.16-rc2 next-20250618]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Coddington/NFSv4-pNFS-Fix-a-race-to-wake-on-NFS_LAYOUT_DRAIN/20250619-023749
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
patch link:    https://lore.kernel.org/r/43be0de9ff48ea68dec20d07cb235e164e634588.1750271744.git.bcodding%40redhat.com
patch subject: [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20250619/202506192044.sMgMZpkZ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250619/202506192044.sMgMZpkZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506192044.sMgMZpkZ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/nfs/pnfs.c: In function 'nfs_layoutget_end':
>> fs/nfs/pnfs.c:2061:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    2061 |         if (atomic_dec_and_test(&lo->plh_outstanding) &&
         |         ^~
   fs/nfs/pnfs.c:2064:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    2064 |                 wake_up_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN);
         |                 ^~~~~~~~~~~


vim +/if +2061 fs/nfs/pnfs.c

411ae722d10a6d Trond Myklebust     2018-06-23  2058  
411ae722d10a6d Trond Myklebust     2018-06-23  2059  static void nfs_layoutget_end(struct pnfs_layout_hdr *lo)
411ae722d10a6d Trond Myklebust     2018-06-23  2060  {
880265c77ac415 Trond Myklebust     2022-05-31 @2061  	if (atomic_dec_and_test(&lo->plh_outstanding) &&
880265c77ac415 Trond Myklebust     2022-05-31  2062  	    test_and_clear_bit(NFS_LAYOUT_DRAIN, &lo->plh_flags))
b844d0ad43d3ba Benjamin Coddington 2025-06-18  2063  		smp_mb__after_atomic();
880265c77ac415 Trond Myklebust     2022-05-31  2064  		wake_up_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN);
411ae722d10a6d Trond Myklebust     2018-06-23  2065  }
411ae722d10a6d Trond Myklebust     2018-06-23  2066  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
  2025-06-19 13:05 ` kernel test robot
@ 2025-06-19 15:00   ` Benjamin Coddington
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Coddington @ 2025-06-19 15:00 UTC (permalink / raw)
  To: kernel test robot; +Cc: trondmy, anna, oe-kbuild-all, linux-nfs

On 19 Jun 2025, at 9:05, kernel test robot wrote:

> Hi Benjamin,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on trondmy-nfs/linux-next]
> [also build test WARNING on linus/master v6.16-rc2 next-20250618]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Coddington/NFSv4-pNFS-Fix-a-race-to-wake-on-NFS_LAYOUT_DRAIN/20250619-023749
> base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
> patch link:    https://lore.kernel.org/r/43be0de9ff48ea68dec20d07cb235e164e634588.1750271744.git.bcodding%40redhat.com
> patch subject: [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
> config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20250619/202506192044.sMgMZpkZ-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250619/202506192044.sMgMZpkZ-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202506192044.sMgMZpkZ-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>    fs/nfs/pnfs.c: In function 'nfs_layoutget_end':
>>> fs/nfs/pnfs.c:2061:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
>     2061 |         if (atomic_dec_and_test(&lo->plh_outstanding) &&
>          |         ^~
>    fs/nfs/pnfs.c:2064:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
>     2064 |                 wake_up_bit(&lo->plh_flags, NFS_LAYOUT_DRAIN);
>          |                 ^~~~~~~~~~~
>

Oh what shame, thanks robot. v2 incoming.

Ben


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-19 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 18:36 [PATCH] NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN Benjamin Coddington
2025-06-19 13:05 ` kernel test robot
2025-06-19 15:00   ` Benjamin Coddington

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.