]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: Fix up RPC back channel transmission
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 5 Mar 2019 12:30:48 +0000 (07:30 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:11:41 +0000 (20:11 +0100)
commit 477687e1116ad16180caf8633dd830b296a5ce73 upstream.

Now that transmissions happen through a queue, we require the RPC tasks
to handle error conditions that may have been set while they were
sleeping. The back channel does not currently do this, but assumes
that any error condition happens during its own call to xprt_transmit().

The solution is to ensure that the back channel splits out the
error handling just like the forward channel does.

Fixes: 89f90fe1ad8b ("SUNRPC: Allow calls to xprt_transmit() to drain...")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/clnt.c

index 47d664ce64ba53257a8e9083ad60dbfb06b7875d..43939ab761234368d49fd0cc9b8590d0ac1681f2 100644 (file)
@@ -66,9 +66,6 @@ static void   call_decode(struct rpc_task *task);
 static void    call_bind(struct rpc_task *task);
 static void    call_bind_status(struct rpc_task *task);
 static void    call_transmit(struct rpc_task *task);
-#if defined(CONFIG_SUNRPC_BACKCHANNEL)
-static void    call_bc_transmit(struct rpc_task *task);
-#endif /* CONFIG_SUNRPC_BACKCHANNEL */
 static void    call_status(struct rpc_task *task);
 static void    call_transmit_status(struct rpc_task *task);
 static void    call_refresh(struct rpc_task *task);
@@ -1131,6 +1128,8 @@ rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
 EXPORT_SYMBOL_GPL(rpc_call_async);
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
+static void call_bc_encode(struct rpc_task *task);
+
 /**
  * rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run
  * rpc_execute against it
@@ -1152,7 +1151,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
        task = rpc_new_task(&task_setup_data);
        xprt_init_bc_request(req, task);
 
-       task->tk_action = call_bc_transmit;
+       task->tk_action = call_bc_encode;
        atomic_inc(&task->tk_count);
        WARN_ON_ONCE(atomic_read(&task->tk_count) != 2);
        rpc_execute(task);
@@ -2064,6 +2063,16 @@ call_transmit_status(struct rpc_task *task)
 }
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
+static void call_bc_transmit(struct rpc_task *task);
+static void call_bc_transmit_status(struct rpc_task *task);
+
+static void
+call_bc_encode(struct rpc_task *task)
+{
+       xprt_request_enqueue_transmit(task);
+       task->tk_action = call_bc_transmit;
+}
+
 /*
  * 5b. Send the backchannel RPC reply.  On error, drop the reply.  In
  * addition, disconnect on connectivity errors.
@@ -2071,26 +2080,23 @@ call_transmit_status(struct rpc_task *task)
 static void
 call_bc_transmit(struct rpc_task *task)
 {
-       struct rpc_rqst *req = task->tk_rqstp;
-
-       if (rpc_task_need_encode(task))
-               xprt_request_enqueue_transmit(task);
-       if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate))
-               goto out_wakeup;
-
-       if (!xprt_prepare_transmit(task))
-               goto out_retry;
-
-       if (task->tk_status < 0) {
-               printk(KERN_NOTICE "RPC: Could not send backchannel reply "
-                       "error: %d\n", task->tk_status);
-               goto out_done;
+       task->tk_action = call_bc_transmit_status;
+       if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) {
+               if (!xprt_prepare_transmit(task))
+                       return;
+               task->tk_status = 0;
+               xprt_transmit(task);
        }
+       xprt_end_transmit(task);
+}
 
-       xprt_transmit(task);
+static void
+call_bc_transmit_status(struct rpc_task *task)
+{
+       struct rpc_rqst *req = task->tk_rqstp;
 
-       xprt_end_transmit(task);
        dprint_status(task);
+
        switch (task->tk_status) {
        case 0:
                /* Success */
@@ -2104,8 +2110,14 @@ call_bc_transmit(struct rpc_task *task)
        case -ENOTCONN:
        case -EPIPE:
                break;
+       case -ENOBUFS:
+               rpc_delay(task, HZ>>2);
+               /* fall through */
+       case -EBADSLT:
        case -EAGAIN:
-               goto out_retry;
+               task->tk_status = 0;
+               task->tk_action = call_bc_transmit;
+               return;
        case -ETIMEDOUT:
                /*
                 * Problem reaching the server.  Disconnect and let the
@@ -2124,18 +2136,11 @@ call_bc_transmit(struct rpc_task *task)
                 * We were unable to reply and will have to drop the
                 * request.  The server should reconnect and retransmit.
                 */
-               WARN_ON_ONCE(task->tk_status == -EAGAIN);
                printk(KERN_NOTICE "RPC: Could not send backchannel reply "
                        "error: %d\n", task->tk_status);
                break;
        }
-out_wakeup:
-       rpc_wake_up_queued_task(&req->rq_xprt->pending, task);
-out_done:
        task->tk_action = rpc_exit_task;
-       return;
-out_retry:
-       task->tk_status = 0;
 }
 #endif /* CONFIG_SUNRPC_BACKCHANNEL */