Blob Blame History Raw
From dd36876008bd144a18fa43bde58ba09dd9c9506d Mon Sep 17 00:00:00 2001
From: Pranith Kumar K <pkarampu@redhat.com>
Date: Tue, 16 Jun 2015 22:59:17 +0530
Subject: [PATCH 085/101] cluster/ec: Prevent races in ec_unlock for rename

       Backport of http://review.gluster.org/11261

If fop->lock_count > 1 then there is a chance that by the time
ec_unlock_timer_add() is called for the second lock epoll thread could
reply inodelk and jobs will be '0' leading to completion of state
machine and freeing of fop. So add sleep/resume.

ec_lookup_rebuild already removes EC_XATTR_SIZE from xdata. So assign
link->size from buf->ia_size.

BUG: 1231166
Change-Id: Iea7ef6ad6fcd151deffaf2b7b1653eba35d777ab
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50992
---
 xlators/cluster/ec/src/ec-common.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index a158637..be69c57 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -1118,10 +1118,7 @@ int32_t ec_get_real_size_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
 
     if (op_ret >= 0) {
         link = fop->data;
-        if (ec_dict_del_number(xdata, EC_XATTR_SIZE, &link->size) != 0) {
-            gf_log(this->name, GF_LOG_WARNING,
-                   "Unable to determine real file size");
-        }
+        link->size = buf->ia_size;
     } else {
         /* Prevent failure of parent fop. */
         fop->error = 0;
@@ -1728,9 +1725,15 @@ void ec_unlock(ec_fop_data_t *fop)
 {
     int32_t i;
 
+    /*If fop->lock_count > 1 then there is a chance that by the time
+     * ec_unlock_timer_add() is called for the second lock epoll thread could
+     * reply inodelk and jobs will be '0' leading to completion of state
+     * machine and freeing of fop. So add sleep/resume*/
+    ec_sleep (fop);
     for (i = 0; i < fop->lock_count; i++) {
         ec_unlock_timer_add(&fop->locks[i]);
     }
+    ec_resume (fop, 0);
 }
 
 void
-- 
1.7.1