Skip to content

Commit 4f200bd

Browse files
committed
svcrdma: Add a @status parameter to svc_rdma_send_error_msg()
The common "send RDMA_ERR" function should be in svc_rdma_sendto.c, since that is where the other Send-related functions are located. So from here, I will beef up svc_rdma_send_error_msg() and deprecate svc_rdma_send_error(). A generic svc_rdma_send_error_msg() will need to handle both ERR_CHUNK and ERR_VERS. Copy that logic from svc_rdma_send_error() to svc_rdma_send_error_msg(). Signed-off-by: Chuck Lever <[email protected]>
1 parent d1f6e23 commit 4f200bd

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma,
812812
*/
813813
static int svc_rdma_send_error_msg(struct svcxprt_rdma *rdma,
814814
struct svc_rdma_send_ctxt *sctxt,
815-
struct svc_rdma_recv_ctxt *rctxt)
815+
struct svc_rdma_recv_ctxt *rctxt,
816+
int status)
816817
{
817818
__be32 *rdma_argp = rctxt->rc_recv_buf;
818819
__be32 *p;
@@ -821,16 +822,35 @@ static int svc_rdma_send_error_msg(struct svcxprt_rdma *rdma,
821822
xdr_init_encode(&sctxt->sc_stream, &sctxt->sc_hdrbuf,
822823
sctxt->sc_xprt_buf, NULL);
823824

824-
p = xdr_reserve_space(&sctxt->sc_stream, RPCRDMA_HDRLEN_ERR);
825+
p = xdr_reserve_space(&sctxt->sc_stream,
826+
rpcrdma_fixed_maxsz * sizeof(*p));
825827
if (!p)
826828
return -ENOMSG;
827829

828830
*p++ = *rdma_argp;
829831
*p++ = *(rdma_argp + 1);
830832
*p++ = rdma->sc_fc_credits;
831-
*p++ = rdma_error;
832-
*p = err_chunk;
833-
trace_svcrdma_err_chunk(*rdma_argp);
833+
*p = rdma_error;
834+
835+
switch (status) {
836+
case -EPROTONOSUPPORT:
837+
p = xdr_reserve_space(&sctxt->sc_stream, 3 * sizeof(*p));
838+
if (!p)
839+
return -ENOMSG;
840+
841+
*p++ = err_vers;
842+
*p++ = rpcrdma_version;
843+
*p = rpcrdma_version;
844+
trace_svcrdma_err_vers(*rdma_argp);
845+
break;
846+
default:
847+
p = xdr_reserve_space(&sctxt->sc_stream, sizeof(*p));
848+
if (!p)
849+
return -ENOMSG;
850+
851+
*p = err_chunk;
852+
trace_svcrdma_err_chunk(*rdma_argp);
853+
}
834854

835855
sctxt->sc_send_wr.num_sge = 1;
836856
sctxt->sc_send_wr.opcode = IB_WR_SEND;
@@ -930,7 +950,7 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
930950
* of previously posted RDMA Writes.
931951
*/
932952
svc_rdma_save_io_pages(rqstp, sctxt);
933-
ret = svc_rdma_send_error_msg(rdma, sctxt, rctxt);
953+
ret = svc_rdma_send_error_msg(rdma, sctxt, rctxt, ret);
934954
if (ret < 0)
935955
goto err1;
936956
return 0;

0 commit comments

Comments
 (0)