Skip to content

Commit 9ba373e

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Allocate Protection Domain in rpcrdma_ep_create()
Make a Protection Domain (PD) a per-connection resource rather than a per-transport resource. In other words, when the connection terminates, the PD is destroyed. Thus there is one less HW resource that remains allocated to a transport after a connection is closed. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 9144a80 commit 9ba373e

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

net/sunrpc/xprtrdma/verbs.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,6 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt)
363363
rc = PTR_ERR(ia->ri_id);
364364
goto out_err;
365365
}
366-
367-
ia->ri_pd = ib_alloc_pd(ia->ri_id->device, 0);
368-
if (IS_ERR(ia->ri_pd)) {
369-
rc = PTR_ERR(ia->ri_pd);
370-
pr_err("rpcrdma: ib_alloc_pd() returned %d\n", rc);
371-
goto out_err;
372-
}
373-
374366
return 0;
375367

376368
out_err:
@@ -403,9 +395,6 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia)
403395

404396
rpcrdma_ep_destroy(r_xprt);
405397

406-
ib_dealloc_pd(ia->ri_pd);
407-
ia->ri_pd = NULL;
408-
409398
/* Allow waiters to continue */
410399
complete(&ia->ri_remove_done);
411400

@@ -423,11 +412,6 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia)
423412
if (ia->ri_id && !IS_ERR(ia->ri_id))
424413
rdma_destroy_id(ia->ri_id);
425414
ia->ri_id = NULL;
426-
427-
/* If the pd is still busy, xprtrdma missed freeing a resource */
428-
if (ia->ri_pd && !IS_ERR(ia->ri_pd))
429-
ib_dealloc_pd(ia->ri_pd);
430-
ia->ri_pd = NULL;
431415
}
432416

433417
static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt,
@@ -514,6 +498,12 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt,
514498
ep->rep_remote_cma.flow_control = 0;
515499
ep->rep_remote_cma.rnr_retry_count = 0;
516500

501+
ia->ri_pd = ib_alloc_pd(id->device, 0);
502+
if (IS_ERR(ia->ri_pd)) {
503+
rc = PTR_ERR(ia->ri_pd);
504+
goto out_destroy;
505+
}
506+
517507
rc = rdma_create_qp(id, ia->ri_pd, &ep->rep_attr);
518508
if (rc)
519509
goto out_destroy;
@@ -540,6 +530,10 @@ static void rpcrdma_ep_destroy(struct rpcrdma_xprt *r_xprt)
540530
if (ep->rep_attr.send_cq)
541531
ib_free_cq(ep->rep_attr.send_cq);
542532
ep->rep_attr.send_cq = NULL;
533+
534+
if (ia->ri_pd)
535+
ib_dealloc_pd(ia->ri_pd);
536+
ia->ri_pd = NULL;
543537
}
544538

545539
/* Re-establish a connection after a device removal event.

0 commit comments

Comments
 (0)