Skip to content

Commit 4561f34

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Add "destroy MRs" memreg op
Memory Region objects associated with a transport instance are destroyed before the instance is shutdown and destroyed. Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Tested-by: Devesh Sharma <[email protected]> Tested-by: Meghana Cheripady <[email protected]> Tested-by: Veeresh U. Kokatnur <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 31a701a commit 4561f34

File tree

5 files changed

+40
-51
lines changed

5 files changed

+40
-51
lines changed

net/sunrpc/xprtrdma/fmr_ops.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,29 @@ fmr_op_reset(struct rpcrdma_xprt *r_xprt)
168168
__func__, rc);
169169
}
170170

171+
static void
172+
fmr_op_destroy(struct rpcrdma_buffer *buf)
173+
{
174+
struct rpcrdma_mw *r;
175+
int rc;
176+
177+
while (!list_empty(&buf->rb_all)) {
178+
r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all);
179+
list_del(&r->mw_all);
180+
rc = ib_dealloc_fmr(r->r.fmr);
181+
if (rc)
182+
dprintk("RPC: %s: ib_dealloc_fmr failed %i\n",
183+
__func__, rc);
184+
kfree(r);
185+
}
186+
}
187+
171188
const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = {
172189
.ro_map = fmr_op_map,
173190
.ro_unmap = fmr_op_unmap,
174191
.ro_maxpages = fmr_op_maxpages,
175192
.ro_init = fmr_op_init,
176193
.ro_reset = fmr_op_reset,
194+
.ro_destroy = fmr_op_destroy,
177195
.ro_displayname = "fmr",
178196
};

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,25 @@ frwr_op_reset(struct rpcrdma_xprt *r_xprt)
260260
}
261261
}
262262

263+
static void
264+
frwr_op_destroy(struct rpcrdma_buffer *buf)
265+
{
266+
struct rpcrdma_mw *r;
267+
268+
while (!list_empty(&buf->rb_all)) {
269+
r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all);
270+
list_del(&r->mw_all);
271+
__frwr_release(r);
272+
kfree(r);
273+
}
274+
}
275+
263276
const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = {
264277
.ro_map = frwr_op_map,
265278
.ro_unmap = frwr_op_unmap,
266279
.ro_maxpages = frwr_op_maxpages,
267280
.ro_init = frwr_op_init,
268281
.ro_reset = frwr_op_reset,
282+
.ro_destroy = frwr_op_destroy,
269283
.ro_displayname = "frwr",
270284
};

net/sunrpc/xprtrdma/physical_ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,17 @@ physical_op_reset(struct rpcrdma_xprt *r_xprt)
6464
{
6565
}
6666

67+
static void
68+
physical_op_destroy(struct rpcrdma_buffer *buf)
69+
{
70+
}
71+
6772
const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
6873
.ro_map = physical_op_map,
6974
.ro_unmap = physical_op_unmap,
7075
.ro_maxpages = physical_op_maxpages,
7176
.ro_init = physical_op_init,
7277
.ro_reset = physical_op_reset,
78+
.ro_destroy = physical_op_destroy,
7379
.ro_displayname = "physical",
7480
};

net/sunrpc/xprtrdma/verbs.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,47 +1199,6 @@ rpcrdma_destroy_req(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
11991199
kfree(req);
12001200
}
12011201

1202-
static void
1203-
rpcrdma_destroy_fmrs(struct rpcrdma_buffer *buf)
1204-
{
1205-
struct rpcrdma_mw *r;
1206-
int rc;
1207-
1208-
while (!list_empty(&buf->rb_all)) {
1209-
r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all);
1210-
list_del(&r->mw_all);
1211-
list_del(&r->mw_list);
1212-
1213-
rc = ib_dealloc_fmr(r->r.fmr);
1214-
if (rc)
1215-
dprintk("RPC: %s: ib_dealloc_fmr failed %i\n",
1216-
__func__, rc);
1217-
1218-
kfree(r);
1219-
}
1220-
}
1221-
1222-
static void
1223-
rpcrdma_destroy_frmrs(struct rpcrdma_buffer *buf)
1224-
{
1225-
struct rpcrdma_mw *r;
1226-
int rc;
1227-
1228-
while (!list_empty(&buf->rb_all)) {
1229-
r = list_entry(buf->rb_all.next, struct rpcrdma_mw, mw_all);
1230-
list_del(&r->mw_all);
1231-
list_del(&r->mw_list);
1232-
1233-
rc = ib_dereg_mr(r->r.frmr.fr_mr);
1234-
if (rc)
1235-
dprintk("RPC: %s: ib_dereg_mr failed %i\n",
1236-
__func__, rc);
1237-
ib_free_fast_reg_page_list(r->r.frmr.fr_pgl);
1238-
1239-
kfree(r);
1240-
}
1241-
}
1242-
12431202
void
12441203
rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
12451204
{
@@ -1260,16 +1219,7 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
12601219
rpcrdma_destroy_req(ia, buf->rb_send_bufs[i]);
12611220
}
12621221

1263-
switch (ia->ri_memreg_strategy) {
1264-
case RPCRDMA_FRMR:
1265-
rpcrdma_destroy_frmrs(buf);
1266-
break;
1267-
case RPCRDMA_MTHCAFMR:
1268-
rpcrdma_destroy_fmrs(buf);
1269-
break;
1270-
default:
1271-
break;
1272-
}
1222+
ia->ri_ops->ro_destroy(buf);
12731223

12741224
kfree(buf->rb_pool);
12751225
}

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ struct rpcrdma_memreg_ops {
343343
size_t (*ro_maxpages)(struct rpcrdma_xprt *);
344344
int (*ro_init)(struct rpcrdma_xprt *);
345345
void (*ro_reset)(struct rpcrdma_xprt *);
346+
void (*ro_destroy)(struct rpcrdma_buffer *);
346347
const char *ro_displayname;
347348
};
348349

0 commit comments

Comments
 (0)