Skip to content

Commit ff053db

Browse files
author
Trond Myklebust
committed
SUNRPC: Move the call to xprt_send_pagedata() out of xprt_sock_sendmsg()
The client and server have different requirements for their memory allocation, so move the allocation of the send buffer out of the socket send code that is common to both. Reported-by: NeilBrown <neilb@suse.de> Fixes: b264801 ("SUNRPC: Make the rpciod and xprtiod slab allocation modes consistent") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent b056fa0 commit ff053db

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

net/sunrpc/socklib.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ static int xprt_send_kvec(struct socket *sock, struct msghdr *msg,
221221
static int xprt_send_pagedata(struct socket *sock, struct msghdr *msg,
222222
struct xdr_buf *xdr, size_t base)
223223
{
224-
int err;
225-
226-
err = xdr_alloc_bvec(xdr, rpc_task_gfp_mask());
227-
if (err < 0)
228-
return err;
229-
230224
iov_iter_bvec(&msg->msg_iter, WRITE, xdr->bvec, xdr_buf_pagecount(xdr),
231225
xdr->page_len + xdr->page_base);
232226
return xprt_sendmsg(sock, msg, base + xdr->page_base);

net/sunrpc/svcsock.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,15 +579,18 @@ static int svc_udp_sendto(struct svc_rqst *rqstp)
579579
if (svc_xprt_is_dead(xprt))
580580
goto out_notconn;
581581

582+
err = xdr_alloc_bvec(xdr, GFP_KERNEL);
583+
if (err < 0)
584+
goto out_unlock;
585+
582586
err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent);
583-
xdr_free_bvec(xdr);
584587
if (err == -ECONNREFUSED) {
585588
/* ICMP error on earlier request. */
586589
err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent);
587-
xdr_free_bvec(xdr);
588590
}
591+
xdr_free_bvec(xdr);
589592
trace_svcsock_udp_send(xprt, err);
590-
593+
out_unlock:
591594
mutex_unlock(&xprt->xpt_mutex);
592595
if (err < 0)
593596
return err;

net/sunrpc/xprtsock.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,14 @@ static int xs_stream_nospace(struct rpc_rqst *req, bool vm_wait)
825825
static int
826826
xs_stream_prepare_request(struct rpc_rqst *req)
827827
{
828+
gfp_t gfp = rpc_task_gfp_mask();
829+
int ret;
830+
831+
ret = xdr_alloc_bvec(&req->rq_snd_buf, gfp);
832+
if (ret < 0)
833+
return ret;
828834
xdr_free_bvec(&req->rq_rcv_buf);
829-
return xdr_alloc_bvec(
830-
&req->rq_rcv_buf, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
835+
return xdr_alloc_bvec(&req->rq_rcv_buf, gfp);
831836
}
832837

833838
/*
@@ -956,6 +961,9 @@ static int xs_udp_send_request(struct rpc_rqst *req)
956961
if (!xprt_request_get_cong(xprt, req))
957962
return -EBADSLT;
958963

964+
status = xdr_alloc_bvec(xdr, rpc_task_gfp_mask());
965+
if (status < 0)
966+
return status;
959967
req->rq_xtime = ktime_get();
960968
status = xprt_sock_sendmsg(transport->sock, &msg, xdr, 0, 0, &sent);
961969

@@ -2554,6 +2562,9 @@ static int bc_sendto(struct rpc_rqst *req)
25542562
int err;
25552563

25562564
req->rq_xtime = ktime_get();
2565+
err = xdr_alloc_bvec(xdr, rpc_task_gfp_mask());
2566+
if (err < 0)
2567+
return err;
25572568
err = xprt_sock_sendmsg(transport->sock, &msg, xdr, 0, marker, &sent);
25582569
xdr_free_bvec(xdr);
25592570
if (err < 0 || sent != (xdr->len + sizeof(marker)))

0 commit comments

Comments
 (0)