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