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