Skip to content

Commit ed3aa74

Browse files
chuckleveramschuma-ntap
authored andcommitted
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>
1 parent a8f688e commit ed3aa74

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
366366
seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
367367
false, &mr);
368368
if (IS_ERR(seg))
369-
goto out_maperr;
369+
return PTR_ERR(seg);
370370
rpcrdma_mr_push(mr, &req->rl_registered);
371371

372372
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,
378378
} while (nsegs);
379379

380380
return 0;
381-
382-
out_maperr:
383-
if (PTR_ERR(seg) == -EAGAIN)
384-
xprt_wait_for_buffer_space(rqst->rq_task, NULL);
385-
return PTR_ERR(seg);
386381
}
387382

388383
/* 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,
429424
seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
430425
true, &mr);
431426
if (IS_ERR(seg))
432-
goto out_maperr;
427+
return PTR_ERR(seg);
433428
rpcrdma_mr_push(mr, &req->rl_registered);
434429

435430
if (encode_rdma_segment(xdr, mr) < 0)
@@ -446,11 +441,6 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
446441
*segcount = cpu_to_be32(nchunks);
447442

448443
return 0;
449-
450-
out_maperr:
451-
if (PTR_ERR(seg) == -EAGAIN)
452-
xprt_wait_for_buffer_space(rqst->rq_task, NULL);
453-
return PTR_ERR(seg);
454444
}
455445

456446
/* 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,
492482
seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
493483
true, &mr);
494484
if (IS_ERR(seg))
495-
goto out_maperr;
485+
return PTR_ERR(seg);
496486
rpcrdma_mr_push(mr, &req->rl_registered);
497487

498488
if (encode_rdma_segment(xdr, mr) < 0)
@@ -509,11 +499,6 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
509499
*segcount = cpu_to_be32(nchunks);
510500

511501
return 0;
512-
513-
out_maperr:
514-
if (PTR_ERR(seg) == -EAGAIN)
515-
xprt_wait_for_buffer_space(rqst->rq_task, NULL);
516-
return PTR_ERR(seg);
517502
}
518503

519504
/**
@@ -884,7 +869,15 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
884869
return 0;
885870

886871
out_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+
}
888881
return ret;
889882
}
890883

0 commit comments

Comments
 (0)