Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC: Add a transport callback to handle dequeuing of an RPC request

Add a transport level callback to allow it to handle the consequences of
dequeuing the request that was in the process of being transmitted.
For something like a TCP connection, we may need to disconnect if the
request was partially transmitted.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

+20
+1
include/linux/sunrpc/xprt.h
··· 152 152 int (*prepare_request)(struct rpc_rqst *req, 153 153 struct xdr_buf *buf); 154 154 int (*send_request)(struct rpc_rqst *req); 155 + void (*abort_send_request)(struct rpc_rqst *req); 155 156 void (*wait_for_reply_request)(struct rpc_task *task); 156 157 void (*timer)(struct rpc_xprt *xprt, struct rpc_task *task); 157 158 void (*release_request)(struct rpc_task *task);
+6
net/sunrpc/xprt.c
··· 1398 1398 if (!test_and_clear_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) 1399 1399 return; 1400 1400 if (!list_empty(&req->rq_xmit)) { 1401 + struct rpc_xprt *xprt = req->rq_xprt; 1402 + 1403 + if (list_is_first(&req->rq_xmit, &xprt->xmit_queue) && 1404 + xprt->ops->abort_send_request) 1405 + xprt->ops->abort_send_request(req); 1406 + 1401 1407 list_del(&req->rq_xmit); 1402 1408 if (!list_empty(&req->rq_xmit2)) { 1403 1409 struct rpc_rqst *next = list_first_entry(&req->rq_xmit2,
+13
net/sunrpc/xprtsock.c
··· 884 884 return xdr_alloc_bvec(buf, rpc_task_gfp_mask()); 885 885 } 886 886 887 + static void xs_stream_abort_send_request(struct rpc_rqst *req) 888 + { 889 + struct rpc_xprt *xprt = req->rq_xprt; 890 + struct sock_xprt *transport = 891 + container_of(xprt, struct sock_xprt, xprt); 892 + 893 + if (transport->xmit.offset != 0 && 894 + !test_bit(XPRT_CLOSE_WAIT, &xprt->state)) 895 + xprt_force_disconnect(xprt); 896 + } 897 + 887 898 /* 888 899 * Determine if the previous message in the stream was aborted before it 889 900 * could complete transmission. ··· 3040 3029 .buf_free = rpc_free, 3041 3030 .prepare_request = xs_stream_prepare_request, 3042 3031 .send_request = xs_local_send_request, 3032 + .abort_send_request = xs_stream_abort_send_request, 3043 3033 .wait_for_reply_request = xprt_wait_for_reply_request_def, 3044 3034 .close = xs_close, 3045 3035 .destroy = xs_destroy, ··· 3088 3076 .buf_free = rpc_free, 3089 3077 .prepare_request = xs_stream_prepare_request, 3090 3078 .send_request = xs_tcp_send_request, 3079 + .abort_send_request = xs_stream_abort_send_request, 3091 3080 .wait_for_reply_request = xprt_wait_for_reply_request_def, 3092 3081 .close = xs_tcp_shutdown, 3093 3082 .destroy = xs_destroy,