diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2015-03-30 14:35:17 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2015-03-31 09:52:53 -0400 |
commit | 4561f347d49c645fd81d1f47b0fb460e8a6e4587 (patch) | |
tree | 139bf80af59a649e011c21f915d60ad2941850ef | |
parent | 31a701a94751509bb72e13d851f18ddcf22ff722 (diff) |
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 <chuck.lever@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Tested-by: Devesh Sharma <Devesh.Sharma@Emulex.Com>
Tested-by: Meghana Cheripady <Meghana.Cheripady@Emulex.Com>
Tested-by: Veeresh U. Kokatnur <veereshuk@chelsio.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | net/sunrpc/xprtrdma/fmr_ops.c | 18 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/frwr_ops.c | 14 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/physical_ops.c | 6 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/verbs.c | 52 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/xprt_rdma.h | 1 |
5 files changed, 40 insertions, 51 deletions
diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c index 93261b05891e..e9ca5944ac1e 100644 --- a/net/sunrpc/xprtrdma/fmr_ops.c +++ b/net/sunrpc/xprtrdma/fmr_ops.c | |||
@@ -168,11 +168,29 @@ fmr_op_reset(struct rpcrdma_xprt *r_xprt) | |||
168 | __func__, rc); | 168 | __func__, rc); |
169 | } | 169 | } |
170 | 170 | ||
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 | |||
171 | const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = { | 188 | const struct rpcrdma_memreg_ops rpcrdma_fmr_memreg_ops = { |
172 | .ro_map = fmr_op_map, | 189 | .ro_map = fmr_op_map, |
173 | .ro_unmap = fmr_op_unmap, | 190 | .ro_unmap = fmr_op_unmap, |
174 | .ro_maxpages = fmr_op_maxpages, | 191 | .ro_maxpages = fmr_op_maxpages, |
175 | .ro_init = fmr_op_init, | 192 | .ro_init = fmr_op_init, |
176 | .ro_reset = fmr_op_reset, | 193 | .ro_reset = fmr_op_reset, |
194 | .ro_destroy = fmr_op_destroy, | ||
177 | .ro_displayname = "fmr", | 195 | .ro_displayname = "fmr", |
178 | }; | 196 | }; |
diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c index c2bb29d4df3c..121e400d0565 100644 --- a/net/sunrpc/xprtrdma/frwr_ops.c +++ b/net/sunrpc/xprtrdma/frwr_ops.c | |||
@@ -260,11 +260,25 @@ frwr_op_reset(struct rpcrdma_xprt *r_xprt) | |||
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
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 | |||
263 | const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = { | 276 | const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = { |
264 | .ro_map = frwr_op_map, | 277 | .ro_map = frwr_op_map, |
265 | .ro_unmap = frwr_op_unmap, | 278 | .ro_unmap = frwr_op_unmap, |
266 | .ro_maxpages = frwr_op_maxpages, | 279 | .ro_maxpages = frwr_op_maxpages, |
267 | .ro_init = frwr_op_init, | 280 | .ro_init = frwr_op_init, |
268 | .ro_reset = frwr_op_reset, | 281 | .ro_reset = frwr_op_reset, |
282 | .ro_destroy = frwr_op_destroy, | ||
269 | .ro_displayname = "frwr", | 283 | .ro_displayname = "frwr", |
270 | }; | 284 | }; |
diff --git a/net/sunrpc/xprtrdma/physical_ops.c b/net/sunrpc/xprtrdma/physical_ops.c index e0607136655b..eb39011e3129 100644 --- a/net/sunrpc/xprtrdma/physical_ops.c +++ b/net/sunrpc/xprtrdma/physical_ops.c | |||
@@ -64,11 +64,17 @@ physical_op_reset(struct rpcrdma_xprt *r_xprt) | |||
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | static void | ||
68 | physical_op_destroy(struct rpcrdma_buffer *buf) | ||
69 | { | ||
70 | } | ||
71 | |||
67 | const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = { | 72 | const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = { |
68 | .ro_map = physical_op_map, | 73 | .ro_map = physical_op_map, |
69 | .ro_unmap = physical_op_unmap, | 74 | .ro_unmap = physical_op_unmap, |
70 | .ro_maxpages = physical_op_maxpages, | 75 | .ro_maxpages = physical_op_maxpages, |
71 | .ro_init = physical_op_init, | 76 | .ro_init = physical_op_init, |
72 | .ro_reset = physical_op_reset, | 77 | .ro_reset = physical_op_reset, |
78 | .ro_destroy = physical_op_destroy, | ||
73 | .ro_displayname = "physical", | 79 | .ro_displayname = "physical", |
74 | }; | 80 | }; |
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 1b2c1f4ec4c3..a7fb31441069 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c | |||
@@ -1199,47 +1199,6 @@ rpcrdma_destroy_req(struct rpcrdma_ia *ia, struct rpcrdma_req *req) | |||
1199 | kfree(req); | 1199 | kfree(req); |
1200 | } | 1200 | } |
1201 | 1201 | ||
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 | |||
1243 | void | 1202 | void |
1244 | rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) | 1203 | rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) |
1245 | { | 1204 | { |
@@ -1260,16 +1219,7 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf) | |||
1260 | rpcrdma_destroy_req(ia, buf->rb_send_bufs[i]); | 1219 | rpcrdma_destroy_req(ia, buf->rb_send_bufs[i]); |
1261 | } | 1220 | } |
1262 | 1221 | ||
1263 | switch (ia->ri_memreg_strategy) { | 1222 | ia->ri_ops->ro_destroy(buf); |
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 | } | ||
1273 | 1223 | ||
1274 | kfree(buf->rb_pool); | 1224 | kfree(buf->rb_pool); |
1275 | } | 1225 | } |
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index 06802394cf89..b95e223d3d69 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h | |||
@@ -343,6 +343,7 @@ struct rpcrdma_memreg_ops { | |||
343 | size_t (*ro_maxpages)(struct rpcrdma_xprt *); | 343 | size_t (*ro_maxpages)(struct rpcrdma_xprt *); |
344 | int (*ro_init)(struct rpcrdma_xprt *); | 344 | int (*ro_init)(struct rpcrdma_xprt *); |
345 | void (*ro_reset)(struct rpcrdma_xprt *); | 345 | void (*ro_reset)(struct rpcrdma_xprt *); |
346 | void (*ro_destroy)(struct rpcrdma_buffer *); | ||
346 | const char *ro_displayname; | 347 | const char *ro_displayname; |
347 | }; | 348 | }; |
348 | 349 | ||