mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-13 16:11:54 +00:00
svcrdma: svc_rdma_post_recv() should close connection on error
Clean up: Most svc_rdma_post_recv() call sites close the transport connection when a receive cannot be posted. Wrap that in a common helper. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Devesh Sharma <devesh.sharma@broadcom.com> Tested-by: Devesh Sharma <devesh.sharma@broadcom.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
3e1eeb9808
commit
bf36387ad3
@ -234,6 +234,7 @@ extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *);
|
|||||||
extern void svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *,
|
extern void svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *,
|
||||||
enum rpcrdma_errcode);
|
enum rpcrdma_errcode);
|
||||||
extern int svc_rdma_post_recv(struct svcxprt_rdma *, gfp_t);
|
extern int svc_rdma_post_recv(struct svcxprt_rdma *, gfp_t);
|
||||||
|
extern int svc_rdma_repost_recv(struct svcxprt_rdma *, gfp_t);
|
||||||
extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
|
extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
|
||||||
extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
|
extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
|
||||||
extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
|
extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
|
||||||
|
@ -111,16 +111,9 @@ static int svc_rdma_bc_sendto(struct svcxprt_rdma *rdma,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
/* Post a recv buffer to handle the reply for this request. */
|
ret = svc_rdma_repost_recv(rdma, GFP_NOIO);
|
||||||
ret = svc_rdma_post_recv(rdma, GFP_NOIO);
|
if (ret)
|
||||||
if (ret) {
|
|
||||||
pr_err("svcrdma: Failed to post bc receive buffer, err=%d.\n",
|
|
||||||
ret);
|
|
||||||
pr_err("svcrdma: closing transport %p.\n", rdma);
|
|
||||||
set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
|
|
||||||
ret = -ENOTCONN;
|
|
||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
|
||||||
|
|
||||||
ctxt = svc_rdma_get_context(rdma);
|
ctxt = svc_rdma_get_context(rdma);
|
||||||
ctxt->pages[0] = virt_to_page(rqst->rq_buffer);
|
ctxt->pages[0] = virt_to_page(rqst->rq_buffer);
|
||||||
|
@ -711,13 +711,5 @@ defer:
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
repost:
|
repost:
|
||||||
ret = svc_rdma_post_recv(rdma_xprt, GFP_KERNEL);
|
return svc_rdma_repost_recv(rdma_xprt, GFP_KERNEL);
|
||||||
if (ret) {
|
|
||||||
pr_err("svcrdma: could not post a receive buffer, err=%d.\n",
|
|
||||||
ret);
|
|
||||||
pr_err("svcrdma: closing transport %p.\n", rdma_xprt);
|
|
||||||
set_bit(XPT_CLOSE, &rdma_xprt->sc_xprt.xpt_flags);
|
|
||||||
ret = -ENOTCONN;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -475,13 +475,8 @@ static int send_reply(struct svcxprt_rdma *rdma,
|
|||||||
int pages;
|
int pages;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Post a recv buffer to handle another request. */
|
ret = svc_rdma_repost_recv(rdma, GFP_KERNEL);
|
||||||
ret = svc_rdma_post_recv(rdma, GFP_KERNEL);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_INFO
|
|
||||||
"svcrdma: could not post a receive buffer, err=%d."
|
|
||||||
"Closing transport %p.\n", ret, rdma);
|
|
||||||
set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
|
|
||||||
svc_rdma_put_context(ctxt, 0);
|
svc_rdma_put_context(ctxt, 0);
|
||||||
return -ENOTCONN;
|
return -ENOTCONN;
|
||||||
}
|
}
|
||||||
|
@ -722,6 +722,21 @@ int svc_rdma_post_recv(struct svcxprt_rdma *xprt, gfp_t flags)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int svc_rdma_repost_recv(struct svcxprt_rdma *xprt, gfp_t flags)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
ret = svc_rdma_post_recv(xprt, flags);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("svcrdma: could not post a receive buffer, err=%d.\n",
|
||||||
|
ret);
|
||||||
|
pr_err("svcrdma: closing transport %p.\n", xprt);
|
||||||
|
set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags);
|
||||||
|
ret = -ENOTCONN;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function handles the CONNECT_REQUEST event on a listening
|
* This function handles the CONNECT_REQUEST event on a listening
|
||||||
* endpoint. It is passed the cma_id for the _new_ connection. The context in
|
* endpoint. It is passed the cma_id for the _new_ connection. The context in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user