12a457
From 029b4109de7090f9269a22327203aa1724e15bd4 Mon Sep 17 00:00:00 2001
12a457
From: Sakshi Bansal <sabansal@redhat.com>
12a457
Date: Sat, 19 Mar 2016 10:15:24 +0530
12a457
Subject: [PATCH 32/80] dht: update attr information in refresh layout to avoid
12a457
      stale timestamp
12a457
12a457
Consider the scenario where an mkdir has just created the
12a457
directory but has not healed it yet. A parallel lookup on
12a457
this entry will find anomalies and trigger a selfheal which
12a457
will sample the ctime of the directory after the mkdir phase.
12a457
Meanwhile the mkdir has completed setting the layout and
12a457
updated the ctime. The selfheal then sees the layout to be
12a457
healed and returns with the ctime it got after the mkdir phase
12a457
which has now become stale. However if the lookup happens
12a457
to unwind before the mkdir then the inode associated with
12a457
lookup will get linked in the inode table which has the
12a457
stale ctime. To avoid this selfheal must do an iatt_merge in
12a457
refresh layout to get the latest timestamp irrespective of
12a457
whether it needs to heal the layout or not.
12a457
12a457
Change-Id: I3634c3978bcc1710705f44b48f3876601682d33e
12a457
BUG: 1298724
12a457
Signed-off-by: Sakshi Bansal <sabansal@redhat.com>
12a457
Reviewed-on: http://review.gluster.org/13781
12a457
Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
12a457
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/70836
12a457
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
12a457
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
12a457
---
12a457
 xlators/cluster/dht/src/dht-selfheal.c |    9 ++++++++-
12a457
 1 files changed, 8 insertions(+), 1 deletions(-)
12a457
12a457
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
12a457
index 73e3782..fd55303 100644
12a457
--- a/xlators/cluster/dht/src/dht-selfheal.c
12a457
+++ b/xlators/cluster/dht/src/dht-selfheal.c
12a457
@@ -196,6 +196,8 @@ dht_refresh_layout_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
12a457
                 op_ret = dht_layout_merge (this, layout, prev->this,
12a457
                                            op_ret, op_errno, xattr);
12a457
 
12a457
+                dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
12a457
+
12a457
                 if (op_ret == -1) {
12a457
                         local->op_errno = op_errno;
12a457
                         gf_msg_debug (this->name, op_errno,
12a457
@@ -642,7 +644,12 @@ dht_selfheal_dir_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
12a457
                 }
12a457
         }
12a457
 
12a457
-        dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
12a457
+        LOCK (&frame->lock);
12a457
+        {
12a457
+                dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
12a457
+        }
12a457
+        UNLOCK (&frame->lock);
12a457
+
12a457
         this_call_cnt = dht_frame_return (frame);
12a457
 
12a457
         if (is_last_call (this_call_cnt)) {
12a457
-- 
12a457
1.7.1
12a457