]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xprtrdma: Simplify rpcrdma_mr_pop
authorChuck Lever <chuck.lever@oracle.com>
Mon, 19 Aug 2019 22:44:04 +0000 (18:44 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 20 Aug 2019 20:03:41 +0000 (16:03 -0400)
Clean up: rpcrdma_mr_pop call sites check if the list is empty
first. Let's replace the list_empty with less costly logic.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/frwr_ops.c
net/sunrpc/xprtrdma/rpc_rdma.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index 3a10bfff212546989f476496095ba4ccc0259827..d7e763fafa040d8328c20092d2c16ea5d9dde0e1 100644 (file)
@@ -126,12 +126,10 @@ frwr_mr_recycle_worker(struct work_struct *work)
  */
 void frwr_reset(struct rpcrdma_req *req)
 {
-       while (!list_empty(&req->rl_registered)) {
-               struct rpcrdma_mr *mr;
+       struct rpcrdma_mr *mr;
 
-               mr = rpcrdma_mr_pop(&req->rl_registered);
+       while ((mr = rpcrdma_mr_pop(&req->rl_registered)))
                rpcrdma_mr_unmap_and_put(mr);
-       }
 }
 
 /**
@@ -532,8 +530,7 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
         */
        frwr = NULL;
        prev = &first;
-       while (!list_empty(&req->rl_registered)) {
-               mr = rpcrdma_mr_pop(&req->rl_registered);
+       while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
 
                trace_xprtrdma_mr_localinv(mr);
                r_xprt->rx_stats.local_inv_needed++;
@@ -632,8 +629,7 @@ void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
         */
        frwr = NULL;
        prev = &first;
-       while (!list_empty(&req->rl_registered)) {
-               mr = rpcrdma_mr_pop(&req->rl_registered);
+       while ((mr = rpcrdma_mr_pop(&req->rl_registered))) {
 
                trace_xprtrdma_mr_localinv(mr);
                r_xprt->rx_stats.local_inv_needed++;
index 4345e6912392c5a8609e4fef17f0120fb5c0ac51..0ac096a6348aa70a6db8955c690b691f8f74b960 100644 (file)
@@ -841,12 +841,7 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
         * chunks. Very likely the connection has been replaced,
         * so these registrations are invalid and unusable.
         */
-       while (unlikely(!list_empty(&req->rl_registered))) {
-               struct rpcrdma_mr *mr;
-
-               mr = rpcrdma_mr_pop(&req->rl_registered);
-               rpcrdma_mr_recycle(mr);
-       }
+       frwr_reset(req);
 
        /* This implementation supports the following combinations
         * of chunk lists in one RPC-over-RDMA Call message:
index e004873cc4f05b1c6a19dbb734da057a6eb24da8..ee6fcf10425bfd797b26114181f55cbe2fc21b8a 100644 (file)
@@ -1213,13 +1213,11 @@ struct rpcrdma_mr *
 rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt)
 {
        struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
-       struct rpcrdma_mr *mr = NULL;
+       struct rpcrdma_mr *mr;
 
        spin_lock(&buf->rb_mrlock);
-       if (!list_empty(&buf->rb_mrs))
-               mr = rpcrdma_mr_pop(&buf->rb_mrs);
+       mr = rpcrdma_mr_pop(&buf->rb_mrs);
        spin_unlock(&buf->rb_mrlock);
-
        if (!mr)
                goto out_nomrs;
        return mr;
index 5aaa53b8ae1232e768c8bf42af0e5b5ab9c8a1d1..9663b8ddd7334b3cf0aa24c424dac33d8b27274e 100644 (file)
@@ -338,7 +338,7 @@ rpcr_to_rdmar(const struct rpc_rqst *rqst)
 static inline void
 rpcrdma_mr_push(struct rpcrdma_mr *mr, struct list_head *list)
 {
-       list_add_tail(&mr->mr_list, list);
+       list_add(&mr->mr_list, list);
 }
 
 static inline struct rpcrdma_mr *
@@ -346,8 +346,9 @@ rpcrdma_mr_pop(struct list_head *list)
 {
        struct rpcrdma_mr *mr;
 
-       mr = list_first_entry(list, struct rpcrdma_mr, mr_list);
-       list_del_init(&mr->mr_list);
+       mr = list_first_entry_or_null(list, struct rpcrdma_mr, mr_list);
+       if (mr)
+               list_del_init(&mr->mr_list);
        return mr;
 }