linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neilb@suse.de>, Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia <kolga@netapp.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Christoph Hellwig <hch@lst.de>,  Tom Haynes <loghyr@gmail.com>
Subject: Re: [PATCH 11/13] nfsd: allow open state ids to be revoked and then freed
Date: Mon, 29 Jan 2024 07:31:57 -0500	[thread overview]
Message-ID: <e74341299eff72b61f2248c96d5841fea4819628.camel@kernel.org> (raw)
In-Reply-To: <20240129033637.2133-12-neilb@suse.de>

On Mon, 2024-01-29 at 14:29 +1100, NeilBrown wrote:
> Revoking state through 'unlock_filesystem' now revokes any open states
> found.  When the stateids are then freed by the client, the revoked
> stateids will be cleaned up correctly.
> 
> Possibly the related lock states should be revoked too, but a
> subsequent patch will do that for all lock state on the superblock.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  fs/nfsd/nfs4state.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index a5c17dab8bdb..5dc8f60e18dc 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1717,7 +1717,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
>  	unsigned int idhashval;
>  	unsigned int sc_types;
>  
> -	sc_types = SC_TYPE_LOCK;
> +	sc_types = SC_TYPE_OPEN | SC_TYPE_LOCK;
>  
>  	spin_lock(&nn->client_lock);
>  	for (idhashval = 0; idhashval < CLIENT_HASH_MASK; idhashval++) {
> @@ -1732,6 +1732,22 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
>  
>  				spin_unlock(&nn->client_lock);
>  				switch (stid->sc_type) {
> +				case SC_TYPE_OPEN:
> +					stp = openlockstateid(stid);
> +					mutex_lock_nested(&stp->st_mutex,
> +							  OPEN_STATEID_MUTEX);
> +
> +					spin_lock(&clp->cl_lock);
> +					if (stid->sc_status == 0) {
> +						stid->sc_status |=
> +							SC_STATUS_ADMIN_REVOKED;
> +						atomic_inc(&clp->cl_admin_revoked);
> +						spin_unlock(&clp->cl_lock);
> +						release_all_access(stp);
> +					} else
> +						spin_unlock(&clp->cl_lock);
> +					mutex_unlock(&stp->st_mutex);
> +					break;
>  				case SC_TYPE_LOCK:
>  					stp = openlockstateid(stid);
>  					mutex_lock_nested(&stp->st_mutex,
> @@ -4662,6 +4678,13 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)
>  	bool unhashed;
>  
>  	switch (s->sc_type) {
> +	case SC_TYPE_OPEN:
> +		stp = openlockstateid(s);
> +		if (unhash_open_stateid(stp, &reaplist))
> +			put_ol_stateid_locked(stp, &reaplist);
> +		spin_unlock(&cl->cl_lock);
> +		free_ol_stateid_reaplist(&reaplist);
> +		break;
>  	case SC_TYPE_LOCK:
>  		stp = openlockstateid(s);
>  		unhashed = unhash_lock_stateid(stp);

Reviewed-by: Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2024-01-29 12:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29  3:29 [PATCH 00/13 v4] nfsd: support admin-revocation of v4 state NeilBrown
2024-01-29  3:29 ` [PATCH 01/13] nfsd: remove stale comment in nfs4_show_deleg() NeilBrown
2024-01-29  3:29 ` [PATCH 02/13] nfsd: hold ->cl_lock for hash_delegation_locked() NeilBrown
2024-01-29  3:29 ` [PATCH 03/13] nfsd: don't call functions with side-effecting inside WARN_ON() NeilBrown
2024-01-29 11:18   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 04/13] nfsd: avoid race after unhash_delegation_locked() NeilBrown
2024-01-29  3:29 ` [PATCH 05/13] nfsd: split sc_status out of sc_type NeilBrown
2024-01-29 12:21   ` Jeff Layton
2024-01-29 14:04   ` Chuck Lever
2024-01-29  3:29 ` [PATCH 06/13] nfsd: prepare for supporting admin-revocation of state NeilBrown
2024-01-29 12:22   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 07/13] nfsd: allow state with no file to appear in /proc/fs/nfsd/clients/*/states NeilBrown
2024-01-29 12:23   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 08/13] nfsd: report in /proc/fs/nfsd/clients/*/states when state is admin-revoke NeilBrown
2024-01-29 12:24   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 09/13] nfsd: allow admin-revoked NFSv4.0 state to be freed NeilBrown
2024-01-29 12:29   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 10/13] nfsd: allow lock state ids to be revoked and then freed NeilBrown
2024-01-29 12:30   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 11/13] nfsd: allow open " NeilBrown
2024-01-29 12:31   ` Jeff Layton [this message]
2024-01-29  3:29 ` [PATCH 12/13] nfsd: allow delegation " NeilBrown
2024-01-29 12:32   ` Jeff Layton
2024-01-29  3:29 ` [PATCH 13/13] nfsd: allow layout state to be admin-revoked NeilBrown
2024-01-29 12:38   ` Jeff Layton
2024-01-30  1:07     ` NeilBrown
  -- strict thread matches above, loose matches on Subject: below --
2024-01-30  1:08 [PATCH 00/13 v5] nfsd: support admin-revocation of v4 state NeilBrown
2024-01-30  1:08 ` [PATCH 11/13] nfsd: allow open state ids to be revoked and then freed NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e74341299eff72b61f2248c96d5841fea4819628.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=hch@lst.de \
    --cc=kolga@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=loghyr@gmail.com \
    --cc=neilb@suse.de \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).