SUNRPC: Ensure the bvecs are reset when we re-encode the RPC request
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 18 Jul 2019 01:22:38 +0000 (21:22 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 18 Jul 2019 18:43:52 +0000 (14:43 -0400)
The bvec tracks the list of pages, so if the number of pages changes
due to a re-encode, we need to reset the bvec as well.

Fixes: 277e4ab7d530 ("SUNRPC: Simplify TCP receive code by switching...")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: stable@vger.kernel.org # v4.20+
net/sunrpc/clnt.c
net/sunrpc/xprt.c
net/sunrpc/xprtsock.c

index 79c849391cb9737f9df5a5cf14f0cd42ad3d105f..d8679b6027e933a2130fafcecd12e57b9975c8db 100644 (file)
@@ -1865,6 +1865,7 @@ rpc_xdr_encode(struct rpc_task *task)
        req->rq_snd_buf.head[0].iov_len = 0;
        xdr_init_encode(&xdr, &req->rq_snd_buf,
                        req->rq_snd_buf.head[0].iov_base, req);
+       xdr_free_bvec(&req->rq_snd_buf);
        if (rpc_encode_header(task, &xdr))
                return;
 
@@ -1904,8 +1905,6 @@ call_encode(struct rpc_task *task)
                        rpc_call_rpcerror(task, task->tk_status);
                }
                return;
-       } else {
-               xprt_request_prepare(task->tk_rqstp);
        }
 
        /* Add task to reply queue before transmission to avoid races */
index 70a704c44c6d01cef42dc428a4f5e39ad8f99c98..783748dc5e6fbf59959380e024e99e42039d7956 100644 (file)
@@ -1041,6 +1041,8 @@ xprt_request_enqueue_receive(struct rpc_task *task)
 
        if (!xprt_request_need_enqueue_receive(task, req))
                return;
+
+       xprt_request_prepare(task->tk_rqstp);
        spin_lock(&xprt->queue_lock);
 
        /* Update the softirq receive buffer */
index 6b1fca51028a0c4ebbb7e0a687dbdc96db822e08..e2176c167a57918240b7b379621d1fe0c48cee97 100644 (file)
@@ -909,6 +909,7 @@ static int xs_nospace(struct rpc_rqst *req)
 static void
 xs_stream_prepare_request(struct rpc_rqst *req)
 {
+       xdr_free_bvec(&req->rq_rcv_buf);
        req->rq_task->tk_status = xdr_alloc_bvec(&req->rq_rcv_buf, GFP_KERNEL);
 }