summaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2018-05-04 15:35:52 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-06-01 13:56:30 -0400
commited3aa7424566f35c51035748928575a35625e07e (patch)
treea6669e0651ec01a57d333ad8c8a25fba09b29ca4 /net/sunrpc
parenta8f688ec437dc2045cc8f0c89fe877d5803850da (diff)
xprtrdma: Move common wait_for_buffer_space call to parent function
Clean up: The logic to wait for write space is common to a bunch of the encoding helper functions. Lift it out and put it in the tail of rpcrdma_marshal_req(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/xprtrdma/rpc_rdma.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index 1d7857919d3d..b12b0443d33a 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -366,7 +366,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
366 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 366 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
367 false, &mr); 367 false, &mr);
368 if (IS_ERR(seg)) 368 if (IS_ERR(seg))
369 goto out_maperr; 369 return PTR_ERR(seg);
370 rpcrdma_mr_push(mr, &req->rl_registered); 370 rpcrdma_mr_push(mr, &req->rl_registered);
371 371
372 if (encode_read_segment(xdr, mr, pos) < 0) 372 if (encode_read_segment(xdr, mr, pos) < 0)
@@ -378,11 +378,6 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
378 } while (nsegs); 378 } while (nsegs);
379 379
380 return 0; 380 return 0;
381
382out_maperr:
383 if (PTR_ERR(seg) == -EAGAIN)
384 xprt_wait_for_buffer_space(rqst->rq_task, NULL);
385 return PTR_ERR(seg);
386} 381}
387 382
388/* Register and XDR encode the Write list. Supports encoding a list 383/* Register and XDR encode the Write list. Supports encoding a list
@@ -429,7 +424,7 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
429 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 424 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
430 true, &mr); 425 true, &mr);
431 if (IS_ERR(seg)) 426 if (IS_ERR(seg))
432 goto out_maperr; 427 return PTR_ERR(seg);
433 rpcrdma_mr_push(mr, &req->rl_registered); 428 rpcrdma_mr_push(mr, &req->rl_registered);
434 429
435 if (encode_rdma_segment(xdr, mr) < 0) 430 if (encode_rdma_segment(xdr, mr) < 0)
@@ -446,11 +441,6 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
446 *segcount = cpu_to_be32(nchunks); 441 *segcount = cpu_to_be32(nchunks);
447 442
448 return 0; 443 return 0;
449
450out_maperr:
451 if (PTR_ERR(seg) == -EAGAIN)
452 xprt_wait_for_buffer_space(rqst->rq_task, NULL);
453 return PTR_ERR(seg);
454} 444}
455 445
456/* Register and XDR encode the Reply chunk. Supports encoding an array 446/* Register and XDR encode the Reply chunk. Supports encoding an array
@@ -492,7 +482,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
492 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs, 482 seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
493 true, &mr); 483 true, &mr);
494 if (IS_ERR(seg)) 484 if (IS_ERR(seg))
495 goto out_maperr; 485 return PTR_ERR(seg);
496 rpcrdma_mr_push(mr, &req->rl_registered); 486 rpcrdma_mr_push(mr, &req->rl_registered);
497 487
498 if (encode_rdma_segment(xdr, mr) < 0) 488 if (encode_rdma_segment(xdr, mr) < 0)
@@ -509,11 +499,6 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
509 *segcount = cpu_to_be32(nchunks); 499 *segcount = cpu_to_be32(nchunks);
510 500
511 return 0; 501 return 0;
512
513out_maperr:
514 if (PTR_ERR(seg) == -EAGAIN)
515 xprt_wait_for_buffer_space(rqst->rq_task, NULL);
516 return PTR_ERR(seg);
517} 502}
518 503
519/** 504/**
@@ -884,7 +869,15 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
884 return 0; 869 return 0;
885 870
886out_err: 871out_err:
887 r_xprt->rx_stats.failed_marshal_count++; 872 switch (ret) {
873 case -EAGAIN:
874 xprt_wait_for_buffer_space(rqst->rq_task, NULL);
875 break;
876 case -ENOBUFS:
877 break;
878 default:
879 r_xprt->rx_stats.failed_marshal_count++;
880 }
888 return ret; 881 return ret;
889} 882}
890 883