Skip to content

Commit 631fc9e

Browse files
author
J. Bruce Fields
committed
nfsd4: allow removing clients not holding state
RFC 5661 actually says we should allow an exchange_id to remove a matching client, even if the exchange_id comes from a different principal, *if* the victim client lacks any state. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 136e658 commit 631fc9e

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎fs/nfsd/nfs4state.c‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,19 @@ nfsd4_set_ex_flags(struct nfs4_client *new, struct nfsd4_exchange_id *clid)
15081508
clid->flags = new->cl_exchange_flags;
15091509
}
15101510

1511+
static bool client_has_state(struct nfs4_client *clp)
1512+
{
1513+
/*
1514+
* Note clp->cl_openowners check isn't quite right: there's no
1515+
* need to count owners without stateid's.
1516+
*
1517+
* Also note we should probably be using this in 4.0 case too.
1518+
*/
1519+
return list_empty(&clp->cl_openowners)
1520+
&& list_empty(&clp->cl_delegations)
1521+
&& list_empty(&clp->cl_sessions);
1522+
}
1523+
15111524
__be32
15121525
nfsd4_exchange_id(struct svc_rqst *rqstp,
15131526
struct nfsd4_compound_state *cstate,
@@ -1576,15 +1589,19 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
15761589
goto out_copy;
15771590
}
15781591
if (!creds_match) { /* case 3 */
1579-
status = nfserr_clid_inuse;
1580-
goto out;
1592+
if (client_has_state(conf)) {
1593+
status = nfserr_clid_inuse;
1594+
goto out;
1595+
}
1596+
goto expire_client;
15811597
}
15821598
if (verfs_match) { /* case 2 */
15831599
exid->flags |= EXCHGID4_FLAG_CONFIRMED_R;
15841600
new = conf;
15851601
goto out_copy;
15861602
}
15871603
/* case 5, client reboot */
1604+
expire_client:
15881605
expire_client(conf);
15891606
goto out_new;
15901607
}

0 commit comments

Comments
 (0)