Skip to content

Commit 6622e3a

Browse files
author
Trond Myklebust
committed
SUNRPC: Reinitialise the backchannel request buffers before reuse
When we're reusing the backchannel requests instead of freeing them, then we should reinitialise any values of the send/receive xdr_bufs so that they reflect the available space. Fixes: 0d2a970 ("SUNRPC: Fix a backchannel race") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent e35a5e7 commit 6622e3a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

net/sunrpc/backchannel_rqst.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ static void xprt_free_allocation(struct rpc_rqst *req)
6464
kfree(req);
6565
}
6666

67+
static void xprt_bc_reinit_xdr_buf(struct xdr_buf *buf)
68+
{
69+
buf->head[0].iov_len = PAGE_SIZE;
70+
buf->tail[0].iov_len = 0;
71+
buf->pages = NULL;
72+
buf->page_len = 0;
73+
buf->flags = 0;
74+
buf->len = 0;
75+
buf->buflen = PAGE_SIZE;
76+
}
77+
6778
static int xprt_alloc_xdr_buf(struct xdr_buf *buf, gfp_t gfp_flags)
6879
{
6980
struct page *page;
@@ -292,6 +303,9 @@ void xprt_free_bc_rqst(struct rpc_rqst *req)
292303
*/
293304
spin_lock_bh(&xprt->bc_pa_lock);
294305
if (xprt_need_to_requeue(xprt)) {
306+
xprt_bc_reinit_xdr_buf(&req->rq_snd_buf);
307+
xprt_bc_reinit_xdr_buf(&req->rq_rcv_buf);
308+
req->rq_rcv_buf.len = PAGE_SIZE;
295309
list_add_tail(&req->rq_bc_pa_list, &xprt->bc_pa_list);
296310
xprt->bc_alloc_count++;
297311
atomic_inc(&xprt->bc_slot_count);

0 commit comments

Comments
 (0)