[PATCH v2 2/2] NFSv4/flexfiles: limit transport disconnects when cancelling I/O
From: tmenninger
Date: Wed Nov 04 2026 - 23:28:25 EST
From: Tim Menninger <tmenninger@xxxxxxxxxxxxxxxx>
ff_layout_cancel_io() cancels RPC tasks associated with a recalled or
revoked layout segment. If any matching tasks are found, it then calls
rpc_clnt_disconnect().
rpc_clnt_disconnect() disconnects every transport attached to the RPC
client. A data server client can have multiple transports, while the
cancelled requests may have used only a subset of them. Cancelling I/O
for one layout segment can therefore disrupt unrelated I/O using other
transports belonging to the same data server client.
This is particularly disruptive with RPC/RDMA during data server
recovery, where unnecessary transport disconnects can result in repeated
reconnect activity on otherwise unaffected connections.
Use rpc_cancel_tasks_and_disconnect() instead. Matching tasks are still
cancelled, but only matching requests belonging to that client that
remain on the transport transmit or receive queues are marked for
disconnect. When such a request is released, SUNRPC conditionally
disconnects the connection generation on which that request was sent.
This preserves cancellation and draining of I/O associated with the
layout segment without disconnecting unrelated transports attached to
the same RPC client.
Fixes: b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked")
Signed-off-by: Tim Menninger <tmenninger@xxxxxxxxxxxxxxxx>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 9492d6bc1d1a7..700f0e4606e8f 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -2599,10 +2599,9 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg,
clnt = ds_clp->cl_rpcclient;
if (!clnt)
goto next;
- if (!rpc_cancel_tasks(clnt, -ECANCELED,
- ff_layout_match_io, lseg))
- goto next;
- rpc_clnt_disconnect(clnt);
+ rpc_cancel_tasks_and_disconnect(clnt, -ECANCELED,
+ ff_layout_match_io,
+ lseg);
next:
nfs4_ff_layout_put_deviceid(mirror_ds);
}
--
2.53.0