Commit f764a1e1 authored by Trond Myklebust's avatar Trond Myklebust

Merge tag 'nfs-rdma-for-5.7-1' of git://git.linux-nfs.org/projects/anna/linux-nfs

NFSoRDMA Client Updates for Linux 5.7

New Features:
- Allow one active connection and several zombie connections to prevent
  blocking if the remote server is unresponsive.

Bugfixes and Cleanups:
- Enhance MR-related trace points
- Refactor connection set-up and disconnect functions
- Make Protection Domains per-connection instead of per-transport
- Merge struct rpcrdma_ia into rpcrdma_ep
parents 1de3af98 e28ce900
...@@ -104,12 +104,12 @@ DECLARE_EVENT_CLASS(xprtrdma_connect_class, ...@@ -104,12 +104,12 @@ DECLARE_EVENT_CLASS(xprtrdma_connect_class,
TP_fast_assign( TP_fast_assign(
__entry->r_xprt = r_xprt; __entry->r_xprt = r_xprt;
__entry->rc = rc; __entry->rc = rc;
__entry->connect_status = r_xprt->rx_ep.rep_connected; __entry->connect_status = r_xprt->rx_ep->re_connect_status;
__assign_str(addr, rpcrdma_addrstr(r_xprt)); __assign_str(addr, rpcrdma_addrstr(r_xprt));
__assign_str(port, rpcrdma_portstr(r_xprt)); __assign_str(port, rpcrdma_portstr(r_xprt));
), ),
TP_printk("peer=[%s]:%s r_xprt=%p: rc=%d connect status=%d", TP_printk("peer=[%s]:%s r_xprt=%p: rc=%d connection status=%d",
__get_str(addr), __get_str(port), __entry->r_xprt, __get_str(addr), __get_str(port), __entry->r_xprt,
__entry->rc, __entry->connect_status __entry->rc, __entry->connect_status
) )
...@@ -228,20 +228,20 @@ DECLARE_EVENT_CLASS(xprtrdma_frwr_done, ...@@ -228,20 +228,20 @@ DECLARE_EVENT_CLASS(xprtrdma_frwr_done,
TP_ARGS(wc, frwr), TP_ARGS(wc, frwr),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(unsigned int, status) __field(unsigned int, status)
__field(unsigned int, vendor_err) __field(unsigned int, vendor_err)
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = container_of(frwr, struct rpcrdma_mr, frwr); __entry->mr_id = frwr->fr_mr->res.id;
__entry->status = wc->status; __entry->status = wc->status;
__entry->vendor_err = __entry->status ? wc->vendor_err : 0; __entry->vendor_err = __entry->status ? wc->vendor_err : 0;
), ),
TP_printk( TP_printk(
"mr=%p: %s (%u/0x%x)", "mr.id=%u: %s (%u/0x%x)",
__entry->mr, rdma_show_wc_status(__entry->status), __entry->mr_id, rdma_show_wc_status(__entry->status),
__entry->status, __entry->vendor_err __entry->status, __entry->vendor_err
) )
); );
...@@ -274,7 +274,8 @@ DECLARE_EVENT_CLASS(xprtrdma_mr, ...@@ -274,7 +274,8 @@ DECLARE_EVENT_CLASS(xprtrdma_mr,
TP_ARGS(mr), TP_ARGS(mr),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(int, nents)
__field(u32, handle) __field(u32, handle)
__field(u32, length) __field(u32, length)
__field(u64, offset) __field(u64, offset)
...@@ -282,15 +283,16 @@ DECLARE_EVENT_CLASS(xprtrdma_mr, ...@@ -282,15 +283,16 @@ DECLARE_EVENT_CLASS(xprtrdma_mr,
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = mr; __entry->mr_id = mr->frwr.fr_mr->res.id;
__entry->nents = mr->mr_nents;
__entry->handle = mr->mr_handle; __entry->handle = mr->mr_handle;
__entry->length = mr->mr_length; __entry->length = mr->mr_length;
__entry->offset = mr->mr_offset; __entry->offset = mr->mr_offset;
__entry->dir = mr->mr_dir; __entry->dir = mr->mr_dir;
), ),
TP_printk("mr=%p %u@0x%016llx:0x%08x (%s)", TP_printk("mr.id=%u nents=%d %u@0x%016llx:0x%08x (%s)",
__entry->mr, __entry->length, __entry->mr_id, __entry->nents, __entry->length,
(unsigned long long)__entry->offset, __entry->handle, (unsigned long long)__entry->offset, __entry->handle,
xprtrdma_show_direction(__entry->dir) xprtrdma_show_direction(__entry->dir)
) )
...@@ -340,68 +342,37 @@ DECLARE_EVENT_CLASS(xprtrdma_cb_event, ...@@ -340,68 +342,37 @@ DECLARE_EVENT_CLASS(xprtrdma_cb_event,
** Connection events ** Connection events
**/ **/
TRACE_EVENT(xprtrdma_cm_event,
TP_PROTO(
const struct rpcrdma_xprt *r_xprt,
struct rdma_cm_event *event
),
TP_ARGS(r_xprt, event),
TP_STRUCT__entry(
__field(const void *, r_xprt)
__field(unsigned int, event)
__field(int, status)
__string(addr, rpcrdma_addrstr(r_xprt))
__string(port, rpcrdma_portstr(r_xprt))
),
TP_fast_assign(
__entry->r_xprt = r_xprt;
__entry->event = event->event;
__entry->status = event->status;
__assign_str(addr, rpcrdma_addrstr(r_xprt));
__assign_str(port, rpcrdma_portstr(r_xprt));
),
TP_printk("peer=[%s]:%s r_xprt=%p: %s (%u/%d)",
__get_str(addr), __get_str(port),
__entry->r_xprt, rdma_show_cm_event(__entry->event),
__entry->event, __entry->status
)
);
TRACE_EVENT(xprtrdma_inline_thresh, TRACE_EVENT(xprtrdma_inline_thresh,
TP_PROTO( TP_PROTO(
const struct rpcrdma_xprt *r_xprt const struct rpcrdma_ep *ep
), ),
TP_ARGS(r_xprt), TP_ARGS(ep),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, r_xprt)
__field(unsigned int, inline_send) __field(unsigned int, inline_send)
__field(unsigned int, inline_recv) __field(unsigned int, inline_recv)
__field(unsigned int, max_send) __field(unsigned int, max_send)
__field(unsigned int, max_recv) __field(unsigned int, max_recv)
__string(addr, rpcrdma_addrstr(r_xprt)) __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
__string(port, rpcrdma_portstr(r_xprt)) __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
), ),
TP_fast_assign( TP_fast_assign(
const struct rpcrdma_ep *ep = &r_xprt->rx_ep; const struct rdma_cm_id *id = ep->re_id;
__entry->r_xprt = r_xprt; __entry->inline_send = ep->re_inline_send;
__entry->inline_send = ep->rep_inline_send; __entry->inline_recv = ep->re_inline_recv;
__entry->inline_recv = ep->rep_inline_recv; __entry->max_send = ep->re_max_inline_send;
__entry->max_send = ep->rep_max_inline_send; __entry->max_recv = ep->re_max_inline_recv;
__entry->max_recv = ep->rep_max_inline_recv; memcpy(__entry->srcaddr, &id->route.addr.src_addr,
__assign_str(addr, rpcrdma_addrstr(r_xprt)); sizeof(struct sockaddr_in6));
__assign_str(port, rpcrdma_portstr(r_xprt)); memcpy(__entry->dstaddr, &id->route.addr.dst_addr,
sizeof(struct sockaddr_in6));
), ),
TP_printk("peer=[%s]:%s r_xprt=%p neg send/recv=%u/%u, calc send/recv=%u/%u", TP_printk("%pISpc -> %pISpc neg send/recv=%u/%u, calc send/recv=%u/%u",
__get_str(addr), __get_str(port), __entry->r_xprt, __entry->srcaddr, __entry->dstaddr,
__entry->inline_send, __entry->inline_recv, __entry->inline_send, __entry->inline_recv,
__entry->max_send, __entry->max_recv __entry->max_send, __entry->max_recv
) )
...@@ -409,11 +380,10 @@ TRACE_EVENT(xprtrdma_inline_thresh, ...@@ -409,11 +380,10 @@ TRACE_EVENT(xprtrdma_inline_thresh,
DEFINE_CONN_EVENT(connect); DEFINE_CONN_EVENT(connect);
DEFINE_CONN_EVENT(disconnect); DEFINE_CONN_EVENT(disconnect);
DEFINE_CONN_EVENT(flush_dct);
DEFINE_RXPRT_EVENT(xprtrdma_create); DEFINE_RXPRT_EVENT(xprtrdma_create);
DEFINE_RXPRT_EVENT(xprtrdma_op_destroy); DEFINE_RXPRT_EVENT(xprtrdma_op_destroy);
DEFINE_RXPRT_EVENT(xprtrdma_remove);
DEFINE_RXPRT_EVENT(xprtrdma_reinsert);
DEFINE_RXPRT_EVENT(xprtrdma_op_inject_dsc); DEFINE_RXPRT_EVENT(xprtrdma_op_inject_dsc);
DEFINE_RXPRT_EVENT(xprtrdma_op_close); DEFINE_RXPRT_EVENT(xprtrdma_op_close);
DEFINE_RXPRT_EVENT(xprtrdma_op_setport); DEFINE_RXPRT_EVENT(xprtrdma_op_setport);
...@@ -480,32 +450,33 @@ TRACE_EVENT(xprtrdma_op_set_cto, ...@@ -480,32 +450,33 @@ TRACE_EVENT(xprtrdma_op_set_cto,
TRACE_EVENT(xprtrdma_qp_event, TRACE_EVENT(xprtrdma_qp_event,
TP_PROTO( TP_PROTO(
const struct rpcrdma_xprt *r_xprt, const struct rpcrdma_ep *ep,
const struct ib_event *event const struct ib_event *event
), ),
TP_ARGS(r_xprt, event), TP_ARGS(ep, event),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, r_xprt) __field(unsigned long, event)
__field(unsigned int, event)
__string(name, event->device->name) __string(name, event->device->name)
__string(addr, rpcrdma_addrstr(r_xprt)) __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6))
__string(port, rpcrdma_portstr(r_xprt)) __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6))
), ),
TP_fast_assign( TP_fast_assign(
__entry->r_xprt = r_xprt; const struct rdma_cm_id *id = ep->re_id;
__entry->event = event->event; __entry->event = event->event;
__assign_str(name, event->device->name); __assign_str(name, event->device->name);
__assign_str(addr, rpcrdma_addrstr(r_xprt)); memcpy(__entry->srcaddr, &id->route.addr.src_addr,
__assign_str(port, rpcrdma_portstr(r_xprt)); sizeof(struct sockaddr_in6));
memcpy(__entry->dstaddr, &id->route.addr.dst_addr,
sizeof(struct sockaddr_in6));
), ),
TP_printk("peer=[%s]:%s r_xprt=%p: dev %s: %s (%u)", TP_printk("%pISpc -> %pISpc device=%s %s (%lu)",
__get_str(addr), __get_str(port), __entry->r_xprt, __entry->srcaddr, __entry->dstaddr, __get_str(name),
__get_str(name), rdma_show_ib_event(__entry->event), rdma_show_ib_event(__entry->event), __entry->event
__entry->event
) )
); );
...@@ -801,7 +772,7 @@ TRACE_EVENT(xprtrdma_post_recvs, ...@@ -801,7 +772,7 @@ TRACE_EVENT(xprtrdma_post_recvs,
__entry->r_xprt = r_xprt; __entry->r_xprt = r_xprt;
__entry->count = count; __entry->count = count;
__entry->status = status; __entry->status = status;
__entry->posted = r_xprt->rx_ep.rep_receive_count; __entry->posted = r_xprt->rx_ep->re_receive_count;
__assign_str(addr, rpcrdma_addrstr(r_xprt)); __assign_str(addr, rpcrdma_addrstr(r_xprt));
__assign_str(port, rpcrdma_portstr(r_xprt)); __assign_str(port, rpcrdma_portstr(r_xprt));
), ),
...@@ -920,17 +891,17 @@ TRACE_EVENT(xprtrdma_frwr_alloc, ...@@ -920,17 +891,17 @@ TRACE_EVENT(xprtrdma_frwr_alloc,
TP_ARGS(mr, rc), TP_ARGS(mr, rc),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(int, rc) __field(int, rc)
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = mr; __entry->mr_id = mr->frwr.fr_mr->res.id;
__entry->rc = rc; __entry->rc = rc;
), ),
TP_printk("mr=%p: rc=%d", TP_printk("mr.id=%u: rc=%d",
__entry->mr, __entry->rc __entry->mr_id, __entry->rc
) )
); );
...@@ -943,7 +914,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg, ...@@ -943,7 +914,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg,
TP_ARGS(mr, rc), TP_ARGS(mr, rc),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(int, nents)
__field(u32, handle) __field(u32, handle)
__field(u32, length) __field(u32, length)
__field(u64, offset) __field(u64, offset)
...@@ -952,7 +924,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg, ...@@ -952,7 +924,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg,
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = mr; __entry->mr_id = mr->frwr.fr_mr->res.id;
__entry->nents = mr->mr_nents;
__entry->handle = mr->mr_handle; __entry->handle = mr->mr_handle;
__entry->length = mr->mr_length; __entry->length = mr->mr_length;
__entry->offset = mr->mr_offset; __entry->offset = mr->mr_offset;
...@@ -960,8 +933,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg, ...@@ -960,8 +933,8 @@ TRACE_EVENT(xprtrdma_frwr_dereg,
__entry->rc = rc; __entry->rc = rc;
), ),
TP_printk("mr=%p %u@0x%016llx:0x%08x (%s): rc=%d", TP_printk("mr.id=%u nents=%d %u@0x%016llx:0x%08x (%s): rc=%d",
__entry->mr, __entry->length, __entry->mr_id, __entry->nents, __entry->length,
(unsigned long long)__entry->offset, __entry->handle, (unsigned long long)__entry->offset, __entry->handle,
xprtrdma_show_direction(__entry->dir), xprtrdma_show_direction(__entry->dir),
__entry->rc __entry->rc
...@@ -977,21 +950,21 @@ TRACE_EVENT(xprtrdma_frwr_sgerr, ...@@ -977,21 +950,21 @@ TRACE_EVENT(xprtrdma_frwr_sgerr,
TP_ARGS(mr, sg_nents), TP_ARGS(mr, sg_nents),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(u64, addr) __field(u64, addr)
__field(u32, dir) __field(u32, dir)
__field(int, nents) __field(int, nents)
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = mr; __entry->mr_id = mr->frwr.fr_mr->res.id;
__entry->addr = mr->mr_sg->dma_address; __entry->addr = mr->mr_sg->dma_address;
__entry->dir = mr->mr_dir; __entry->dir = mr->mr_dir;
__entry->nents = sg_nents; __entry->nents = sg_nents;
), ),
TP_printk("mr=%p dma addr=0x%llx (%s) sg_nents=%d", TP_printk("mr.id=%u DMA addr=0x%llx (%s) sg_nents=%d",
__entry->mr, __entry->addr, __entry->mr_id, __entry->addr,
xprtrdma_show_direction(__entry->dir), xprtrdma_show_direction(__entry->dir),
__entry->nents __entry->nents
) )
...@@ -1006,7 +979,7 @@ TRACE_EVENT(xprtrdma_frwr_maperr, ...@@ -1006,7 +979,7 @@ TRACE_EVENT(xprtrdma_frwr_maperr,
TP_ARGS(mr, num_mapped), TP_ARGS(mr, num_mapped),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, mr) __field(u32, mr_id)
__field(u64, addr) __field(u64, addr)
__field(u32, dir) __field(u32, dir)
__field(int, num_mapped) __field(int, num_mapped)
...@@ -1014,15 +987,15 @@ TRACE_EVENT(xprtrdma_frwr_maperr, ...@@ -1014,15 +987,15 @@ TRACE_EVENT(xprtrdma_frwr_maperr,
), ),
TP_fast_assign( TP_fast_assign(
__entry->mr = mr; __entry->mr_id = mr->frwr.fr_mr->res.id;
__entry->addr = mr->mr_sg->dma_address; __entry->addr = mr->mr_sg->dma_address;
__entry->dir = mr->mr_dir; __entry->dir = mr->mr_dir;
__entry->num_mapped = num_mapped; __entry->num_mapped = num_mapped;
__entry->nents = mr->mr_nents; __entry->nents = mr->mr_nents;
), ),
TP_printk("mr=%p dma addr=0x%llx (%s) nents=%d of %d", TP_printk("mr.id=%u DMA addr=0x%llx (%s) nents=%d of %d",
__entry->mr, __entry->addr, __entry->mr_id, __entry->addr,
xprtrdma_show_direction(__entry->dir), xprtrdma_show_direction(__entry->dir),
__entry->num_mapped, __entry->nents __entry->num_mapped, __entry->nents
) )
...@@ -1031,7 +1004,7 @@ TRACE_EVENT(xprtrdma_frwr_maperr, ...@@ -1031,7 +1004,7 @@ TRACE_EVENT(xprtrdma_frwr_maperr,
DEFINE_MR_EVENT(localinv); DEFINE_MR_EVENT(localinv);
DEFINE_MR_EVENT(map); DEFINE_MR_EVENT(map);
DEFINE_MR_EVENT(unmap); DEFINE_MR_EVENT(unmap);
DEFINE_MR_EVENT(remoteinv); DEFINE_MR_EVENT(reminv);
DEFINE_MR_EVENT(recycle); DEFINE_MR_EVENT(recycle);
TRACE_EVENT(xprtrdma_dma_maperr, TRACE_EVENT(xprtrdma_dma_maperr,
......
...@@ -44,10 +44,10 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs) ...@@ -44,10 +44,10 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
size_t xprt_rdma_bc_maxpayload(struct rpc_xprt *xprt) size_t xprt_rdma_bc_maxpayload(struct rpc_xprt *xprt)
{ {
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
struct rpcrdma_ep *ep = &r_xprt->rx_ep; struct rpcrdma_ep *ep = r_xprt->rx_ep;
size_t maxmsg; size_t maxmsg;
maxmsg = min_t(unsigned int, ep->rep_inline_send, ep->rep_inline_recv); maxmsg = min_t(unsigned int, ep->re_inline_send, ep->re_inline_recv);
maxmsg = min_t(unsigned int, maxmsg, PAGE_SIZE); maxmsg = min_t(unsigned int, maxmsg, PAGE_SIZE);
return maxmsg - RPCRDMA_HDRLEN_MIN; return maxmsg - RPCRDMA_HDRLEN_MIN;
} }
...@@ -115,7 +115,7 @@ int xprt_rdma_bc_send_reply(struct rpc_rqst *rqst) ...@@ -115,7 +115,7 @@ int xprt_rdma_bc_send_reply(struct rpc_rqst *rqst)
if (rc < 0) if (rc < 0)
goto failed_marshal; goto failed_marshal;
if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req)) if (rpcrdma_post_sends(r_xprt, req))
goto drop_connection; goto drop_connection;
return 0; return 0;
...@@ -190,7 +190,7 @@ static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt) ...@@ -190,7 +190,7 @@ static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt)
if (xprt->bc_alloc_count >= RPCRDMA_BACKWARD_WRS) if (xprt->bc_alloc_count >= RPCRDMA_BACKWARD_WRS)
return NULL; return NULL;
size = min_t(size_t, r_xprt->rx_ep.rep_inline_recv, PAGE_SIZE); size = min_t(size_t, r_xprt->rx_ep->re_inline_recv, PAGE_SIZE);
req = rpcrdma_req_create(r_xprt, size, GFP_KERNEL); req = rpcrdma_req_create(r_xprt, size, GFP_KERNEL);
if (!req) if (!req)
return NULL; return NULL;
......
This diff is collapsed.
...@@ -103,21 +103,20 @@ static unsigned int rpcrdma_max_reply_header_size(unsigned int maxsegs) ...@@ -103,21 +103,20 @@ static unsigned int rpcrdma_max_reply_header_size(unsigned int maxsegs)
/** /**
* rpcrdma_set_max_header_sizes - Initialize inline payload sizes * rpcrdma_set_max_header_sizes - Initialize inline payload sizes
* @r_xprt: transport instance to initialize * @ep: endpoint to initialize
* *
* The max_inline fields contain the maximum size of an RPC message * The max_inline fields contain the maximum size of an RPC message
* so the marshaling code doesn't have to repeat this calculation * so the marshaling code doesn't have to repeat this calculation
* for every RPC. * for every RPC.
*/ */
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *r_xprt) void rpcrdma_set_max_header_sizes(struct rpcrdma_ep *ep)
{ {
unsigned int maxsegs = r_xprt->rx_ia.ri_max_rdma_segs; unsigned int maxsegs = ep->re_max_rdma_segs;
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
ep->rep_max_inline_send = ep->re_max_inline_send =
ep->rep_inline_send - rpcrdma_max_call_header_size(maxsegs); ep->re_inline_send - rpcrdma_max_call_header_size(maxsegs);
ep->rep_max_inline_recv = ep->re_max_inline_recv =
ep->rep_inline_recv - rpcrdma_max_reply_header_size(maxsegs); ep->re_inline_recv - rpcrdma_max_reply_header_size(maxsegs);
} }
/* The client can send a request inline as long as the RPCRDMA header /* The client can send a request inline as long as the RPCRDMA header
...@@ -132,9 +131,10 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt, ...@@ -132,9 +131,10 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
struct rpc_rqst *rqst) struct rpc_rqst *rqst)
{ {
struct xdr_buf *xdr = &rqst->rq_snd_buf; struct xdr_buf *xdr = &rqst->rq_snd_buf;
struct rpcrdma_ep *ep = r_xprt->rx_ep;
unsigned int count, remaining, offset; unsigned int count, remaining, offset;
if (xdr->len > r_xprt->rx_ep.rep_max_inline_send) if (xdr->len > ep->re_max_inline_send)
return false; return false;
if (xdr->page_len) { if (xdr->page_len) {
...@@ -145,7 +145,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt, ...@@ -145,7 +145,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
remaining -= min_t(unsigned int, remaining -= min_t(unsigned int,
PAGE_SIZE - offset, remaining); PAGE_SIZE - offset, remaining);
offset = 0; offset = 0;
if (++count > r_xprt->rx_ep.rep_attr.cap.max_send_sge) if (++count > ep->re_attr.cap.max_send_sge)
return false; return false;
} }
} }
...@@ -162,7 +162,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt, ...@@ -162,7 +162,7 @@ static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt, static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,
struct rpc_rqst *rqst) struct rpc_rqst *rqst)
{ {
return rqst->rq_rcv_buf.buflen <= r_xprt->rx_ep.rep_max_inline_recv; return rqst->rq_rcv_buf.buflen <= r_xprt->rx_ep->re_max_inline_recv;
} }
/* The client is required to provide a Reply chunk if the maximum /* The client is required to provide a Reply chunk if the maximum
...@@ -176,7 +176,7 @@ rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt, ...@@ -176,7 +176,7 @@ rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt,
const struct xdr_buf *buf = &rqst->rq_rcv_buf; const struct xdr_buf *buf = &rqst->rq_rcv_buf;
return (buf->head[0].iov_len + buf->tail[0].iov_len) < return (buf->head[0].iov_len + buf->tail[0].iov_len) <
r_xprt->rx_ep.rep_max_inline_recv; r_xprt->rx_ep->re_max_inline_recv;
} }
/* Split @vec on page boundaries into SGEs. FMR registers pages, not /* Split @vec on page boundaries into SGEs. FMR registers pages, not
...@@ -255,7 +255,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf, ...@@ -255,7 +255,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
/* When encoding a Read chunk, the tail iovec contains an /* When encoding a Read chunk, the tail iovec contains an
* XDR pad and may be omitted. * XDR pad and may be omitted.
*/ */
if (type == rpcrdma_readch && r_xprt->rx_ia.ri_implicit_roundup) if (type == rpcrdma_readch && r_xprt->rx_ep->re_implicit_roundup)
goto out; goto out;
/* When encoding a Write chunk, some servers need to see an /* When encoding a Write chunk, some servers need to see an
...@@ -263,7 +263,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf, ...@@ -263,7 +263,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
* layer provides space in the tail iovec that may be used * layer provides space in the tail iovec that may be used
* for this purpose. * for this purpose.
*/ */
if (type == rpcrdma_writech && r_xprt->rx_ia.ri_implicit_roundup) if (type == rpcrdma_writech && r_xprt->rx_ep->re_implicit_roundup)
goto out; goto out;
if (xdrbuf->tail[0].iov_len) if (xdrbuf->tail[0].iov_len)
...@@ -1476,8 +1476,8 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep) ...@@ -1476,8 +1476,8 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
if (credits == 0) if (credits == 0)
credits = 1; /* don't deadlock */ credits = 1; /* don't deadlock */
else if (credits > r_xprt->rx_ep.rep_max_requests) else if (credits > r_xprt->rx_ep->re_max_requests)
credits = r_xprt->rx_ep.rep_max_requests; credits = r_xprt->rx_ep->re_max_requests;
if (buf->rb_credits != credits) if (buf->rb_credits != credits)
rpcrdma_update_cwnd(r_xprt, credits); rpcrdma_update_cwnd(r_xprt, credits);
rpcrdma_post_recvs(r_xprt, false); rpcrdma_post_recvs(r_xprt, false);
......
...@@ -240,9 +240,10 @@ xprt_rdma_connect_worker(struct work_struct *work) ...@@ -240,9 +240,10 @@ xprt_rdma_connect_worker(struct work_struct *work)
struct rpc_xprt *xprt = &r_xprt->rx_xprt; struct rpc_xprt *xprt = &r_xprt->rx_xprt;
int rc; int rc;
rc = rpcrdma_ep_connect(&r_xprt->rx_ep, &r_xprt->rx_ia); rc = rpcrdma_xprt_connect(r_xprt);
xprt_clear_connecting(xprt); xprt_clear_connecting(xprt);
if (r_xprt->rx_ep.rep_connected > 0) { if (r_xprt->rx_ep && r_xprt->rx_ep->re_connect_status > 0) {
xprt->connect_cookie++;
xprt->stat.connect_count++; xprt->stat.connect_count++;
xprt->stat.connect_time += (long)jiffies - xprt->stat.connect_time += (long)jiffies -
xprt->stat.connect_start; xprt->stat.connect_start;
...@@ -265,7 +266,7 @@ xprt_rdma_inject_disconnect(struct rpc_xprt *xprt) ...@@ -265,7 +266,7 @@ xprt_rdma_inject_disconnect(struct rpc_xprt *xprt)
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
trace_xprtrdma_op_inject_dsc(r_xprt); trace_xprtrdma_op_inject_dsc(r_xprt);
rdma_disconnect(r_xprt->rx_ia.ri_id); rdma_disconnect(r_xprt->rx_ep->re_id);
} }
/** /**
...@@ -284,9 +285,8 @@ xprt_rdma_destroy(struct rpc_xprt *xprt) ...@@ -284,9 +285,8 @@ xprt_rdma_destroy(struct rpc_xprt *xprt)
cancel_delayed_work_sync(&r_xprt->rx_connect_worker); cancel_delayed_work_sync(&r_xprt->rx_connect_worker);
rpcrdma_ep_destroy(r_xprt); rpcrdma_xprt_disconnect(r_xprt);
rpcrdma_buffer_destroy(&r_xprt->rx_buf); rpcrdma_buffer_destroy(&r_xprt->rx_buf);
rpcrdma_ia_close(&r_xprt->rx_ia);
xprt_rdma_free_addresses(xprt); xprt_rdma_free_addresses(xprt);
xprt_free(xprt); xprt_free(xprt);
...@@ -316,10 +316,15 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -316,10 +316,15 @@ xprt_setup_rdma(struct xprt_create *args)
if (args->addrlen > sizeof(xprt->addr)) if (args->addrlen > sizeof(xprt->addr))
return ERR_PTR(-EBADF); return ERR_PTR(-EBADF);
if (!try_module_get(THIS_MODULE))
return ERR_PTR(-EIO);
xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0, xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0,
xprt_rdma_slot_table_entries); xprt_rdma_slot_table_entries);
if (!xprt) if (!xprt) {
module_put(THIS_MODULE);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
xprt->timeout = &xprt_rdma_default_timeout; xprt->timeout = &xprt_rdma_default_timeout;
xprt->connect_timeout = xprt->timeout->to_initval; xprt->connect_timeout = xprt->timeout->to_initval;
...@@ -347,23 +352,17 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -347,23 +352,17 @@ xprt_setup_rdma(struct xprt_create *args)
xprt_rdma_format_addresses(xprt, sap); xprt_rdma_format_addresses(xprt, sap);
new_xprt = rpcx_to_rdmax(xprt); new_xprt = rpcx_to_rdmax(xprt);
rc = rpcrdma_ia_open(new_xprt);
if (rc)
goto out1;
rc = rpcrdma_ep_create(new_xprt);
if (rc)
goto out2;
rc = rpcrdma_buffer_create(new_xprt); rc = rpcrdma_buffer_create(new_xprt);
if (rc) if (rc) {
goto out3; xprt_rdma_free_addresses(xprt);
xprt_free(xprt);
if (!try_module_get(THIS_MODULE)) module_put(THIS_MODULE);
goto out4; return ERR_PTR(rc);
}
INIT_DELAYED_WORK(&new_xprt->rx_connect_worker, INIT_DELAYED_WORK(&new_xprt->rx_connect_worker,
xprt_rdma_connect_worker); xprt_rdma_connect_worker);
xprt->max_payload = RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT; xprt->max_payload = RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT;
dprintk("RPC: %s: %s:%s\n", __func__, dprintk("RPC: %s: %s:%s\n", __func__,
...@@ -371,19 +370,6 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -371,19 +370,6 @@ xprt_setup_rdma(struct xprt_create *args)
xprt->address_strings[RPC_DISPLAY_PORT]); xprt->address_strings[RPC_DISPLAY_PORT]);
trace_xprtrdma_create(new_xprt); trace_xprtrdma_create(new_xprt);
return xprt; return xprt;
out4:
rpcrdma_buffer_destroy(&new_xprt->rx_buf);
rc = -ENODEV;
out3:
rpcrdma_ep_destroy(new_xprt);
out2:
rpcrdma_ia_close(&new_xprt->rx_ia);
out1:
trace_xprtrdma_op_destroy(new_xprt);
xprt_rdma_free_addresses(xprt);
xprt_free(xprt);
return ERR_PTR(rc);
} }
/** /**
...@@ -398,26 +384,11 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -398,26 +384,11 @@ xprt_setup_rdma(struct xprt_create *args)
void xprt_rdma_close(struct rpc_xprt *xprt) void xprt_rdma_close(struct rpc_xprt *xprt)
{ {
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
might_sleep();
trace_xprtrdma_op_close(r_xprt); trace_xprtrdma_op_close(r_xprt);
/* Prevent marshaling and sending of new requests */ rpcrdma_xprt_disconnect(r_xprt);
xprt_clear_connected(xprt);
if (test_and_clear_bit(RPCRDMA_IAF_REMOVING, &ia->ri_flags)) {
rpcrdma_ia_remove(ia);
goto out;
}
if (ep->rep_connected == -ENODEV)
return;
rpcrdma_ep_disconnect(ep, ia);
out:
xprt->reestablish_timeout = 0; xprt->reestablish_timeout = 0;
++xprt->connect_cookie; ++xprt->connect_cookie;
xprt_disconnect_done(xprt); xprt_disconnect_done(xprt);
...@@ -517,10 +488,11 @@ static void ...@@ -517,10 +488,11 @@ static void
xprt_rdma_connect(struct rpc_xprt *xprt, struct rpc_task *task) xprt_rdma_connect(struct rpc_xprt *xprt, struct rpc_task *task)
{ {
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
struct rpcrdma_ep *ep = r_xprt->rx_ep;
unsigned long delay; unsigned long delay;
delay = 0; delay = 0;
if (r_xprt->rx_ep.rep_connected != 0) { if (ep && ep->re_connect_status != 0) {
delay = xprt_reconnect_delay(xprt); delay = xprt_reconnect_delay(xprt);
xprt_reconnect_backoff(xprt, RPCRDMA_INIT_REEST_TO); xprt_reconnect_backoff(xprt, RPCRDMA_INIT_REEST_TO);
} }
...@@ -694,7 +666,7 @@ xprt_rdma_send_request(struct rpc_rqst *rqst) ...@@ -694,7 +666,7 @@ xprt_rdma_send_request(struct rpc_rqst *rqst)
goto drop_connection; goto drop_connection;
rqst->rq_xtime = ktime_get(); rqst->rq_xtime = ktime_get();
if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req)) if (rpcrdma_post_sends(r_xprt, req))
goto drop_connection; goto drop_connection;
rqst->rq_xmit_bytes_sent += rqst->rq_snd_buf.len; rqst->rq_xmit_bytes_sent += rqst->rq_snd_buf.len;
......
This diff is collapsed.
...@@ -65,43 +65,33 @@ ...@@ -65,43 +65,33 @@
#define RPCRDMA_IDLE_DISC_TO (5U * 60 * HZ) #define RPCRDMA_IDLE_DISC_TO (5U * 60 * HZ)
/* /*
* Interface Adapter -- one per transport instance * RDMA Endpoint -- connection endpoint details
*/ */
struct rpcrdma_ia {
struct rdma_cm_id *ri_id;
struct ib_pd *ri_pd;
int ri_async_rc;
unsigned int ri_max_rdma_segs;
unsigned int ri_max_frwr_depth;
bool ri_implicit_roundup;
enum ib_mr_type ri_mrtype;
unsigned long ri_flags;
struct completion ri_done;
struct completion ri_remove_done;
};
enum {
RPCRDMA_IAF_REMOVING = 0,
};
/*
* RDMA Endpoint -- one per transport instance
*/
struct rpcrdma_ep { struct rpcrdma_ep {
unsigned int rep_send_count; struct kref re_kref;
unsigned int rep_send_batch; struct rdma_cm_id *re_id;
unsigned int rep_max_inline_send; struct ib_pd *re_pd;
unsigned int rep_max_inline_recv; unsigned int re_max_rdma_segs;
int rep_connected; unsigned int re_max_fr_depth;
struct ib_qp_init_attr rep_attr; bool re_implicit_roundup;
wait_queue_head_t rep_connect_wait; enum ib_mr_type re_mrtype;
struct rpcrdma_connect_private rep_cm_private; struct completion re_done;
struct rdma_conn_param rep_remote_cma; unsigned int re_send_count;
unsigned int rep_max_requests; /* depends on device */ unsigned int re_send_batch;
unsigned int rep_inline_send; /* negotiated */ unsigned int re_max_inline_send;
unsigned int rep_inline_recv; /* negotiated */ unsigned int re_max_inline_recv;
int rep_receive_count; int re_async_rc;
int re_connect_status;
struct ib_qp_init_attr re_attr;
wait_queue_head_t re_connect_wait;
struct rpc_xprt *re_xprt;
struct rpcrdma_connect_private
re_cm_private;
struct rdma_conn_param re_remote_cma;
int re_receive_count;
unsigned int re_max_requests; /* depends on device */
unsigned int re_inline_send; /* negotiated */
unsigned int re_inline_recv; /* negotiated */
}; };
/* Pre-allocate extra Work Requests for handling backward receives /* Pre-allocate extra Work Requests for handling backward receives
...@@ -422,8 +412,7 @@ struct rpcrdma_stats { ...@@ -422,8 +412,7 @@ struct rpcrdma_stats {
*/ */
struct rpcrdma_xprt { struct rpcrdma_xprt {
struct rpc_xprt rx_xprt; struct rpc_xprt rx_xprt;
struct rpcrdma_ia rx_ia; struct rpcrdma_ep *rx_ep;
struct rpcrdma_ep rx_ep;
struct rpcrdma_buffer rx_buf; struct rpcrdma_buffer rx_buf;
struct delayed_work rx_connect_worker; struct delayed_work rx_connect_worker;
struct rpc_timeout rx_timeout; struct rpc_timeout rx_timeout;
...@@ -454,23 +443,14 @@ extern int xprt_rdma_pad_optimize; ...@@ -454,23 +443,14 @@ extern int xprt_rdma_pad_optimize;
*/ */
extern unsigned int xprt_rdma_memreg_strategy; extern unsigned int xprt_rdma_memreg_strategy;
/*
* Interface Adapter calls - xprtrdma/verbs.c
*/
int rpcrdma_ia_open(struct rpcrdma_xprt *xprt);
void rpcrdma_ia_remove(struct rpcrdma_ia *ia);
void rpcrdma_ia_close(struct rpcrdma_ia *);
/* /*
* Endpoint calls - xprtrdma/verbs.c * Endpoint calls - xprtrdma/verbs.c
*/ */
int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt); void rpcrdma_flush_disconnect(struct ib_cq *cq, struct ib_wc *wc);
void rpcrdma_ep_destroy(struct rpcrdma_xprt *r_xprt); int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt);
int rpcrdma_ep_connect(struct rpcrdma_ep *, struct rpcrdma_ia *); void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt);
void rpcrdma_ep_disconnect(struct rpcrdma_ep *, struct rpcrdma_ia *);
int rpcrdma_ep_post(struct rpcrdma_ia *, struct rpcrdma_ep *, int rpcrdma_post_sends(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req);
struct rpcrdma_req *);
void rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp); void rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp);
/* /*
...@@ -536,15 +516,14 @@ rpcrdma_data_dir(bool writing) ...@@ -536,15 +516,14 @@ rpcrdma_data_dir(bool writing)
/* Memory registration calls xprtrdma/frwr_ops.c /* Memory registration calls xprtrdma/frwr_ops.c
*/ */
void frwr_reset(struct rpcrdma_req *req); void frwr_reset(struct rpcrdma_req *req);
int frwr_query_device(struct rpcrdma_xprt *r_xprt, int frwr_query_device(struct rpcrdma_ep *ep, const struct ib_device *device);
const struct ib_device *device); int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr);
int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr);
void frwr_release_mr(struct rpcrdma_mr *mr); void frwr_release_mr(struct rpcrdma_mr *mr);
struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *frwr_map(struct rpcrdma_xprt *r_xprt,
struct rpcrdma_mr_seg *seg, struct rpcrdma_mr_seg *seg,
int nsegs, bool writing, __be32 xid, int nsegs, bool writing, __be32 xid,
struct rpcrdma_mr *mr); struct rpcrdma_mr *mr);
int frwr_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req); int frwr_send(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req);
void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs); void frwr_reminv(struct rpcrdma_rep *rep, struct list_head *mrs);
void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req); void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req);
void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req); void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req);
...@@ -569,7 +548,7 @@ int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt, ...@@ -569,7 +548,7 @@ int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt,
enum rpcrdma_chunktype rtype); enum rpcrdma_chunktype rtype);
void rpcrdma_sendctx_unmap(struct rpcrdma_sendctx *sc); void rpcrdma_sendctx_unmap(struct rpcrdma_sendctx *sc);
int rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst); int rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst);
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *); void rpcrdma_set_max_header_sizes(struct rpcrdma_ep *ep);
void rpcrdma_reset_cwnd(struct rpcrdma_xprt *r_xprt); void rpcrdma_reset_cwnd(struct rpcrdma_xprt *r_xprt);
void rpcrdma_complete_rqst(struct rpcrdma_rep *rep); void rpcrdma_complete_rqst(struct rpcrdma_rep *rep);
void rpcrdma_reply_handler(struct rpcrdma_rep *rep); void rpcrdma_reply_handler(struct rpcrdma_rep *rep);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment