d1681e
From ea71f09cd6ea45a2d1525519843fc553f0e46bec Mon Sep 17 00:00:00 2001
d1681e
From: Zhang Huan <zhanghuan@open-fs.com>
d1681e
Date: Tue, 5 Sep 2017 11:36:25 +0800
d1681e
Subject: [PATCH 104/128] cluster/dht: fix crash when deleting directories
d1681e
d1681e
In DHT, after locks on all subvolumes are acquired, it would perform the
d1681e
following steps sequentially,
d1681e
1. send remove dir on all other subvolumes except the hashed one in a loop;
d1681e
2. wait for all pending rmdir to be done
d1681e
3. remove dir on the hashed subvolume
d1681e
d1681e
The problem is that in step 1 there is a check to skip hashed subvolume
d1681e
in the loop. If the last subvolume to check is actually the
d1681e
hashed one, and step 3 is quickly done before the last and hashed
d1681e
subvolume is checked, by accessing shared context data be destroyed in
d1681e
step 3, would cause a crash.
d1681e
d1681e
Fix by saving shared data in a local variable to access later in the
d1681e
loop.
d1681e
d1681e
> BUG: 1490642
d1681e
> Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
d1681e
(cherry picked from commit 206120126d455417a81a48ae473d49be337e9463)
d1681e
Change-Id: I8db7cf7cb262d74efcb58eb00f02ea37df4be4e2
d1681e
BUG: 1519076
d1681e
Signed-off-by: N Balachandran <nbalacha@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/124755
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
d1681e
---
d1681e
 xlators/cluster/dht/src/dht-common.c | 6 ++++--
d1681e
 1 file changed, 4 insertions(+), 2 deletions(-)
d1681e
d1681e
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
d1681e
index c6944b2..f611278 100644
d1681e
--- a/xlators/cluster/dht/src/dht-common.c
d1681e
+++ b/xlators/cluster/dht/src/dht-common.c
d1681e
@@ -8094,6 +8094,7 @@ dht_rmdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
d1681e
         dht_local_t  *local = NULL;
d1681e
         dht_conf_t   *conf  = NULL;
d1681e
         int           i     = 0;
d1681e
+        xlator_t     *hashed_subvol;
d1681e
 
d1681e
         VALIDATE_OR_GOTO (this->private, err);
d1681e
 
d1681e
@@ -8111,9 +8112,10 @@ dht_rmdir_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
d1681e
                 goto err;
d1681e
         }
d1681e
 
d1681e
+        hashed_subvol = local->hashed_subvol;
d1681e
         for (i = 0; i < conf->subvolume_cnt; i++) {
d1681e
-                if (local->hashed_subvol &&
d1681e
-                    (local->hashed_subvol == conf->subvolumes[i]))
d1681e
+                if (hashed_subvol &&
d1681e
+                    (hashed_subvol == conf->subvolumes[i]))
d1681e
                         continue;
d1681e
 
d1681e
                 STACK_WIND_COOKIE (frame, dht_rmdir_cbk, conf->subvolumes[i],
d1681e
-- 
d1681e
1.8.3.1
d1681e