Patchwork [BUG:1877] rpc-transport/rdma: increment post->ctx.count in a loop doint rdma_read.

login
register
Submitter Raghavendra G
Date 2010-11-01 06:55:03
Message ID <20101101065502.GA25073@dev.gluster.com>
Download mbox | patch
Permalink /patch/5609/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Raghavendra G - 2010-11-01 06:55:03
- incrementing by the number of read chunks even before doing rdma read will
    cause issues since post->ctx.count is used while posting rdma read.

Signed-off-by: Raghavendra G <raghavendra@gluster.com>
---
 rpc/rpc-transport/rdma/src/rdma.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Patch

diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c
index 63b1c2c..4301f41 100644
--- a/rpc/rpc-transport/rdma/src/rdma.c
+++ b/rpc/rpc-transport/rdma/src/rdma.c
@@ -2911,7 +2911,7 @@  out:
 int32_t
 rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
 {
-        int32_t         ret    = -1, i = 0;
+        int32_t         ret    = -1, i = 0, count = 0;
         size_t          size   = 0;
         char           *ptr    = NULL;  
         struct iobuf   *iobuf  = NULL;
@@ -2931,7 +2931,6 @@  rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
         }
 
         post->ctx.rdma_reads = i;
-        post->ctx.count += post->ctx.rdma_reads;
 
         if (size > peer->trans->ctx->page_size) {
                 gf_log (RDMA_LOG_NAME, GF_LOG_ERROR,
@@ -2970,12 +2969,13 @@  rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
                 }
 
                 for (i = 0; readch[i].rc_discrim != 0; i++) {
-                        post->ctx.vector[post->ctx.count].iov_base = ptr;
-                        post->ctx.vector[post->ctx.count].iov_len
+                        count = post->ctx.count++;
+                        post->ctx.vector[count].iov_base = ptr;
+                        post->ctx.vector[count].iov_len
                                 = readch[i].rc_target.rs_length;
 
                         ret = __rdma_read (peer, post,
-                                           &post->ctx.vector[post->ctx.count],
+                                           &post->ctx.vector[count],
                                            &readch[i]);
                         if (ret == -1) {
                                 goto unlock;