Patchwork [BUG:1877] rpc-transport: fix race-condition between rdma-read completion and updating the count of number of vectors to be passed to rpc.

login
register
Submitter Raghavendra G
Date 2010-10-29 08:43:22
Message ID <20101029084321.GA3807@dev.gluster.com>
Download mbox | patch
Permalink /patch/5600/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Raghavendra G - 2010-10-29 08:43:22
- If rdma read completes before incrementing the vector count, the count
    value sent to rpc will be improper. For fops like write, this may result
    in missing out a vector to be written, thereby causing data corruption.

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

Patch

diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c
index 9035364..c2adc9f 100644
--- a/rpc/rpc-transport/rdma/src/rdma.c
+++ b/rpc/rpc-transport/rdma/src/rdma.c
@@ -2937,6 +2937,7 @@  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,
@@ -2986,7 +2987,6 @@  rdma_do_reads (rdma_peer_t *peer, rdma_post_t *post, rdma_read_chunk_t *readch)
                                 goto unlock;
                         }
 
-                        post->ctx.count++;
                         ptr += readch[i].rc_target.rs_length;
                 }