9ae3f9
From 2c582ea6c76031463501b31d9250e739d5aeda79 Mon Sep 17 00:00:00 2001
9ae3f9
From: Ravishankar N <ravishankar@redhat.com>
9ae3f9
Date: Fri, 5 Jun 2020 14:28:11 +0530
9ae3f9
Subject: [PATCH 425/449] tests: Fix spurious self-heald.t failure
9ae3f9
9ae3f9
Problem:
9ae3f9
heal-info code assumes that all indices in xattrop directory
9ae3f9
definitely need heal. There is one corner case.
9ae3f9
The very first xattrop on the file will lead to adding the
9ae3f9
gfid to 'xattrop' index in fop path and in _cbk path it is
9ae3f9
removed because the fop is zero-xattr xattrop in success case.
9ae3f9
These gfids could be read by heal-info and shown as needing heal.
9ae3f9
9ae3f9
Fix:
9ae3f9
Check the pending flag to see if the file definitely needs or
9ae3f9
not instead of which index is being crawled at the moment.
9ae3f9
9ae3f9
> Upstream patch: https://review.gluster.org/#/c/glusterfs/+/24110/
9ae3f9
> fixes: bz#1801623
9ae3f9
> Change-Id: I79f00dc7366fedbbb25ec4bec838dba3b34c7ad5
9ae3f9
> Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
9ae3f9
9ae3f9
BUG: 1721355
9ae3f9
Change-Id: I7efdf45a5158fadfdbdd21c91837f193d80fa6c7
9ae3f9
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
9ae3f9
Reviewed-on: https://code.engineering.redhat.com/gerrit/202491
9ae3f9
Tested-by: RHGS Build Bot <nigelb@redhat.com>
9ae3f9
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
9ae3f9
---
9ae3f9
 heal/src/glfs-heal.c                 | 17 ++++++----------
9ae3f9
 xlators/cluster/afr/src/afr-common.c | 38 ++++++++++++++----------------------
9ae3f9
 2 files changed, 21 insertions(+), 34 deletions(-)
9ae3f9
9ae3f9
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
9ae3f9
index 5af9e31..125b12c 100644
9ae3f9
--- a/heal/src/glfs-heal.c
9ae3f9
+++ b/heal/src/glfs-heal.c
9ae3f9
@@ -775,8 +775,7 @@ static int
9ae3f9
 glfsh_process_entries(xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
9ae3f9
                       uint64_t *offset, num_entries_t *num_entries,
9ae3f9
                       print_status glfsh_print_status,
9ae3f9
-                      gf_boolean_t ignore_dirty, glfsh_fail_mode_t mode,
9ae3f9
-                      dict_t *xattr_req)
9ae3f9
+                      gf_boolean_t ignore_dirty, glfsh_fail_mode_t mode)
9ae3f9
 {
9ae3f9
     gf_dirent_t *entry = NULL;
9ae3f9
     gf_dirent_t *tmp = NULL;
9ae3f9
@@ -808,7 +807,7 @@ glfsh_process_entries(xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
9ae3f9
 
9ae3f9
         gf_uuid_parse(entry->d_name, gfid);
9ae3f9
         gf_uuid_copy(loc.gfid, gfid);
9ae3f9
-        ret = syncop_getxattr(this, &loc, &dict, GF_HEAL_INFO, xattr_req, NULL);
9ae3f9
+        ret = syncop_getxattr(this, &loc, &dict, GF_HEAL_INFO, NULL, NULL);
9ae3f9
         if (ret) {
9ae3f9
             if ((mode != GLFSH_MODE_CONTINUE_ON_ERROR) && (ret == -ENOTCONN))
9ae3f9
                 goto out;
9ae3f9
@@ -877,19 +876,19 @@ glfsh_crawl_directory(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
9ae3f9
         if (heal_op == GF_SHD_OP_INDEX_SUMMARY) {
9ae3f9
             ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
9ae3f9
                                         num_entries, glfsh_print_heal_status,
9ae3f9
-                                        ignore, mode, xattr_req);
9ae3f9
+                                        ignore, mode);
9ae3f9
             if (ret < 0)
9ae3f9
                 goto out;
9ae3f9
         } else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) {
9ae3f9
             ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
9ae3f9
                                         num_entries, glfsh_print_spb_status,
9ae3f9
-                                        ignore, mode, xattr_req);
9ae3f9
+                                        ignore, mode);
9ae3f9
             if (ret < 0)
9ae3f9
                 goto out;
9ae3f9
         } else if (heal_op == GF_SHD_OP_HEAL_SUMMARY) {
9ae3f9
             ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
9ae3f9
                                         num_entries, glfsh_print_summary_status,
9ae3f9
-                                        ignore, mode, xattr_req);
9ae3f9
+                                        ignore, mode);
9ae3f9
             if (ret < 0)
9ae3f9
                 goto out;
9ae3f9
         } else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) {
9ae3f9
@@ -898,7 +897,7 @@ glfsh_crawl_directory(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
9ae3f9
         } else if (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) {
9ae3f9
             ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
9ae3f9
                                         num_entries, glfsh_heal_status_boolean,
9ae3f9
-                                        ignore, mode, xattr_req);
9ae3f9
+                                        ignore, mode);
9ae3f9
             if (ret < 0)
9ae3f9
                 goto out;
9ae3f9
         }
9ae3f9
@@ -952,10 +951,6 @@ glfsh_print_pending_heals_type(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
9ae3f9
     int32_t op_errno = 0;
9ae3f9
     gf_boolean_t ignore = _gf_false;
9ae3f9
 
9ae3f9
-    ret = dict_set_str(xattr_req, "index-vgfid", vgfid);
9ae3f9
-    if (ret)
9ae3f9
-        return ret;
9ae3f9
-
9ae3f9
     if (!strcmp(vgfid, GF_XATTROP_DIRTY_GFID))
9ae3f9
         ignore = _gf_true;
9ae3f9
 
9ae3f9
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
9ae3f9
index c355ec5..89e2483 100644
9ae3f9
--- a/xlators/cluster/afr/src/afr-common.c
9ae3f9
+++ b/xlators/cluster/afr/src/afr-common.c
9ae3f9
@@ -5995,8 +5995,8 @@ afr_is_dirty_count_non_unary(xlator_t *this, struct afr_reply *replies,
9ae3f9
 
9ae3f9
 static int
9ae3f9
 afr_update_heal_status(xlator_t *this, struct afr_reply *replies,
9ae3f9
-                       char *index_vgfid, ia_type_t ia_type, gf_boolean_t *esh,
9ae3f9
-                       gf_boolean_t *dsh, gf_boolean_t *msh)
9ae3f9
+                       ia_type_t ia_type, gf_boolean_t *esh, gf_boolean_t *dsh,
9ae3f9
+                       gf_boolean_t *msh, unsigned char pending)
9ae3f9
 {
9ae3f9
     int ret = -1;
9ae3f9
     GF_UNUSED int ret1 = 0;
9ae3f9
@@ -6026,14 +6026,7 @@ afr_update_heal_status(xlator_t *this, struct afr_reply *replies,
9ae3f9
         }
9ae3f9
     }
9ae3f9
 
9ae3f9
-    if (!strcmp(index_vgfid, GF_XATTROP_INDEX_GFID)) {
9ae3f9
-        if (shd_domain_lk_count) {
9ae3f9
-            ret = -EAGAIN; /*For 'possibly-healing'. */
9ae3f9
-        } else {
9ae3f9
-            ret = 0; /*needs heal. Just set a non -ve value so that it is
9ae3f9
-                       assumed as the source index.*/
9ae3f9
-        }
9ae3f9
-    } else if (!strcmp(index_vgfid, GF_XATTROP_DIRTY_GFID)) {
9ae3f9
+    if (!pending) {
9ae3f9
         if ((afr_is_dirty_count_non_unary(this, replies, ia_type)) ||
9ae3f9
             (!io_domain_lk_count)) {
9ae3f9
             /* Needs heal. */
9ae3f9
@@ -6042,6 +6035,13 @@ afr_update_heal_status(xlator_t *this, struct afr_reply *replies,
9ae3f9
             /* No heal needed. */
9ae3f9
             *dsh = *esh = *msh = 0;
9ae3f9
         }
9ae3f9
+    } else {
9ae3f9
+        if (shd_domain_lk_count) {
9ae3f9
+            ret = -EAGAIN; /*For 'possibly-healing'. */
9ae3f9
+        } else {
9ae3f9
+            ret = 0; /*needs heal. Just set a non -ve value so that it is
9ae3f9
+                       assumed as the source index.*/
9ae3f9
+        }
9ae3f9
     }
9ae3f9
     return ret;
9ae3f9
 }
9ae3f9
@@ -6049,8 +6049,8 @@ afr_update_heal_status(xlator_t *this, struct afr_reply *replies,
9ae3f9
 /*return EIO, EAGAIN or pending*/
9ae3f9
 int
9ae3f9
 afr_lockless_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
9ae3f9
-                     inode_t **inode, char *index_vgfid,
9ae3f9
-                     gf_boolean_t *entry_selfheal, gf_boolean_t *data_selfheal,
9ae3f9
+                     inode_t **inode, gf_boolean_t *entry_selfheal,
9ae3f9
+                     gf_boolean_t *data_selfheal,
9ae3f9
                      gf_boolean_t *metadata_selfheal, unsigned char *pending)
9ae3f9
 {
9ae3f9
     int ret = -1;
9ae3f9
@@ -6109,8 +6109,8 @@ afr_lockless_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
9ae3f9
             goto out;
9ae3f9
     }
9ae3f9
 
9ae3f9
-    ret = afr_update_heal_status(this, replies, index_vgfid, (*inode)->ia_type,
9ae3f9
-                                 &esh, &dsh, &msh;;
9ae3f9
+    ret = afr_update_heal_status(this, replies, (*inode)->ia_type, &esh, &dsh,
9ae3f9
+                                 &msh, *pending);
9ae3f9
 out:
9ae3f9
     *data_selfheal = dsh;
9ae3f9
     *entry_selfheal = esh;
9ae3f9
@@ -6133,16 +6133,8 @@ afr_get_heal_info(call_frame_t *frame, xlator_t *this, loc_t *loc)
9ae3f9
     inode_t *inode = NULL;
9ae3f9
     char *substr = NULL;
9ae3f9
     char *status = NULL;
9ae3f9
-    afr_local_t *local = NULL;
9ae3f9
-    char *index_vgfid = NULL;
9ae3f9
-
9ae3f9
-    local = frame->local;
9ae3f9
-    if (dict_get_str(local->xdata_req, "index-vgfid", &index_vgfid)) {
9ae3f9
-        ret = -1;
9ae3f9
-        goto out;
9ae3f9
-    }
9ae3f9
 
9ae3f9
-    ret = afr_lockless_inspect(frame, this, loc->gfid, &inode, index_vgfid,
9ae3f9
+    ret = afr_lockless_inspect(frame, this, loc->gfid, &inode,
9ae3f9
                                &entry_selfheal, &data_selfheal,
9ae3f9
                                &metadata_selfheal, &pending);
9ae3f9
 
9ae3f9
-- 
9ae3f9
1.8.3.1
9ae3f9