mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY
@ 2024-04-05 17:56 Jeff Layton
  2024-04-05 18:07 ` Chuck Lever
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2024-04-05 17:56 UTC (permalink / raw)
  To: Chuck Lever, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey
  Cc: Vladimir Benes, linux-nfs, linux-kernel, Jeff Layton

Currently the CB_RECALL_ANY job takes a cl_rpc_users reference to the
client. While a callback job is technically an RPC that counter is
really more for client-driven RPCs, and this has the effect of
preventing the client from being unhashed until the callback completes.

If nfsd decides to send a CB_RECALL_ANY just as the client reboots, we
can end up in a situation where the callback can't complete on the (now
dead) callback channel, but the new client can't connect because the old
client can't be unhashed. This usually manifests as a NFS4ERR_DELAY
return on the CREATE_SESSION operation.

The job is only holding a reference to the client so it can clear a flag
in the after the RPC completes. Fix this by having CB_RECALL_ANY instead
hold a reference to the cl_nfsdfs.cl_ref. Typically we only take that
sort of reference when dealing with the nfsdfs info files, but it should
work appropriately here to ensure that the nfs4_client doesn't
disappear.

Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low memory condition")
Reported-by: Vladimir Benes <vbenes@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Changes in v2:
- Clean up the changelog
- Add Fixes: tag
- Use kref_get instead of kref_get_unless_zero
---
 fs/nfsd/nfs4state.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 5fcd93f7cb8c..3cef81e196c6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3042,12 +3042,9 @@ static void
 nfsd4_cb_recall_any_release(struct nfsd4_callback *cb)
 {
 	struct nfs4_client *clp = cb->cb_clp;
-	struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
 
-	spin_lock(&nn->client_lock);
 	clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
-	put_client_renew_locked(clp);
-	spin_unlock(&nn->client_lock);
+	drop_client(clp);
 }
 
 static int
@@ -6616,7 +6613,7 @@ deleg_reaper(struct nfsd_net *nn)
 		list_add(&clp->cl_ra_cblist, &cblist);
 
 		/* release in nfsd4_cb_recall_any_release */
-		atomic_inc(&clp->cl_rpc_users);
+		kref_get(&clp->cl_nfsdfs.cl_ref);
 		set_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
 		clp->cl_ra_time = ktime_get_boottime_seconds();
 	}

---
base-commit: 05258a0a69b3c5d2c003f818702c0a52b6fea861
change-id: 20240405-rhel-31513-028ab6f14252

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


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

* Re: [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY
  2024-04-05 17:56 [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY Jeff Layton
@ 2024-04-05 18:07 ` Chuck Lever
  2024-04-05 20:11   ` vbenes
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chuck Lever @ 2024-04-05 18:07 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Vladimir Benes, linux-nfs, linux-kernel

On Fri, Apr 05, 2024 at 01:56:18PM -0400, Jeff Layton wrote:
> Currently the CB_RECALL_ANY job takes a cl_rpc_users reference to the
> client. While a callback job is technically an RPC that counter is
> really more for client-driven RPCs, and this has the effect of
> preventing the client from being unhashed until the callback completes.
> 
> If nfsd decides to send a CB_RECALL_ANY just as the client reboots, we
> can end up in a situation where the callback can't complete on the (now
> dead) callback channel, but the new client can't connect because the old
> client can't be unhashed. This usually manifests as a NFS4ERR_DELAY
> return on the CREATE_SESSION operation.
> 
> The job is only holding a reference to the client so it can clear a flag
> in the after the RPC completes. Fix this by having CB_RECALL_ANY instead
> hold a reference to the cl_nfsdfs.cl_ref. Typically we only take that
> sort of reference when dealing with the nfsdfs info files, but it should
> work appropriately here to ensure that the nfs4_client doesn't
> disappear.
> 
> Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low memory condition")
> Reported-by: Vladimir Benes <vbenes@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Applied to nfsd-fixes while waiting for review and testing. Thanks!


> ---
> Changes in v2:
> - Clean up the changelog
> - Add Fixes: tag
> - Use kref_get instead of kref_get_unless_zero
> ---
>  fs/nfsd/nfs4state.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 5fcd93f7cb8c..3cef81e196c6 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3042,12 +3042,9 @@ static void
>  nfsd4_cb_recall_any_release(struct nfsd4_callback *cb)
>  {
>  	struct nfs4_client *clp = cb->cb_clp;
> -	struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
>  
> -	spin_lock(&nn->client_lock);
>  	clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
> -	put_client_renew_locked(clp);
> -	spin_unlock(&nn->client_lock);
> +	drop_client(clp);
>  }
>  
>  static int
> @@ -6616,7 +6613,7 @@ deleg_reaper(struct nfsd_net *nn)
>  		list_add(&clp->cl_ra_cblist, &cblist);
>  
>  		/* release in nfsd4_cb_recall_any_release */
> -		atomic_inc(&clp->cl_rpc_users);
> +		kref_get(&clp->cl_nfsdfs.cl_ref);
>  		set_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
>  		clp->cl_ra_time = ktime_get_boottime_seconds();
>  	}
> 
> ---
> base-commit: 05258a0a69b3c5d2c003f818702c0a52b6fea861
> change-id: 20240405-rhel-31513-028ab6f14252
> 
> Best regards,
> -- 
> Jeff Layton <jlayton@kernel.org>
> 
> 

-- 
Chuck Lever

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

* Re: [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY
  2024-04-05 18:07 ` Chuck Lever
@ 2024-04-05 20:11   ` vbenes
  2024-04-06  6:07   ` Cedric Blancher
       [not found]   ` <d661b740-a431-4099-ae41-39a69bbc67b7@esat.kuleuven.be>
  2 siblings, 0 replies; 5+ messages in thread
From: vbenes @ 2024-04-05 20:11 UTC (permalink / raw)
  To: Chuck Lever, Jeff Layton
  Cc: Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs,
	linux-kernel

On Fri, 2024-04-05 at 14:07 -0400, Chuck Lever wrote:
> On Fri, Apr 05, 2024 at 01:56:18PM -0400, Jeff Layton wrote:
> > Currently the CB_RECALL_ANY job takes a cl_rpc_users reference to
> > the
> > client. While a callback job is technically an RPC that counter is
> > really more for client-driven RPCs, and this has the effect of
> > preventing the client from being unhashed until the callback
> > completes.
> > 
> > If nfsd decides to send a CB_RECALL_ANY just as the client reboots,
> > we
> > can end up in a situation where the callback can't complete on the
> > (now
> > dead) callback channel, but the new client can't connect because
> > the old
> > client can't be unhashed. This usually manifests as a NFS4ERR_DELAY
> > return on the CREATE_SESSION operation.
> > 
> > The job is only holding a reference to the client so it can clear a
> > flag
> > in the after the RPC completes. Fix this by having CB_RECALL_ANY
> > instead
> > hold a reference to the cl_nfsdfs.cl_ref. Typically we only take
> > that
> > sort of reference when dealing with the nfsdfs info files, but it
> > should
> > work appropriately here to ensure that the nfs4_client doesn't
> > disappear.
> > 
> > Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low
> > memory condition")
> > Reported-by: Vladimir Benes <vbenes@redhat.com>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Applied to nfsd-fixes while waiting for review and testing. Thanks!
> 
> 
> > ---
> > Changes in v2:
> > - Clean up the changelog
> > - Add Fixes: tag
> > - Use kref_get instead of kref_get_unless_zero
> > ---
> >  fs/nfsd/nfs4state.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index 5fcd93f7cb8c..3cef81e196c6 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -3042,12 +3042,9 @@ static void
> >  nfsd4_cb_recall_any_release(struct nfsd4_callback *cb)
> >  {
> >  	struct nfs4_client *clp = cb->cb_clp;
> > -	struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
> >  
> > -	spin_lock(&nn->client_lock);
> >  	clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags);
> > -	put_client_renew_locked(clp);
> > -	spin_unlock(&nn->client_lock);
> > +	drop_client(clp);
> >  }
> >  
> >  static int
> > @@ -6616,7 +6613,7 @@ deleg_reaper(struct nfsd_net *nn)
> >  		list_add(&clp->cl_ra_cblist, &cblist);
> >  
> >  		/* release in nfsd4_cb_recall_any_release */
> > -		atomic_inc(&clp->cl_rpc_users);
> > +		kref_get(&clp->cl_nfsdfs.cl_ref);
> >  		set_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp-
> > >cl_flags);
> >  		clp->cl_ra_time = ktime_get_boottime_seconds();
> >  	}
> > 
> > ---
> > base-commit: 05258a0a69b3c5d2c003f818702c0a52b6fea861
> > change-id: 20240405-rhel-31513-028ab6f14252
> > 
> > Best regards,
> > -- 
> > Jeff Layton <jlayton@kernel.org>
> > 
> > 
> 
Hi, 
I've just finished the testing of the new patch on the same HW
configuration and the dracut test suite is stable again.

Thank you for your patches!
Vladimir Benes

Tested-by: Vladimir Benes <vbenes@redhat.com>







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

* Re: [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY
  2024-04-05 18:07 ` Chuck Lever
  2024-04-05 20:11   ` vbenes
@ 2024-04-06  6:07   ` Cedric Blancher
       [not found]   ` <d661b740-a431-4099-ae41-39a69bbc67b7@esat.kuleuven.be>
  2 siblings, 0 replies; 5+ messages in thread
From: Cedric Blancher @ 2024-04-06  6:07 UTC (permalink / raw)
  To: linux-nfs; +Cc: linux-kernel

On Fri, 5 Apr 2024 at 20:07, Chuck Lever <chuck.lever@oracle.com> wrote:
>
> On Fri, Apr 05, 2024 at 01:56:18PM -0400, Jeff Layton wrote:
> > Currently the CB_RECALL_ANY job takes a cl_rpc_users reference to the
> > client. While a callback job is technically an RPC that counter is
> > really more for client-driven RPCs, and this has the effect of
> > preventing the client from being unhashed until the callback completes.
> >
> > If nfsd decides to send a CB_RECALL_ANY just as the client reboots, we
> > can end up in a situation where the callback can't complete on the (now
> > dead) callback channel, but the new client can't connect because the old
> > client can't be unhashed. This usually manifests as a NFS4ERR_DELAY
> > return on the CREATE_SESSION operation.
> >
> > The job is only holding a reference to the client so it can clear a flag
> > in the after the RPC completes. Fix this by having CB_RECALL_ANY instead
> > hold a reference to the cl_nfsdfs.cl_ref. Typically we only take that
> > sort of reference when dealing with the nfsdfs info files, but it should
> > work appropriately here to ensure that the nfs4_client doesn't
> > disappear.
> >
> > Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low memory condition")
> > Reported-by: Vladimir Benes <vbenes@redhat.com>
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
>
> Applied to nfsd-fixes while waiting for review and testing. Thanks!

Please add this to the 6.6 LTS brach, too

Ced
-- 
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur

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

* Re: [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY
       [not found]   ` <d661b740-a431-4099-ae41-39a69bbc67b7@esat.kuleuven.be>
@ 2024-04-09 17:32     ` Chuck Lever
  0 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2024-04-09 17:32 UTC (permalink / raw)
  To: Rik Theys
  Cc: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Vladimir Benes, linux-nfs, linux-kernel

On Tue, Apr 09, 2024 at 07:24:17PM +0200, Rik Theys wrote:
> Hi,
> 
> On 4/5/24 20:07, Chuck Lever wrote:
> > On Fri, Apr 05, 2024 at 01:56:18PM -0400, Jeff Layton wrote:
> > > Currently the CB_RECALL_ANY job takes a cl_rpc_users reference to the
> > > client. While a callback job is technically an RPC that counter is
> > > really more for client-driven RPCs, and this has the effect of
> > > preventing the client from being unhashed until the callback completes.
> > > 
> > > If nfsd decides to send a CB_RECALL_ANY just as the client reboots, we
> > > can end up in a situation where the callback can't complete on the (now
> > > dead) callback channel, but the new client can't connect because the old
> > > client can't be unhashed. This usually manifests as a NFS4ERR_DELAY
> > > return on the CREATE_SESSION operation.
> > > 
> > > The job is only holding a reference to the client so it can clear a flag
> > > in the after the RPC completes. Fix this by having CB_RECALL_ANY instead
> > > hold a reference to the cl_nfsdfs.cl_ref. Typically we only take that
> > > sort of reference when dealing with the nfsdfs info files, but it should
> > > work appropriately here to ensure that the nfs4_client doesn't
> > > disappear.
> > > 
> > > Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low memory condition")
> > > Reported-by: Vladimir Benes<vbenes@redhat.com>
> > > Signed-off-by: Jeff Layton<jlayton@kernel.org>
> > Applied to nfsd-fixes while waiting for review and testing. Thanks!
> > 
> Can this fix also be included in the 6.1.x LTS kernel? Given that "NFSD: add
> delegation reaper to react to low memory condition" was added to 6.1.81, it
> would be nice to have this fix in the 6.1 series.
> 
> This way it will also be picked up by Debian at some point (it seems they
> are upgrading to 6.1.82 for their next stable point release).

Thanks to the Fixes: tag in the commit's description, it will
probably appear in a later release of linux-6.1.y automatically.

If we don't see it the next few weeks, I will ping the stable
maintainers.


-- 
Chuck Lever

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

end of thread, other threads:[~2024-04-09 17:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-05 17:56 [PATCH v2] nfsd: hold a lighter-weight client reference over CB_RECALL_ANY Jeff Layton
2024-04-05 18:07 ` Chuck Lever
2024-04-05 20:11   ` vbenes
2024-04-06  6:07   ` Cedric Blancher
     [not found]   ` <d661b740-a431-4099-ae41-39a69bbc67b7@esat.kuleuven.be>
2024-04-09 17:32     ` Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®