Skip to content

Commit 857f9ac

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Change return value of rpcrdma_prepare_send_sges()
Clean up: Make rpcrdma_prepare_send_sges() return a negative errno instead of a bool. Soon callers will want distinct treatments of different types of failures. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 394b2c7 commit 857f9ac

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst)
222222
*p++ = xdr_zero;
223223
*p = xdr_zero;
224224

225-
if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req, RPCRDMA_HDRLEN_MIN,
226-
&rqst->rq_snd_buf, rpcrdma_noch))
225+
if (rpcrdma_prepare_send_sges(r_xprt, req, RPCRDMA_HDRLEN_MIN,
226+
&rqst->rq_snd_buf, rpcrdma_noch))
227227
return -EIO;
228228
return 0;
229229
}

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
544544

545545
if (unlikely(!rpcrdma_regbuf_is_mapped(rb))) {
546546
if (!__rpcrdma_dma_map_regbuf(ia, rb))
547-
return false;
547+
goto out_regbuf;
548548
sge->addr = rdmab_addr(rb);
549549
sge->lkey = rdmab_lkey(rb);
550550
}
@@ -554,6 +554,10 @@ rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
554554
sge->length, DMA_TO_DEVICE);
555555
req->rl_send_wr.num_sge++;
556556
return true;
557+
558+
out_regbuf:
559+
pr_err("rpcrdma: failed to DMA map a Send buffer\n");
560+
return false;
557561
}
558562

559563
/* Prepare the Send SGEs. The head and tail iovec, and each entry
@@ -574,7 +578,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
574578
* DMA-mapped. Sync the content that has changed.
575579
*/
576580
if (!rpcrdma_dma_map_regbuf(ia, rb))
577-
return false;
581+
goto out_regbuf;
578582
sge_no = 1;
579583
sge[sge_no].addr = rdmab_addr(rb);
580584
sge[sge_no].length = xdr->head[0].iov_len;
@@ -662,6 +666,10 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
662666
req->rl_send_wr.num_sge += sge_no;
663667
return true;
664668

669+
out_regbuf:
670+
pr_err("rpcrdma: failed to DMA map a Send buffer\n");
671+
return false;
672+
665673
out_mapping_overflow:
666674
rpcrdma_unmap_sges(ia, req);
667675
pr_err("rpcrdma: too many Send SGEs (%u)\n", sge_no);
@@ -673,26 +681,32 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
673681
return false;
674682
}
675683

676-
bool
677-
rpcrdma_prepare_send_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req,
678-
u32 hdrlen, struct xdr_buf *xdr,
679-
enum rpcrdma_chunktype rtype)
684+
/**
685+
* rpcrdma_prepare_send_sges - Construct SGEs for a Send WR
686+
* @r_xprt: controlling transport
687+
* @req: context of RPC Call being marshalled
688+
* @hdrlen: size of transport header, in bytes
689+
* @xdr: xdr_buf containing RPC Call
690+
* @rtype: chunk type being encoded
691+
*
692+
* Returns 0 on success; otherwise a negative errno is returned.
693+
*/
694+
int
695+
rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt,
696+
struct rpcrdma_req *req, u32 hdrlen,
697+
struct xdr_buf *xdr, enum rpcrdma_chunktype rtype)
680698
{
681699
req->rl_send_wr.num_sge = 0;
682700
req->rl_mapped_sges = 0;
683701

684-
if (!rpcrdma_prepare_hdr_sge(ia, req, hdrlen))
685-
goto out_map;
702+
if (!rpcrdma_prepare_hdr_sge(&r_xprt->rx_ia, req, hdrlen))
703+
return -EIO;
686704

687705
if (rtype != rpcrdma_areadch)
688-
if (!rpcrdma_prepare_msg_sges(ia, req, xdr, rtype))
689-
goto out_map;
690-
691-
return true;
706+
if (!rpcrdma_prepare_msg_sges(&r_xprt->rx_ia, req, xdr, rtype))
707+
return -EIO;
692708

693-
out_map:
694-
pr_err("rpcrdma: failed to DMA map a Send buffer\n");
695-
return false;
709+
return 0;
696710
}
697711

698712
/**
@@ -843,12 +857,10 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
843857
transfertypes[rtype], transfertypes[wtype],
844858
xdr_stream_pos(xdr));
845859

846-
if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req,
847-
xdr_stream_pos(xdr),
848-
&rqst->rq_snd_buf, rtype)) {
849-
ret = -EIO;
860+
ret = rpcrdma_prepare_send_sges(r_xprt, req, xdr_stream_pos(xdr),
861+
&rqst->rq_snd_buf, rtype);
862+
if (ret)
850863
goto out_err;
851-
}
852864
return 0;
853865

854866
out_err:

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,10 @@ enum rpcrdma_chunktype {
613613
rpcrdma_replych
614614
};
615615

616-
bool rpcrdma_prepare_send_sges(struct rpcrdma_ia *, struct rpcrdma_req *,
617-
u32, struct xdr_buf *, enum rpcrdma_chunktype);
616+
int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt,
617+
struct rpcrdma_req *req, u32 hdrlen,
618+
struct xdr_buf *xdr,
619+
enum rpcrdma_chunktype rtype);
618620
void rpcrdma_unmap_sges(struct rpcrdma_ia *, struct rpcrdma_req *);
619621
int rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst);
620622
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *);

0 commit comments

Comments
 (0)