Skip to content

Commit 897b7be

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Remove rpcrdma_ia::ri_flags
Clean up: The upper layer serializes calls to xprt_rdma_close, so there is no need for an atomic bit operation, saving 8 bytes in rpcrdma_ia. This enables merging rpcrdma_ia_remove directly into the disconnect logic. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 81fe0c5 commit 897b7be

File tree

3 files changed

+13
-67
lines changed

3 files changed

+13
-67
lines changed

net/sunrpc/xprtrdma/transport.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,26 +385,11 @@ xprt_setup_rdma(struct xprt_create *args)
385385
void xprt_rdma_close(struct rpc_xprt *xprt)
386386
{
387387
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
388-
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
389-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
390-
391-
might_sleep();
392388

393389
trace_xprtrdma_op_close(r_xprt);
394390

395-
/* Prevent marshaling and sending of new requests */
396-
xprt_clear_connected(xprt);
397-
398-
if (test_and_clear_bit(RPCRDMA_IAF_REMOVING, &ia->ri_flags)) {
399-
rpcrdma_ia_remove(ia);
400-
goto out;
401-
}
402-
403-
if (ep->rep_connected == -ENODEV)
404-
return;
405391
rpcrdma_xprt_disconnect(r_xprt);
406392

407-
out:
408393
xprt->reestablish_timeout = 0;
409394
++xprt->connect_cookie;
410395
xprt_disconnect_done(xprt);

net/sunrpc/xprtrdma/verbs.c

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,11 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
250250
rpcrdma_addrstr(r_xprt), rpcrdma_portstr(r_xprt));
251251
#endif
252252
init_completion(&ia->ri_remove_done);
253-
set_bit(RPCRDMA_IAF_REMOVING, &ia->ri_flags);
254253
ep->rep_connected = -ENODEV;
255254
xprt_force_disconnect(xprt);
256255
wait_for_completion(&ia->ri_remove_done);
256+
trace_xprtrdma_remove(r_xprt);
257257

258-
ia->ri_id = NULL;
259258
/* Return 1 to ensure the core destroys the id. */
260259
return 1;
261260
case RDMA_CM_EVENT_ESTABLISHED:
@@ -345,37 +344,6 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt, struct rpcrdma_ia *ia)
345344
* Exported functions.
346345
*/
347346

348-
/**
349-
* rpcrdma_ia_remove - Handle device driver unload
350-
* @ia: interface adapter being removed
351-
*
352-
* Divest transport H/W resources associated with this adapter,
353-
* but allow it to be restored later.
354-
*
355-
* Caller must hold the transport send lock.
356-
*/
357-
void
358-
rpcrdma_ia_remove(struct rpcrdma_ia *ia)
359-
{
360-
struct rpcrdma_xprt *r_xprt = container_of(ia, struct rpcrdma_xprt,
361-
rx_ia);
362-
363-
if (ia->ri_id->qp)
364-
rpcrdma_xprt_drain(r_xprt);
365-
366-
rpcrdma_reps_unmap(r_xprt);
367-
rpcrdma_reqs_reset(r_xprt);
368-
rpcrdma_mrs_destroy(r_xprt);
369-
rpcrdma_sendctxs_destroy(r_xprt);
370-
371-
rpcrdma_ep_destroy(r_xprt);
372-
373-
/* Allow waiters to continue */
374-
complete(&ia->ri_remove_done);
375-
376-
trace_xprtrdma_remove(r_xprt);
377-
}
378-
379347
static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
380348
{
381349
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
@@ -573,12 +541,13 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)
573541
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
574542
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
575543
struct rdma_cm_id *id = ia->ri_id;
576-
int rc;
544+
int rc, status = ep->rep_connected;
545+
546+
might_sleep();
577547

578548
if (!id)
579-
goto out;
549+
return;
580550

581-
/* returns without wait if ID is not connected */
582551
rc = rdma_disconnect(id);
583552
if (!rc)
584553
wait_event_interruptible(ep->rep_connect_wait,
@@ -589,15 +558,17 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)
589558

590559
if (id->qp)
591560
rpcrdma_xprt_drain(r_xprt);
592-
out:
561+
rpcrdma_reps_unmap(r_xprt);
593562
rpcrdma_reqs_reset(r_xprt);
594563
rpcrdma_mrs_destroy(r_xprt);
595564
rpcrdma_sendctxs_destroy(r_xprt);
596565

597566
rpcrdma_ep_destroy(r_xprt);
598567

599-
if (ia->ri_id)
600-
rdma_destroy_id(ia->ri_id);
568+
if (status == -ENODEV)
569+
complete(&ia->ri_remove_done);
570+
else
571+
rdma_destroy_id(id);
601572
ia->ri_id = NULL;
602573
}
603574

@@ -815,10 +786,10 @@ void rpcrdma_mrs_refresh(struct rpcrdma_xprt *r_xprt)
815786
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
816787
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
817788

818-
/* If there is no underlying device, it's no use to
819-
* wake the refresh worker.
789+
/* If there is no underlying connection, it's no use
790+
* to wake the refresh worker.
820791
*/
821-
if (ep->rep_connected != -ENODEV) {
792+
if (ep->rep_connected == 1) {
822793
/* The work is scheduled on a WQ_MEM_RECLAIM
823794
* workqueue in order to prevent MR allocation
824795
* from recursing into NFS during direct reclaim.

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@ struct rpcrdma_ia {
7575
unsigned int ri_max_frwr_depth;
7676
bool ri_implicit_roundup;
7777
enum ib_mr_type ri_mrtype;
78-
unsigned long ri_flags;
7978
struct completion ri_done;
8079
struct completion ri_remove_done;
8180
};
8281

83-
enum {
84-
RPCRDMA_IAF_REMOVING = 0,
85-
};
86-
8782
/*
8883
* RDMA Endpoint -- one per transport instance
8984
*/
@@ -454,11 +449,6 @@ extern int xprt_rdma_pad_optimize;
454449
*/
455450
extern unsigned int xprt_rdma_memreg_strategy;
456451

457-
/*
458-
* Interface Adapter calls - xprtrdma/verbs.c
459-
*/
460-
void rpcrdma_ia_remove(struct rpcrdma_ia *ia);
461-
462452
/*
463453
* Endpoint calls - xprtrdma/verbs.c
464454
*/

0 commit comments

Comments
 (0)