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