nfsd: lift NFSv4.0 handling out of nfsd4_cb_sequence_done()
authorJeff Layton <jlayton@kernel.org>
Sun, 9 Feb 2025 12:31:23 +0000 (07:31 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 10 Mar 2025 13:11:01 +0000 (09:11 -0400)
It's a bit strange to call nfsd4_cb_sequence_done() on a callback with no
CB_SEQUENCE. Lift the handling of restarting a call into a new helper,
and move the handling of NFSv4.0 into nfsd4_cb_done().

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4callback.c

index 041c5e7432f0b39c03f91f76f019f4885323ac05..5eabba4cc6c5ef1750518000c177ebee5923c221 100644 (file)
@@ -1064,6 +1064,17 @@ static bool nfsd4_queue_cb(struct nfsd4_callback *cb)
        return queue_work(clp->cl_callback_wq, &cb->cb_work);
 }
 
+static void nfsd4_requeue_cb(struct rpc_task *task, struct nfsd4_callback *cb)
+{
+       struct nfs4_client *clp = cb->cb_clp;
+
+       if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) {
+               trace_nfsd_cb_restart(clp, cb);
+               task->tk_status = 0;
+               cb->cb_need_restart = true;
+       }
+}
+
 static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
 {
        atomic_inc(&clp->cl_cb_inflight);
@@ -1331,26 +1342,9 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata)
 /* Returns true if CB_COMPOUND processing should continue */
 static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback *cb)
 {
-       struct nfs4_client *clp = cb->cb_clp;
-       struct nfsd4_session *session = clp->cl_cb_session;
+       struct nfsd4_session *session = cb->cb_clp->cl_cb_session;
        bool ret = false;
 
-       if (!clp->cl_minorversion) {
-               /*
-                * If the backchannel connection was shut down while this
-                * task was queued, we need to resubmit it after setting up
-                * a new backchannel connection.
-                *
-                * Note that if we lost our callback connection permanently
-                * the submission code will error out, so we don't need to
-                * handle that case here.
-                */
-               if (RPC_SIGNALLED(task))
-                       goto requeue;
-
-               return true;
-       }
-
        if (cb->cb_held_slot < 0)
                goto requeue;
 
@@ -1411,11 +1405,7 @@ retry_nowait:
        rpc_restart_call_prepare(task);
        goto out;
 requeue:
-       if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) {
-               trace_nfsd_cb_restart(clp, cb);
-               task->tk_status = 0;
-               cb->cb_need_restart = true;
-       }
+       nfsd4_requeue_cb(task, cb);
        return false;
 }
 
@@ -1426,8 +1416,21 @@ static void nfsd4_cb_done(struct rpc_task *task, void *calldata)
 
        trace_nfsd_cb_rpc_done(clp);
 
-       if (!nfsd4_cb_sequence_done(task, cb))
+       if (!clp->cl_minorversion) {
+               /*
+                * If the backchannel connection was shut down while this
+                * task was queued, we need to resubmit it after setting up
+                * a new backchannel connection.
+                *
+                * Note that if we lost our callback connection permanently
+                * the submission code will error out, so we don't need to
+                * handle that case here.
+                */
+               if (RPC_SIGNALLED(task))
+                       nfsd4_requeue_cb(task, cb);
+       } else if (!nfsd4_cb_sequence_done(task, cb)) {
                return;
+       }
 
        if (cb->cb_status) {
                WARN_ONCE(task->tk_status,