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