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