Skip to content

Commit ba6cc97

Browse files
committed
svcrdma: Consolidate send_error helper functions
Final refactor: Replace internals of svc_rdma_send_error() with a simple call to svc_rdma_send_error_msg(). Signed-off-by: Chuck Lever <[email protected]>
1 parent c65b326 commit ba6cc97

File tree

1 file changed

+5
-47
lines changed

1 file changed

+5
-47
lines changed

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -714,58 +714,16 @@ static void rdma_read_complete(struct svc_rqst *rqstp,
714714
rqstp->rq_arg.buflen = head->rc_arg.buflen;
715715
}
716716

717-
static void svc_rdma_send_error(struct svcxprt_rdma *xprt,
717+
static void svc_rdma_send_error(struct svcxprt_rdma *rdma,
718718
struct svc_rdma_recv_ctxt *rctxt,
719719
int status)
720720
{
721-
__be32 *p, *rdma_argp = rctxt->rc_recv_buf;
722-
struct svc_rdma_send_ctxt *ctxt;
723-
int ret;
721+
struct svc_rdma_send_ctxt *sctxt;
724722

725-
ctxt = svc_rdma_send_ctxt_get(xprt);
726-
if (!ctxt)
723+
sctxt = svc_rdma_send_ctxt_get(rdma);
724+
if (!sctxt)
727725
return;
728-
729-
p = xdr_reserve_space(&ctxt->sc_stream,
730-
rpcrdma_fixed_maxsz * sizeof(*p));
731-
if (!p)
732-
goto put_ctxt;
733-
734-
*p++ = *rdma_argp;
735-
*p++ = *(rdma_argp + 1);
736-
*p++ = xprt->sc_fc_credits;
737-
*p = rdma_error;
738-
739-
switch (status) {
740-
case -EPROTONOSUPPORT:
741-
p = xdr_reserve_space(&ctxt->sc_stream, 3 * sizeof(*p));
742-
if (!p)
743-
goto put_ctxt;
744-
745-
*p++ = err_vers;
746-
*p++ = rpcrdma_version;
747-
*p = rpcrdma_version;
748-
trace_svcrdma_err_vers(*rdma_argp);
749-
break;
750-
default:
751-
p = xdr_reserve_space(&ctxt->sc_stream, sizeof(*p));
752-
if (!p)
753-
goto put_ctxt;
754-
755-
*p = err_chunk;
756-
trace_svcrdma_err_chunk(*rdma_argp);
757-
}
758-
759-
ctxt->sc_send_wr.num_sge = 1;
760-
ctxt->sc_send_wr.opcode = IB_WR_SEND;
761-
ctxt->sc_sges[0].length = ctxt->sc_hdrbuf.len;
762-
ret = svc_rdma_send(xprt, &ctxt->sc_send_wr);
763-
if (ret)
764-
goto put_ctxt;
765-
return;
766-
767-
put_ctxt:
768-
svc_rdma_send_ctxt_put(xprt, ctxt);
726+
svc_rdma_send_error_msg(rdma, sctxt, rctxt, status);
769727
}
770728

771729
/* By convention, backchannel calls arrive via rdma_msg type

0 commit comments

Comments
 (0)