]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
svcrdma: Simplify receive buffer posting
[linux-2.6-omap-h63xx.git] / net / sunrpc / xprtrdma / svc_rdma_recvfrom.c
index ab54a736486e258cf4e66aa2599decc161cdda66..f3a108a864adc7822cbcaae979254627f43c9e82 100644 (file)
@@ -237,14 +237,12 @@ static void rdma_set_ctxt_sge(struct svc_rdma_op_ctxt *ctxt,
 
 static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
 {
-#ifdef RDMA_TRANSPORT_IWARP
        if ((RDMA_TRANSPORT_IWARP ==
             rdma_node_get_transport(xprt->sc_cm_id->
                                     device->node_type))
            && sge_count > 1)
                return 1;
        else
-#endif
                return min_t(int, sge_count, xprt->sc_max_sge);
 }
 
@@ -324,15 +322,6 @@ next_sge:
                ctxt->direction = DMA_FROM_DEVICE;
                clear_bit(RDMACTXT_F_READ_DONE, &ctxt->flags);
                clear_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags);
-               if ((ch+1)->rc_discrim == 0) {
-                       /*
-                        * Checked in sq_cq_reap to see if we need to
-                        * be enqueued
-                        */
-                       set_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags);
-                       ctxt->next = hdr_ctxt;
-                       hdr_ctxt->next = head;
-               }
 
                /* Prepare READ WR */
                memset(&read_wr, 0, sizeof read_wr);
@@ -350,7 +339,17 @@ next_sge:
                rdma_set_ctxt_sge(ctxt, &sge[ch_sge_ary[ch_no].start],
                                  &sgl_offset,
                                  read_wr.num_sge);
-
+               if (((ch+1)->rc_discrim == 0) &&
+                   (read_wr.num_sge == ch_sge_ary[ch_no].count)) {
+                       /*
+                        * Mark the last RDMA_READ with a bit to
+                        * indicate all RPC data has been fetched from
+                        * the client and the RPC needs to be enqueued.
+                        */
+                       set_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags);
+                       ctxt->next = hdr_ctxt;
+                       hdr_ctxt->next = head;
+               }
                /* Post the read */
                err = svc_rdma_send(xprt, &read_wr);
                if (err) {
@@ -458,8 +457,6 @@ static int rdma_read_complete(struct svc_rqst *rqstp,
                ret, rqstp->rq_arg.len, rqstp->rq_arg.head[0].iov_base,
                rqstp->rq_arg.head[0].iov_len);
 
-       /* Indicate that we've consumed an RQ credit */
-       rqstp->rq_xprt_ctxt = rqstp->rq_xprt;
        svc_xprt_received(rqstp->rq_xprt);
        return ret;
 }
@@ -481,13 +478,6 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
 
        dprintk("svcrdma: rqstp=%p\n", rqstp);
 
-       /*
-        * The rq_xprt_ctxt indicates if we've consumed an RQ credit
-        * or not. It is used in the rdma xpo_release_rqst function to
-        * determine whether or not to return an RQ WQE to the RQ.
-        */
-       rqstp->rq_xprt_ctxt = NULL;
-
        spin_lock_bh(&rdma_xprt->sc_read_complete_lock);
        if (!list_empty(&rdma_xprt->sc_read_complete_q)) {
                ctxt = list_entry(rdma_xprt->sc_read_complete_q.next,
@@ -551,9 +541,6 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
                return 0;
        }
 
-       /* Indicate we've consumed an RQ credit */
-       rqstp->rq_xprt_ctxt = rqstp->rq_xprt;
-
        ret = rqstp->rq_arg.head[0].iov_len
                + rqstp->rq_arg.page_len
                + rqstp->rq_arg.tail[0].iov_len;
@@ -570,11 +557,8 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
        return ret;
 
  close_out:
-       if (ctxt) {
+       if (ctxt)
                svc_rdma_put_context(ctxt, 1);
-               /* Indicate we've consumed an RQ credit */
-               rqstp->rq_xprt_ctxt = rqstp->rq_xprt;
-       }
        dprintk("svcrdma: transport %p is closing\n", xprt);
        /*
         * Set the close bit and enqueue it. svc_recv will see the