|
|
887953 |
From f928dfab3d2e94211d9865ce994ae3a503f2b9a0 Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
Date: Mon, 11 Mar 2019 08:06:15 +0530
|
|
|
887953 |
Subject: [PATCH 536/538] cluster/dht: Fix lookup selfheal and rmdir race
|
|
|
887953 |
|
|
|
887953 |
A race between the lookup selfheal and rmdir can cause
|
|
|
887953 |
directories to be healed only on non-hashed subvols.
|
|
|
887953 |
This can prevent the directory from being listed from
|
|
|
887953 |
the mount point and in turn causes rm -rf to fail with
|
|
|
887953 |
ENOTEMPTY.
|
|
|
887953 |
Fix: Update the layout information correctly and reduce
|
|
|
887953 |
the call count only after processing the response.
|
|
|
887953 |
|
|
|
887953 |
upstream : https://review.gluster.org/#/c/glusterfs/+/22195/
|
|
|
887953 |
|
|
|
887953 |
> Change-Id: I812779aaf3d7bcf24aab1cb158cb6ed50d212451
|
|
|
887953 |
> fixes: bz#1676400
|
|
|
887953 |
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
|
|
|
887953 |
Change-Id: Ic76248ca7dca05d926f48ba84cd5bfa2943fab92
|
|
|
887953 |
BUG: 1458215
|
|
|
887953 |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/164931
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
xlators/cluster/dht/src/dht-selfheal.c | 36 ++++++++++++++++++++++++----------
|
|
|
887953 |
1 file changed, 26 insertions(+), 10 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
887953 |
index 035a709..045689b 100644
|
|
|
887953 |
--- a/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
887953 |
+++ b/xlators/cluster/dht/src/dht-selfheal.c
|
|
|
887953 |
@@ -1366,6 +1366,7 @@ dht_selfheal_dir_mkdir_lookup_cbk (call_frame_t *frame, void *cookie,
|
|
|
887953 |
int errst = 0;
|
|
|
887953 |
int32_t mds_xattr_val[1] = {0};
|
|
|
887953 |
char gfid_local[GF_UUID_BUF_SIZE] = {0};
|
|
|
887953 |
+ int index = -1;
|
|
|
887953 |
|
|
|
887953 |
VALIDATE_OR_GOTO (this->private, err);
|
|
|
887953 |
|
|
|
887953 |
@@ -1375,32 +1376,47 @@ dht_selfheal_dir_mkdir_lookup_cbk (call_frame_t *frame, void *cookie,
|
|
|
887953 |
prev = cookie;
|
|
|
887953 |
conf = this->private;
|
|
|
887953 |
|
|
|
887953 |
- if (local->gfid)
|
|
|
887953 |
+ if (!gf_uuid_is_null(local->gfid))
|
|
|
887953 |
gf_uuid_unparse(local->gfid, gfid_local);
|
|
|
887953 |
|
|
|
887953 |
- this_call_cnt = dht_frame_return (frame);
|
|
|
887953 |
-
|
|
|
887953 |
LOCK (&frame->lock);
|
|
|
887953 |
{
|
|
|
887953 |
+ index = dht_layout_index_for_subvol(layout, prev);
|
|
|
887953 |
if ((op_ret < 0) &&
|
|
|
887953 |
(op_errno == ENOENT || op_errno == ESTALE)) {
|
|
|
887953 |
local->selfheal.hole_cnt = !local->selfheal.hole_cnt ? 1
|
|
|
887953 |
: local->selfheal.hole_cnt + 1;
|
|
|
887953 |
+ /* the status might have changed. Update the layout
|
|
|
887953 |
+ * with the new status
|
|
|
887953 |
+ */
|
|
|
887953 |
+ if (index >= 0) {
|
|
|
887953 |
+ layout->list[index].err = op_errno;
|
|
|
887953 |
+ }
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
if (!op_ret) {
|
|
|
887953 |
dht_iatt_merge (this, &local->stbuf, stbuf, prev);
|
|
|
887953 |
+ check_mds = dht_dict_get_array (xattr,
|
|
|
887953 |
+ conf->mds_xattr_key,
|
|
|
887953 |
+ mds_xattr_val, 1,
|
|
|
887953 |
+ &errst);
|
|
|
887953 |
+ if (dict_get (xattr, conf->mds_xattr_key) &&
|
|
|
887953 |
+ check_mds && !errst) {
|
|
|
887953 |
+ dict_unref (local->xattr);
|
|
|
887953 |
+ local->xattr = dict_ref (xattr);
|
|
|
887953 |
+ }
|
|
|
887953 |
+ /* the status might have changed. Update the layout
|
|
|
887953 |
+ * with the new status
|
|
|
887953 |
+ */
|
|
|
887953 |
+ if (index >= 0) {
|
|
|
887953 |
+ layout->list[index].err = -1;
|
|
|
887953 |
+ }
|
|
|
887953 |
}
|
|
|
887953 |
- check_mds = dht_dict_get_array (xattr, conf->mds_xattr_key,
|
|
|
887953 |
- mds_xattr_val, 1, &errst);
|
|
|
887953 |
- if (dict_get (xattr, conf->mds_xattr_key) && check_mds && !errst) {
|
|
|
887953 |
- dict_unref (local->xattr);
|
|
|
887953 |
- local->xattr = dict_ref (xattr);
|
|
|
887953 |
- }
|
|
|
887953 |
-
|
|
|
887953 |
}
|
|
|
887953 |
UNLOCK (&frame->lock);
|
|
|
887953 |
|
|
|
887953 |
+ this_call_cnt = dht_frame_return (frame);
|
|
|
887953 |
+
|
|
|
887953 |
if (is_last_call (this_call_cnt)) {
|
|
|
887953 |
if (local->selfheal.hole_cnt == layout->cnt) {
|
|
|
887953 |
gf_msg_debug (this->name, op_errno,
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|