Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xprtrdma: Introduce rpcrdma_mw_unmap_and_put

Clean up: Code review suggested that a common bit of code can be
placed into a helper function, and this gives us fewer places to
stick an "I DMA unmapped something" trace point.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Chuck Lever and committed by
Anna Schumaker
ec12e479 96ceddea

+34 -24
+8 -11
net/sunrpc/xprtrdma/fmr_ops.c
··· 135 135 136 136 /* ORDER: invalidate first */ 137 137 rc = __fmr_unmap(mr); 138 - 139 - /* ORDER: then DMA unmap */ 140 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 141 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 142 138 if (rc) 143 139 goto out_release; 144 140 145 - rpcrdma_mr_put(mr); 141 + /* ORDER: then DMA unmap */ 142 + rpcrdma_mr_unmap_and_put(mr); 143 + 146 144 r_xprt->rx_stats.mrs_recovered++; 147 145 return; 148 146 149 147 out_release: 150 148 pr_err("rpcrdma: FMR reset failed (%d), %p released\n", rc, mr); 151 149 r_xprt->rx_stats.mrs_orphaned++; 150 + 151 + ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 152 + mr->mr_sg, mr->mr_nents, mr->mr_dir); 152 153 153 154 spin_lock(&r_xprt->rx_buf.rb_mrlock); 154 155 list_del(&mr->mr_all); ··· 246 245 pr_err("rpcrdma: ib_map_phys_fmr %u@0x%llx+%i (%d) status %i\n", 247 246 len, (unsigned long long)dma_pages[0], 248 247 pageoff, mr->mr_nents, rc); 249 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 250 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 251 - rpcrdma_mr_put(mr); 248 + rpcrdma_mr_unmap_and_put(mr); 252 249 return ERR_PTR(-EIO); 253 250 } 254 251 ··· 288 289 dprintk("RPC: %s: DMA unmapping fmr %p\n", 289 290 __func__, &mr->fmr); 290 291 list_del(&mr->fmr.fm_mr->list); 291 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 292 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 293 - rpcrdma_mr_put(mr); 292 + rpcrdma_mr_unmap_and_put(mr); 294 293 } 295 294 296 295 return;
+2 -8
net/sunrpc/xprtrdma/frwr_ops.c
··· 459 459 460 460 list_for_each_entry(mr, mrs, mr_list) 461 461 if (mr->mr_handle == rep->rr_inv_rkey) { 462 - struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 463 - 464 462 list_del(&mr->mr_list); 465 463 mr->frwr.fr_state = FRWR_IS_INVALID; 466 - ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 467 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 468 - rpcrdma_mr_put(mr); 464 + rpcrdma_mr_unmap_and_put(mr); 469 465 break; /* only one invalidated MR per RPC */ 470 466 } 471 467 } ··· 541 545 mr = rpcrdma_mr_pop(mrs); 542 546 dprintk("RPC: %s: DMA unmapping frwr %p\n", 543 547 __func__, &mr->frwr); 544 - ib_dma_unmap_sg(ia->ri_device, 545 - mr->mr_sg, mr->mr_nents, mr->mr_dir); 546 - rpcrdma_mr_put(mr); 548 + rpcrdma_mr_unmap_and_put(mr); 547 549 } 548 550 return; 549 551
+23 -5
net/sunrpc/xprtrdma/verbs.c
··· 1321 1321 return NULL; 1322 1322 } 1323 1323 1324 + static void 1325 + __rpcrdma_mr_put(struct rpcrdma_buffer *buf, struct rpcrdma_mr *mr) 1326 + { 1327 + spin_lock(&buf->rb_mrlock); 1328 + rpcrdma_mr_push(mr, &buf->rb_mrs); 1329 + spin_unlock(&buf->rb_mrlock); 1330 + } 1331 + 1324 1332 /** 1325 1333 * rpcrdma_mr_put - Release an rpcrdma_mr object 1326 1334 * @mr: object to release ··· 1337 1329 void 1338 1330 rpcrdma_mr_put(struct rpcrdma_mr *mr) 1339 1331 { 1340 - struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 1341 - struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 1332 + __rpcrdma_mr_put(&mr->mr_xprt->rx_buf, mr); 1333 + } 1342 1334 1343 - spin_lock(&buf->rb_mrlock); 1344 - rpcrdma_mr_push(mr, &buf->rb_mrs); 1345 - spin_unlock(&buf->rb_mrlock); 1335 + /** 1336 + * rpcrdma_mr_unmap_and_put - DMA unmap an MR and release it 1337 + * @mr: object to release 1338 + * 1339 + */ 1340 + void 1341 + rpcrdma_mr_unmap_and_put(struct rpcrdma_mr *mr) 1342 + { 1343 + struct rpcrdma_xprt *r_xprt = mr->mr_xprt; 1344 + 1345 + ib_dma_unmap_sg(r_xprt->rx_ia.ri_device, 1346 + mr->mr_sg, mr->mr_nents, mr->mr_dir); 1347 + __rpcrdma_mr_put(&r_xprt->rx_buf, mr); 1346 1348 } 1347 1349 1348 1350 static struct rpcrdma_rep *
+1
net/sunrpc/xprtrdma/xprt_rdma.h
··· 576 576 577 577 struct rpcrdma_mr *rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt); 578 578 void rpcrdma_mr_put(struct rpcrdma_mr *mr); 579 + void rpcrdma_mr_unmap_and_put(struct rpcrdma_mr *mr); 579 580 void rpcrdma_mr_defer_recovery(struct rpcrdma_mr *mr); 580 581 581 582 struct rpcrdma_req *rpcrdma_buffer_get(struct rpcrdma_buffer *);