[PATCH 6/6] nfsd: do not fence a client for a layout recall with no layouts left
From: Daejun Park via B4 Relay
Date: Tue Oct 06 2026 - 00:31:58 EST
From: Daejun Park <daejun7.park@xxxxxxxxxxx>
nfsd4_cb_layout_done() fences the client for any answer to a
CB_LAYOUTRECALL that it does not handle, without looking at whether the
layout stateid still has layouts. A LAYOUTRETURN can return the last
layout while the recall is still out. The Linux client answers
NFS4ERR_NOMATCHING_LAYOUT then, which RFC 8881 section 20.3.3 allows
for a client that holds no layouts for the file. A client that answers
NFS4ERR_BAD_STATEID is right too, since section 12.5.3 makes a layout
stateid invalid once the client has no layouts for the file, but it is
fenced for nothing.
Check for layouts before fencing, as the polls already do before their
time limit, and end the recall when none are left. This does not depend
on the earlier patches in this series.
A pynfs client that returns its layout on the recall and then answers
it NFS4ERR_BAD_STATEID: without this patch, nfsd logged "failed to
respond to layout recall" and ran the fence for it; with it, the recall
ended without either.
Fixes: c5c707f96fc9 ("nfsd: implement pNFS layout recalls")
Signed-off-by: Daejun Park <daejun7.park@xxxxxxxxxxx>
---
fs/nfsd/nfs4layouts.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index c140c9bde..345890add 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -803,6 +803,15 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task)
}
fallthrough;
default:
+ /*
+ * Nothing to fence for once the layouts are gone: a
+ * LAYOUTRETURN can return the last one while the recall is
+ * still out.
+ */
+ if (list_empty(&ls->ls_layouts)) {
+ trace_nfsd_layout_recall_done(&ls->ls_stid.sc_stateid);
+ return 1;
+ }
/*
* Unknown error or non-responding client, we'll need to fence.
*/
--
2.43.0