]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
xprtrdma: Introduce rpcrdma_mw_unmap_and_put
authorChuck Lever <chuck.lever@oracle.com>
Fri, 15 Dec 2017 01:58:04 +0000 (20:58 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 16 Jan 2018 16:19:52 +0000 (11:19 -0500)
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>
net/sunrpc/xprtrdma/fmr_ops.c
net/sunrpc/xprtrdma/frwr_ops.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index 8bd0399b3a1c26abe5f1ca2db4c08093c5070a8a..7f2f2b774076c1a3118583fe7dfb1a1e829d6dfb 100644 (file)
@@ -135,14 +135,12 @@ fmr_op_recover_mr(struct rpcrdma_mr *mr)
 
        /* ORDER: invalidate first */
        rc = __fmr_unmap(mr);
-
-       /* ORDER: then DMA unmap */
-       ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
-                       mr->mr_sg, mr->mr_nents, mr->mr_dir);
        if (rc)
                goto out_release;
 
-       rpcrdma_mr_put(mr);
+       /* ORDER: then DMA unmap */
+       rpcrdma_mr_unmap_and_put(mr);
+
        r_xprt->rx_stats.mrs_recovered++;
        return;
 
@@ -150,6 +148,9 @@ fmr_op_recover_mr(struct rpcrdma_mr *mr)
        pr_err("rpcrdma: FMR reset failed (%d), %p released\n", rc, mr);
        r_xprt->rx_stats.mrs_orphaned++;
 
+       ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
+                       mr->mr_sg, mr->mr_nents, mr->mr_dir);
+
        spin_lock(&r_xprt->rx_buf.rb_mrlock);
        list_del(&mr->mr_all);
        spin_unlock(&r_xprt->rx_buf.rb_mrlock);
@@ -245,9 +246,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
        pr_err("rpcrdma: ib_map_phys_fmr %u@0x%llx+%i (%d) status %i\n",
               len, (unsigned long long)dma_pages[0],
               pageoff, mr->mr_nents, rc);
-       ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
-                       mr->mr_sg, mr->mr_nents, mr->mr_dir);
-       rpcrdma_mr_put(mr);
+       rpcrdma_mr_unmap_and_put(mr);
        return ERR_PTR(-EIO);
 }
 
@@ -289,9 +288,7 @@ fmr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs)
                dprintk("RPC:       %s: DMA unmapping fmr %p\n",
                        __func__, &mr->fmr);
                list_del(&mr->fmr.fm_mr->list);
-               ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
-                               mr->mr_sg, mr->mr_nents, mr->mr_dir);
-               rpcrdma_mr_put(mr);
+               rpcrdma_mr_unmap_and_put(mr);
        }
 
        return;
index 8ba4b3388a982a2d972274c1a802469ace09f8ba..35e3a54344ccc48b7d5bea85ac6dd58f221f4d6a 100644 (file)
@@ -459,13 +459,9 @@ frwr_op_reminv(struct rpcrdma_rep *rep, struct list_head *mrs)
 
        list_for_each_entry(mr, mrs, mr_list)
                if (mr->mr_handle == rep->rr_inv_rkey) {
-                       struct rpcrdma_xprt *r_xprt = mr->mr_xprt;
-
                        list_del(&mr->mr_list);
                        mr->frwr.fr_state = FRWR_IS_INVALID;
-                       ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
-                                       mr->mr_sg, mr->mr_nents, mr->mr_dir);
-                       rpcrdma_mr_put(mr);
+                       rpcrdma_mr_unmap_and_put(mr);
                        break;  /* only one invalidated MR per RPC */
                }
 }
@@ -545,9 +541,7 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct list_head *mrs)
                mr = rpcrdma_mr_pop(mrs);
                dprintk("RPC:       %s: DMA unmapping frwr %p\n",
                        __func__, &mr->frwr);
-               ib_dma_unmap_sg(ia->ri_device,
-                               mr->mr_sg, mr->mr_nents, mr->mr_dir);
-               rpcrdma_mr_put(mr);
+               rpcrdma_mr_unmap_and_put(mr);
        }
        return;
 
index 2582729f8c644483ed8f5eab41410cc97d649e40..9cc8abc09e14462a0a96441c8b15a7b359428d22 100644 (file)
@@ -1321,6 +1321,14 @@ rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt)
        return NULL;
 }
 
+static void
+__rpcrdma_mr_put(struct rpcrdma_buffer *buf, struct rpcrdma_mr *mr)
+{
+       spin_lock(&buf->rb_mrlock);
+       rpcrdma_mr_push(mr, &buf->rb_mrs);
+       spin_unlock(&buf->rb_mrlock);
+}
+
 /**
  * rpcrdma_mr_put - Release an rpcrdma_mr object
  * @mr: object to release
@@ -1328,13 +1336,23 @@ rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt)
  */
 void
 rpcrdma_mr_put(struct rpcrdma_mr *mr)
+{
+       __rpcrdma_mr_put(&mr->mr_xprt->rx_buf, mr);
+}
+
+/**
+ * rpcrdma_mr_unmap_and_put - DMA unmap an MR and release it
+ * @mr: object to release
+ *
+ */
+void
+rpcrdma_mr_unmap_and_put(struct rpcrdma_mr *mr)
 {
        struct rpcrdma_xprt *r_xprt = mr->mr_xprt;
-       struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
 
-       spin_lock(&buf->rb_mrlock);
-       rpcrdma_mr_push(mr, &buf->rb_mrs);
-       spin_unlock(&buf->rb_mrlock);
+       ib_dma_unmap_sg(r_xprt->rx_ia.ri_device,
+                       mr->mr_sg, mr->mr_nents, mr->mr_dir);
+       __rpcrdma_mr_put(&r_xprt->rx_buf, mr);
 }
 
 static struct rpcrdma_rep *
index 530ace6ed125eab61715171f5f73b7c2d336e214..28ae1fb1e2f3bb62e36bf72c011d1917f523f5b4 100644 (file)
@@ -576,6 +576,7 @@ void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc);
 
 struct rpcrdma_mr *rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt);
 void rpcrdma_mr_put(struct rpcrdma_mr *mr);
+void rpcrdma_mr_unmap_and_put(struct rpcrdma_mr *mr);
 void rpcrdma_mr_defer_recovery(struct rpcrdma_mr *mr);
 
 struct rpcrdma_req *rpcrdma_buffer_get(struct rpcrdma_buffer *);