xprtrdma: Refactor the FRWR recovery worker
authorChuck Lever <chuck.lever@oracle.com>
Mon, 2 May 2016 18:42:21 +0000 (14:42 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 17 May 2016 19:48:02 +0000 (15:48 -0400)
Maintain the order of invalidation and DMA unmapping when doing
a background MR reset.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/frwr_ops.c

index ce245dc4acabc8c67184c6577ef4e5000826ac4a..4e0a5c1abea4b9717693999c0812b58e545e251c 100644 (file)
@@ -124,6 +124,21 @@ __frwr_reset_mr(struct rpcrdma_ia *ia, struct rpcrdma_mw *r)
        return 0;
 }
 
+static void
+__frwr_reset_and_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mw *mw)
+{
+       struct rpcrdma_ia *ia = &r_xprt->rx_ia;
+       struct rpcrdma_frmr *f = &mw->frmr;
+       int rc;
+
+       rc = __frwr_reset_mr(ia, mw);
+       ib_dma_unmap_sg(ia->ri_device, f->fr_sg, f->fr_nents, f->fr_dir);
+       if (rc)
+               return;
+
+       rpcrdma_put_mw(r_xprt, mw);
+}
+
 /* Deferred reset of a single FRMR. Generate a fresh rkey by
  * replacing the MR.
  *
@@ -136,15 +151,8 @@ __frwr_recovery_worker(struct work_struct *work)
 {
        struct rpcrdma_mw *r = container_of(work, struct rpcrdma_mw,
                                            frmr.fr_work);
-       struct rpcrdma_xprt *r_xprt = r->frmr.fr_xprt;
-       struct rpcrdma_ia *ia = &r_xprt->rx_ia;
-       int rc;
-
-       rc = __frwr_reset_mr(ia, r);
-       if (rc)
-               return;
 
-       rpcrdma_put_mw(r_xprt, r);
+       __frwr_reset_and_unmap(r->frmr.fr_xprt, r);
        return;
 }
 
@@ -483,7 +491,6 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
 
 out_senderr:
        dprintk("RPC:       %s: ib_post_send status %i\n", __func__, rc);
-       ib_dma_unmap_sg(device, frmr->fr_sg, dma_nents, direction);
        __frwr_queue_recovery(mw);
        return rc;
 }