From: NeilBrown <neilb@suse.de>
To: Chuck Lever <chuck.lever@oracle.com>, Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia <kolga@netapp.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Subject: [PATCH 10/11] nfsd: allow delegation state ids to be revoked and then freed
Date: Fri, 24 Nov 2023 11:28:45 +1100 [thread overview]
Message-ID: <20231124002925.1816-11-neilb@suse.de> (raw)
In-Reply-To: <20231124002925.1816-1-neilb@suse.de>
Revoking state through 'unlock_filesystem' now revokes any delegation
states found. When the stateids are then freed by the client, the
revoked stateids will be cleaned up correctly.
As there is already support for revoking delegations, we build on that
for admin-revoking.
Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/nfsd/nfs4state.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8712eb81123f..3d85c88ec4d7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1340,9 +1340,12 @@ unhash_delegation_locked(struct nfs4_delegation *dp, unsigned short statusmask)
if (!delegation_hashed(dp))
return false;
- if (dp->dl_stid.sc_client->cl_minorversion == 0)
+ if (statusmask == NFS4_STID_REVOKED &&
+ dp->dl_stid.sc_client->cl_minorversion == 0)
statusmask = NFS4_STID_CLOSED;
dp->dl_stid.sc_status |= statusmask;
+ if (statusmask & NFS4_STID_ADMIN_REVOKED)
+ atomic_inc(&dp->dl_stid.sc_client->cl_admin_revoked);
/* Ensure that deleg break won't try to requeue it */
++dp->dl_time;
@@ -1373,7 +1376,8 @@ static void revoke_delegation(struct nfs4_delegation *dp)
trace_nfsd_stid_revoke(&dp->dl_stid);
- if (dp->dl_stid.sc_status & NFS4_STID_REVOKED) {
+ if (dp->dl_stid.sc_status &
+ (NFS4_STID_REVOKED | NFS4_STID_ADMIN_REVOKED)) {
spin_lock(&clp->cl_lock);
refcount_inc(&dp->dl_stid.sc_count);
list_add(&dp->dl_recall_lru, &clp->cl_revoked);
@@ -1708,7 +1712,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
unsigned int idhashval;
unsigned int sc_types;
- sc_types = NFS4_OPEN_STID | NFS4_LOCK_STID;
+ sc_types = NFS4_OPEN_STID | NFS4_LOCK_STID | NFS4_DELEG_STID;
spin_lock(&nn->client_lock);
for (idhashval = 0; idhashval < CLIENT_HASH_MASK; idhashval++) {
@@ -1720,6 +1724,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
sc_types);
if (stid) {
struct nfs4_ol_stateid *stp;
+ struct nfs4_delegation *dp;
spin_unlock(&nn->client_lock);
switch (stid->sc_type) {
@@ -1765,6 +1770,16 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
spin_unlock(&clp->cl_lock);
mutex_unlock(&stp->st_mutex);
break;
+ case NFS4_DELEG_STID:
+ dp = delegstateid(stid);
+ spin_lock(&state_lock);
+ if (!unhash_delegation_locked(
+ dp, NFS4_STID_ADMIN_REVOKED))
+ dp = NULL;
+ spin_unlock(&state_lock);
+ if (dp)
+ revoke_delegation(dp);
+ break;
}
nfs4_put_stid(stid);
spin_lock(&nn->client_lock);
@@ -4705,6 +4720,7 @@ static void nfsd_drop_revoked_stid(struct nfs4_stid *s)
struct nfs4_client *cl = s->sc_client;
LIST_HEAD(reaplist);
struct nfs4_ol_stateid *stp;
+ struct nfs4_delegation *dp;
bool unhashed;
switch (s->sc_type) {
@@ -4722,6 +4738,12 @@ static void nfsd_drop_revoked_stid(struct nfs4_stid *s)
if (unhashed)
nfs4_put_stid(s);
break;
+ case NFS4_DELEG_STID:
+ dp = delegstateid(s);
+ list_del_init(&dp->dl_recall_lru);
+ spin_unlock(&cl->cl_lock);
+ nfs4_put_stid(s);
+ break;
default:
spin_unlock(&cl->cl_lock);
}
--
2.42.1
next prev parent reply other threads:[~2023-11-24 4:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 0:28 [PATCH 00/11 v4] nfsd: support admin-revocation of v4 state NeilBrown
2023-11-24 0:28 ` [PATCH 01/11] nfsd: hold ->cl_lock for hash_delegation_locked() NeilBrown
2023-11-24 0:28 ` [PATCH 02/11] nfsd: don't call functions with side-effecting inside WARN_ON() NeilBrown
2023-11-24 0:28 ` [PATCH 03/11] nfsd: avoid race after unhash_delegation_locked() NeilBrown
2023-11-24 0:28 ` [PATCH 04/11] nfsd: split sc_status out of sc_type NeilBrown
2023-11-24 0:28 ` [PATCH 05/11] nfsd: prepare for supporting admin-revocation of state NeilBrown
2023-11-26 17:36 ` Chuck Lever
2024-01-19 0:46 ` NeilBrown
2023-11-24 0:28 ` [PATCH 06/11] nfsd: allow admin-revoked state to appear in /proc/fs/nfsd/clients/*/states NeilBrown
2023-11-26 17:41 ` Chuck Lever
2023-11-24 0:28 ` [PATCH 07/11] nfsd: allow admin-revoked NFSv4.0 state to be freed NeilBrown
2023-11-26 17:54 ` Chuck Lever
2024-01-19 1:41 ` NeilBrown
2023-11-26 18:07 ` Chuck Lever
2024-01-19 1:43 ` NeilBrown
2023-11-24 0:28 ` [PATCH 08/11] nfsd: allow lock state ids to be revoked and then freed NeilBrown
2023-11-24 0:28 ` [PATCH 09/11] nfsd: allow open " NeilBrown
2023-11-24 0:28 ` NeilBrown [this message]
2023-11-30 4:48 ` [PATCH 10/11] nfsd: allow delegation " kernel test robot
2023-11-24 0:28 ` [PATCH 11/11] nfsd: allow layout state to be admin-revoked NeilBrown
2023-11-24 15:23 ` kernel test robot
2023-11-24 15:41 ` kernel test robot
2023-11-27 15:25 ` Chuck Lever
2023-12-22 15:01 ` Chuck Lever
2023-12-22 23:02 ` NeilBrown
-- strict thread matches above, loose matches on Subject: below --
2023-11-24 0:23 [PATCH 00/11 v4] nfsd: support admin-revocation of v4 state NeilBrown
2023-11-24 0:23 ` [PATCH 10/11] nfsd: allow delegation 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=20231124002925.1816-11-neilb@suse.de \
--to=neilb@suse.de \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=kolga@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--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