frwr_ops.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2015, 2017 Oracle. All rights reserved.
  4. * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
  5. */
  6. /* Lightweight memory registration using Fast Registration Work
  7. * Requests (FRWR).
  8. *
  9. * FRWR features ordered asynchronous registration and deregistration
  10. * of arbitrarily sized memory regions. This is the fastest and safest
  11. * but most complex memory registration mode.
  12. */
  13. /* Normal operation
  14. *
  15. * A Memory Region is prepared for RDMA READ or WRITE using a FAST_REG
  16. * Work Request (frwr_op_map). When the RDMA operation is finished, this
  17. * Memory Region is invalidated using a LOCAL_INV Work Request
  18. * (frwr_op_unmap_sync).
  19. *
  20. * Typically these Work Requests are not signaled, and neither are RDMA
  21. * SEND Work Requests (with the exception of signaling occasionally to
  22. * prevent provider work queue overflows). This greatly reduces HCA
  23. * interrupt workload.
  24. *
  25. * As an optimization, frwr_op_unmap marks MRs INVALID before the
  26. * LOCAL_INV WR is posted. If posting succeeds, the MR is placed on
  27. * rb_mrs immediately so that no work (like managing a linked list
  28. * under a spinlock) is needed in the completion upcall.
  29. *
  30. * But this means that frwr_op_map() can occasionally encounter an MR
  31. * that is INVALID but the LOCAL_INV WR has not completed. Work Queue
  32. * ordering prevents a subsequent FAST_REG WR from executing against
  33. * that MR while it is still being invalidated.
  34. */
  35. /* Transport recovery
  36. *
  37. * ->op_map and the transport connect worker cannot run at the same
  38. * time, but ->op_unmap can fire while the transport connect worker
  39. * is running. Thus MR recovery is handled in ->op_map, to guarantee
  40. * that recovered MRs are owned by a sending RPC, and not one where
  41. * ->op_unmap could fire at the same time transport reconnect is
  42. * being done.
  43. *
  44. * When the underlying transport disconnects, MRs are left in one of
  45. * four states:
  46. *
  47. * INVALID: The MR was not in use before the QP entered ERROR state.
  48. *
  49. * VALID: The MR was registered before the QP entered ERROR state.
  50. *
  51. * FLUSHED_FR: The MR was being registered when the QP entered ERROR
  52. * state, and the pending WR was flushed.
  53. *
  54. * FLUSHED_LI: The MR was being invalidated when the QP entered ERROR
  55. * state, and the pending WR was flushed.
  56. *
  57. * When frwr_op_map encounters FLUSHED and VALID MRs, they are recovered
  58. * with ib_dereg_mr and then are re-initialized. Because MR recovery
  59. * allocates fresh resources, it is deferred to a workqueue, and the
  60. * recovered MRs are placed back on the rb_mrs list when recovery is
  61. * complete. frwr_op_map allocates another MR for the current RPC while
  62. * the broken MR is reset.
  63. *
  64. * To ensure that frwr_op_map doesn't encounter an MR that is marked
  65. * INVALID but that is about to be flushed due to a previous transport
  66. * disconnect, the transport connect worker attempts to drain all
  67. * pending send queue WRs before the transport is reconnected.
  68. */
  69. #include <linux/sunrpc/rpc_rdma.h>
  70. #include <linux/sunrpc/svc_rdma.h>
  71. #include "xprt_rdma.h"
  72. #include <trace/events/rpcrdma.h>
  73. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  74. # define RPCDBG_FACILITY RPCDBG_TRANS
  75. #endif
  76. bool
  77. frwr_is_supported(struct rpcrdma_ia *ia)
  78. {
  79. struct ib_device_attr *attrs = &ia->ri_device->attrs;
  80. if (!(attrs->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
  81. goto out_not_supported;
  82. if (attrs->max_fast_reg_page_list_len == 0)
  83. goto out_not_supported;
  84. return true;
  85. out_not_supported:
  86. pr_info("rpcrdma: 'frwr' mode is not supported by device %s\n",
  87. ia->ri_device->name);
  88. return false;
  89. }
  90. static void
  91. frwr_op_release_mr(struct rpcrdma_mr *mr)
  92. {
  93. int rc;
  94. rc = ib_dereg_mr(mr->frwr.fr_mr);
  95. if (rc)
  96. pr_err("rpcrdma: final ib_dereg_mr for %p returned %i\n",
  97. mr, rc);
  98. kfree(mr->mr_sg);
  99. kfree(mr);
  100. }
  101. /* MRs are dynamically allocated, so simply clean up and release the MR.
  102. * A replacement MR will subsequently be allocated on demand.
  103. */
  104. static void
  105. frwr_mr_recycle_worker(struct work_struct *work)
  106. {
  107. struct rpcrdma_mr *mr = container_of(work, struct rpcrdma_mr, mr_recycle);
  108. enum rpcrdma_frwr_state state = mr->frwr.fr_state;
  109. struct rpcrdma_xprt *r_xprt = mr->mr_xprt;
  110. trace_xprtrdma_mr_recycle(mr);
  111. if (state != FRWR_FLUSHED_LI) {
  112. trace_xprtrdma_mr_unmap(mr);
  113. ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
  114. mr->mr_sg, mr->mr_nents, mr->mr_dir);
  115. }
  116. spin_lock(&r_xprt->rx_buf.rb_mrlock);
  117. list_del(&mr->mr_all);
  118. r_xprt->rx_stats.mrs_recycled++;
  119. spin_unlock(&r_xprt->rx_buf.rb_mrlock);
  120. frwr_op_release_mr(mr);
  121. }
  122. static int
  123. frwr_op_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr)
  124. {
  125. unsigned int depth = ia->ri_max_frwr_depth;
  126. struct rpcrdma_frwr *frwr = &mr->frwr;
  127. int rc;
  128. frwr->fr_mr = ib_alloc_mr(ia->ri_pd, ia->ri_mrtype, depth);
  129. if (IS_ERR(frwr->fr_mr))
  130. goto out_mr_err;
  131. mr->mr_sg = kcalloc(depth, sizeof(*mr->mr_sg), GFP_KERNEL);
  132. if (!mr->mr_sg)
  133. goto out_list_err;
  134. INIT_LIST_HEAD(&mr->mr_list);
  135. INIT_WORK(&mr->mr_recycle, frwr_mr_recycle_worker);
  136. sg_init_table(mr->mr_sg, depth);
  137. init_completion(&frwr->fr_linv_done);
  138. return 0;
  139. out_mr_err:
  140. rc = PTR_ERR(frwr->fr_mr);
  141. dprintk("RPC: %s: ib_alloc_mr status %i\n",
  142. __func__, rc);
  143. return rc;
  144. out_list_err:
  145. rc = -ENOMEM;
  146. dprintk("RPC: %s: sg allocation failure\n",
  147. __func__);
  148. ib_dereg_mr(frwr->fr_mr);
  149. return rc;
  150. }
  151. /* On success, sets:
  152. * ep->rep_attr.cap.max_send_wr
  153. * ep->rep_attr.cap.max_recv_wr
  154. * cdata->max_requests
  155. * ia->ri_max_segs
  156. *
  157. * And these FRWR-related fields:
  158. * ia->ri_max_frwr_depth
  159. * ia->ri_mrtype
  160. */
  161. static int
  162. frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
  163. struct rpcrdma_create_data_internal *cdata)
  164. {
  165. struct ib_device_attr *attrs = &ia->ri_device->attrs;
  166. int max_qp_wr, depth, delta;
  167. ia->ri_mrtype = IB_MR_TYPE_MEM_REG;
  168. if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG)
  169. ia->ri_mrtype = IB_MR_TYPE_SG_GAPS;
  170. ia->ri_max_frwr_depth =
  171. min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
  172. attrs->max_fast_reg_page_list_len);
  173. dprintk("RPC: %s: device's max FR page list len = %u\n",
  174. __func__, ia->ri_max_frwr_depth);
  175. /* Add room for frwr register and invalidate WRs.
  176. * 1. FRWR reg WR for head
  177. * 2. FRWR invalidate WR for head
  178. * 3. N FRWR reg WRs for pagelist
  179. * 4. N FRWR invalidate WRs for pagelist
  180. * 5. FRWR reg WR for tail
  181. * 6. FRWR invalidate WR for tail
  182. * 7. The RDMA_SEND WR
  183. */
  184. depth = 7;
  185. /* Calculate N if the device max FRWR depth is smaller than
  186. * RPCRDMA_MAX_DATA_SEGS.
  187. */
  188. if (ia->ri_max_frwr_depth < RPCRDMA_MAX_DATA_SEGS) {
  189. delta = RPCRDMA_MAX_DATA_SEGS - ia->ri_max_frwr_depth;
  190. do {
  191. depth += 2; /* FRWR reg + invalidate */
  192. delta -= ia->ri_max_frwr_depth;
  193. } while (delta > 0);
  194. }
  195. max_qp_wr = ia->ri_device->attrs.max_qp_wr;
  196. max_qp_wr -= RPCRDMA_BACKWARD_WRS;
  197. max_qp_wr -= 1;
  198. if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
  199. return -ENOMEM;
  200. if (cdata->max_requests > max_qp_wr)
  201. cdata->max_requests = max_qp_wr;
  202. ep->rep_attr.cap.max_send_wr = cdata->max_requests * depth;
  203. if (ep->rep_attr.cap.max_send_wr > max_qp_wr) {
  204. cdata->max_requests = max_qp_wr / depth;
  205. if (!cdata->max_requests)
  206. return -EINVAL;
  207. ep->rep_attr.cap.max_send_wr = cdata->max_requests *
  208. depth;
  209. }
  210. ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
  211. ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
  212. ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
  213. ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
  214. ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
  215. ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS /
  216. ia->ri_max_frwr_depth);
  217. ia->ri_max_segs += 2; /* segments for head and tail buffers */
  218. return 0;
  219. }
  220. /* FRWR mode conveys a list of pages per chunk segment. The
  221. * maximum length of that list is the FRWR page list depth.
  222. */
  223. static size_t
  224. frwr_op_maxpages(struct rpcrdma_xprt *r_xprt)
  225. {
  226. struct rpcrdma_ia *ia = &r_xprt->rx_ia;
  227. return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
  228. RPCRDMA_MAX_HDR_SEGS * ia->ri_max_frwr_depth);
  229. }
  230. static void
  231. __frwr_sendcompletion_flush(struct ib_wc *wc, const char *wr)
  232. {
  233. if (wc->status != IB_WC_WR_FLUSH_ERR)
  234. pr_err("rpcrdma: %s: %s (%u/0x%x)\n",
  235. wr, ib_wc_status_msg(wc->status),
  236. wc->status, wc->vendor_err);
  237. }
  238. /**
  239. * frwr_wc_fastreg - Invoked by RDMA provider for a flushed FastReg WC
  240. * @cq: completion queue (ignored)
  241. * @wc: completed WR
  242. *
  243. */
  244. static void
  245. frwr_wc_fastreg(struct ib_cq *cq, struct ib_wc *wc)
  246. {
  247. struct ib_cqe *cqe = wc->wr_cqe;
  248. struct rpcrdma_frwr *frwr =
  249. container_of(cqe, struct rpcrdma_frwr, fr_cqe);
  250. /* WARNING: Only wr_cqe and status are reliable at this point */
  251. if (wc->status != IB_WC_SUCCESS) {
  252. frwr->fr_state = FRWR_FLUSHED_FR;
  253. __frwr_sendcompletion_flush(wc, "fastreg");
  254. }
  255. trace_xprtrdma_wc_fastreg(wc, frwr);
  256. }
  257. /**
  258. * frwr_wc_localinv - Invoked by RDMA provider for a flushed LocalInv WC
  259. * @cq: completion queue (ignored)
  260. * @wc: completed WR
  261. *
  262. */
  263. static void
  264. frwr_wc_localinv(struct ib_cq *cq, struct ib_wc *wc)
  265. {
  266. struct ib_cqe *cqe = wc->wr_cqe;
  267. struct rpcrdma_frwr *frwr = container_of(cqe, struct rpcrdma_frwr,
  268. fr_cqe);
  269. /* WARNING: Only wr_cqe and status are reliable at this point */
  270. if (wc->status != IB_WC_SUCCESS) {
  271. frwr->fr_state = FRWR_FLUSHED_LI;
  272. __frwr_sendcompletion_flush(wc, "localinv");
  273. }
  274. trace_xprtrdma_wc_li(wc, frwr);
  275. }
  276. /**
  277. * frwr_wc_localinv_wake - Invoked by RDMA provider for a signaled LocalInv WC
  278. * @cq: completion queue (ignored)
  279. * @wc: completed WR
  280. *
  281. * Awaken anyone waiting for an MR to finish being fenced.
  282. */
  283. static void
  284. frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc)
  285. {
  286. struct ib_cqe *cqe = wc->wr_cqe;
  287. struct rpcrdma_frwr *frwr = container_of(cqe, struct rpcrdma_frwr,
  288. fr_cqe);
  289. /* WARNING: Only wr_cqe and status are reliable at this point */
  290. if (wc->status != IB_WC_SUCCESS) {
  291. frwr->fr_state = FRWR_FLUSHED_LI;
  292. __frwr_sendcompletion_flush(wc, "localinv");
  293. }
  294. complete(&frwr->fr_linv_done);
  295. trace_xprtrdma_wc_li_wake(wc, frwr);
  296. }
  297. /* Post a REG_MR Work Request to register a memory region
  298. * for remote access via RDMA READ or RDMA WRITE.
  299. */
  300. static struct rpcrdma_mr_seg *
  301. frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
  302. int nsegs, bool writing, struct rpcrdma_mr **out)
  303. {
  304. struct rpcrdma_ia *ia = &r_xprt->rx_ia;
  305. bool holes_ok = ia->ri_mrtype == IB_MR_TYPE_SG_GAPS;
  306. struct rpcrdma_frwr *frwr;
  307. struct rpcrdma_mr *mr;
  308. struct ib_mr *ibmr;
  309. struct ib_reg_wr *reg_wr;
  310. int i, n;
  311. u8 key;
  312. mr = NULL;
  313. do {
  314. if (mr)
  315. rpcrdma_mr_recycle(mr);
  316. mr = rpcrdma_mr_get(r_xprt);
  317. if (!mr)
  318. return ERR_PTR(-EAGAIN);
  319. } while (mr->frwr.fr_state != FRWR_IS_INVALID);
  320. frwr = &mr->frwr;
  321. frwr->fr_state = FRWR_IS_VALID;
  322. if (nsegs > ia->ri_max_frwr_depth)
  323. nsegs = ia->ri_max_frwr_depth;
  324. for (i = 0; i < nsegs;) {
  325. if (seg->mr_page)
  326. sg_set_page(&mr->mr_sg[i],
  327. seg->mr_page,
  328. seg->mr_len,
  329. offset_in_page(seg->mr_offset));
  330. else
  331. sg_set_buf(&mr->mr_sg[i], seg->mr_offset,
  332. seg->mr_len);
  333. ++seg;
  334. ++i;
  335. if (holes_ok)
  336. continue;
  337. if ((i < nsegs && offset_in_page(seg->mr_offset)) ||
  338. offset_in_page((seg-1)->mr_offset + (seg-1)->mr_len))
  339. break;
  340. }
  341. mr->mr_dir = rpcrdma_data_dir(writing);
  342. mr->mr_nents = ib_dma_map_sg(ia->ri_device, mr->mr_sg, i, mr->mr_dir);
  343. if (!mr->mr_nents)
  344. goto out_dmamap_err;
  345. trace_xprtrdma_mr_map(mr);
  346. ibmr = frwr->fr_mr;
  347. n = ib_map_mr_sg(ibmr, mr->mr_sg, mr->mr_nents, NULL, PAGE_SIZE);
  348. if (unlikely(n != mr->mr_nents))
  349. goto out_mapmr_err;
  350. key = (u8)(ibmr->rkey & 0x000000FF);
  351. ib_update_fast_reg_key(ibmr, ++key);
  352. reg_wr = &frwr->fr_regwr;
  353. reg_wr->mr = ibmr;
  354. reg_wr->key = ibmr->rkey;
  355. reg_wr->access = writing ?
  356. IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
  357. IB_ACCESS_REMOTE_READ;
  358. mr->mr_handle = ibmr->rkey;
  359. mr->mr_length = ibmr->length;
  360. mr->mr_offset = ibmr->iova;
  361. *out = mr;
  362. return seg;
  363. out_dmamap_err:
  364. pr_err("rpcrdma: failed to DMA map sg %p sg_nents %d\n",
  365. mr->mr_sg, i);
  366. frwr->fr_state = FRWR_IS_INVALID;
  367. rpcrdma_mr_put(mr);
  368. return ERR_PTR(-EIO);
  369. out_mapmr_err:
  370. pr_err("rpcrdma: failed to map mr %p (%d/%d)\n",
  371. frwr->fr_mr, n, mr->mr_nents);
  372. rpcrdma_mr_recycle(mr);
  373. return ERR_PTR(-EIO);
  374. }
  375. /* Post Send WR containing the RPC Call message.
  376. *
  377. * For FRMR, chain any FastReg WRs to the Send WR. Only a
  378. * single ib_post_send call is needed to register memory
  379. * and then post the Send WR.
  380. */
  381. static int
  382. frwr_op_send(struct rpcrdma_ia *ia, struct rpcrdma_req *req)
  383. {
  384. struct ib_send_wr *post_wr;
  385. struct rpcrdma_mr *mr;
  386. post_wr = &req->rl_sendctx->sc_wr;
  387. list_for_each_entry(mr, &req->rl_registered, mr_list) {
  388. struct rpcrdma_frwr *frwr;
  389. frwr = &mr->frwr;
  390. frwr->fr_cqe.done = frwr_wc_fastreg;
  391. frwr->fr_regwr.wr.next = post_wr;
  392. frwr->fr_regwr.wr.wr_cqe = &frwr->fr_cqe;
  393. frwr->fr_regwr.wr.num_sge = 0;
  394. frwr->fr_regwr.wr.opcode = IB_WR_REG_MR;
  395. frwr->fr_regwr.wr.send_flags = 0;
  396. post_wr = &frwr->fr_regwr.wr;
  397. }
  398. /* If ib_post_send fails, the next ->send_request for
  399. * @req will queue these MWs for recovery.
  400. */
  401. return ib_post_send(ia->ri_id->qp, post_wr, NULL);
  402. }
  403. /* Handle a remotely invalidated mr on the @mrs list
  404. */
  405. static void
  406. frwr_op_reminv(struct rpcrdma_rep *rep, struct list_head *mrs)
  407. {
  408. struct rpcrdma_mr *mr;
  409. list_for_each_entry(mr, mrs, mr_list)
  410. if (mr->mr_handle == rep->rr_inv_rkey) {
  411. list_del_init(&mr->mr_list);
  412. trace_xprtrdma_mr_remoteinv(mr);
  413. mr->frwr.fr_state = FRWR_IS_INVALID;
  414. rpcrdma_mr_unmap_and_put(mr);
  415. break; /* only one invalidated MR per RPC */
  416. }
  417. }
  418. /* Invalidate all memory regions that were registered for "req".
  419. *
  420. * Sleeps until it is safe for the host CPU to access the
  421. * previously mapped memory regions.
  422. *
  423. * Caller ensures that @mrs is not empty before the call. This
  424. * function empties the list.
  425. */
  426. static void
  427. frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs)
  428. {
  429. struct ib_send_wr *first, **prev, *last;
  430. const struct ib_send_wr *bad_wr;
  431. struct rpcrdma_ia *ia = &r_xprt->rx_ia;
  432. struct rpcrdma_frwr *frwr;
  433. struct rpcrdma_mr *mr;
  434. int count, rc;
  435. /* ORDER: Invalidate all of the MRs first
  436. *
  437. * Chain the LOCAL_INV Work Requests and post them with
  438. * a single ib_post_send() call.
  439. */
  440. frwr = NULL;
  441. count = 0;
  442. prev = &first;
  443. list_for_each_entry(mr, mrs, mr_list) {
  444. mr->frwr.fr_state = FRWR_IS_INVALID;
  445. frwr = &mr->frwr;
  446. trace_xprtrdma_mr_localinv(mr);
  447. frwr->fr_cqe.done = frwr_wc_localinv;
  448. last = &frwr->fr_invwr;
  449. memset(last, 0, sizeof(*last));
  450. last->wr_cqe = &frwr->fr_cqe;
  451. last->opcode = IB_WR_LOCAL_INV;
  452. last->ex.invalidate_rkey = mr->mr_handle;
  453. count++;
  454. *prev = last;
  455. prev = &last->next;
  456. }
  457. if (!frwr)
  458. goto unmap;
  459. /* Strong send queue ordering guarantees that when the
  460. * last WR in the chain completes, all WRs in the chain
  461. * are complete.
  462. */
  463. last->send_flags = IB_SEND_SIGNALED;
  464. frwr->fr_cqe.done = frwr_wc_localinv_wake;
  465. reinit_completion(&frwr->fr_linv_done);
  466. /* Transport disconnect drains the receive CQ before it
  467. * replaces the QP. The RPC reply handler won't call us
  468. * unless ri_id->qp is a valid pointer.
  469. */
  470. r_xprt->rx_stats.local_inv_needed++;
  471. bad_wr = NULL;
  472. rc = ib_post_send(ia->ri_id->qp, first, &bad_wr);
  473. if (bad_wr != first)
  474. wait_for_completion(&frwr->fr_linv_done);
  475. if (rc)
  476. goto out_release;
  477. /* ORDER: Now DMA unmap all of the MRs, and return
  478. * them to the free MR list.
  479. */
  480. unmap:
  481. while (!list_empty(mrs)) {
  482. mr = rpcrdma_mr_pop(mrs);
  483. rpcrdma_mr_unmap_and_put(mr);
  484. }
  485. return;
  486. out_release:
  487. pr_err("rpcrdma: FRWR invalidate ib_post_send returned %i\n", rc);
  488. /* Unmap and release the MRs in the LOCAL_INV WRs that did not
  489. * get posted.
  490. */
  491. while (bad_wr) {
  492. frwr = container_of(bad_wr, struct rpcrdma_frwr,
  493. fr_invwr);
  494. mr = container_of(frwr, struct rpcrdma_mr, frwr);
  495. bad_wr = bad_wr->next;
  496. list_del(&mr->mr_list);
  497. frwr_op_release_mr(mr);
  498. }
  499. }
  500. const struct rpcrdma_memreg_ops rpcrdma_frwr_memreg_ops = {
  501. .ro_map = frwr_op_map,
  502. .ro_send = frwr_op_send,
  503. .ro_reminv = frwr_op_reminv,
  504. .ro_unmap_sync = frwr_op_unmap_sync,
  505. .ro_open = frwr_op_open,
  506. .ro_maxpages = frwr_op_maxpages,
  507. .ro_init_mr = frwr_op_init_mr,
  508. .ro_release_mr = frwr_op_release_mr,
  509. .ro_displayname = "frwr",
  510. .ro_send_w_inv_ok = RPCRDMA_CMP_F_SND_W_INV_OK,
  511. };