Skip to content

Commit 39657c7

Browse files
neilbrownchucklever
authored andcommitted
nfsd: allow open state ids to be revoked and then freed
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. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 1c13bf9 commit 39657c7

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

fs/nfsd/nfs4state.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
17171717
unsigned int idhashval;
17181718
unsigned int sc_types;
17191719

1720-
sc_types = SC_TYPE_LOCK;
1720+
sc_types = SC_TYPE_OPEN | SC_TYPE_LOCK;
17211721

17221722
spin_lock(&nn->client_lock);
17231723
for (idhashval = 0; idhashval < CLIENT_HASH_MASK; idhashval++) {
@@ -1732,6 +1732,22 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb)
17321732

17331733
spin_unlock(&nn->client_lock);
17341734
switch (stid->sc_type) {
1735+
case SC_TYPE_OPEN:
1736+
stp = openlockstateid(stid);
1737+
mutex_lock_nested(&stp->st_mutex,
1738+
OPEN_STATEID_MUTEX);
1739+
1740+
spin_lock(&clp->cl_lock);
1741+
if (stid->sc_status == 0) {
1742+
stid->sc_status |=
1743+
SC_STATUS_ADMIN_REVOKED;
1744+
atomic_inc(&clp->cl_admin_revoked);
1745+
spin_unlock(&clp->cl_lock);
1746+
release_all_access(stp);
1747+
} else
1748+
spin_unlock(&clp->cl_lock);
1749+
mutex_unlock(&stp->st_mutex);
1750+
break;
17351751
case SC_TYPE_LOCK:
17361752
stp = openlockstateid(stid);
17371753
mutex_lock_nested(&stp->st_mutex,
@@ -4663,6 +4679,13 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)
46634679
bool unhashed;
46644680

46654681
switch (s->sc_type) {
4682+
case SC_TYPE_OPEN:
4683+
stp = openlockstateid(s);
4684+
if (unhash_open_stateid(stp, &reaplist))
4685+
put_ol_stateid_locked(stp, &reaplist);
4686+
spin_unlock(&cl->cl_lock);
4687+
free_ol_stateid_reaplist(&reaplist);
4688+
break;
46664689
case SC_TYPE_LOCK:
46674690
stp = openlockstateid(s);
46684691
unhashed = unhash_lock_stateid(stp);

0 commit comments

Comments
 (0)