e7a346
From 9ac423d71b9d9d8875ce2af29e2bcf5770b61d5a Mon Sep 17 00:00:00 2001
e7a346
From: Raghavendra G <rgowdapp@redhat.com>
e7a346
Date: Fri, 16 Mar 2018 12:16:43 +0530
e7a346
Subject: [PATCH 258/260] cluster/dht: log error only if layout healing is
e7a346
 required
e7a346
e7a346
selfhealing of directory is invoked on two conditions:
e7a346
1. no layout on disk or layout has some anomalies (holes/overlaps)
e7a346
2. mds xattr is not set on the directory
e7a346
e7a346
When dht_selfheal_directory is called with a correct layout just to
e7a346
set mds xattr, we see error msgs complaining about "not able to form
e7a346
layout on directory", which is misleading as the layout is
e7a346
correct. So, log this msg only if layout has anomalies.
e7a346
e7a346
>Change-Id: I4af25246fc3a2450c2426e9902d1a5b372eab125
e7a346
>updates: bz#1543279
e7a346
>BUG: 1543279
e7a346
>Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
e7a346
e7a346
upstream patch: https://review.gluster.org/19727
e7a346
BUG: 1567100
e7a346
Change-Id: I169823ec3d4455c43f575e6c4ec0735aceb54e6b
e7a346
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/138149
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 xlators/cluster/dht/src/dht-common.h   |   1 +
e7a346
 xlators/cluster/dht/src/dht-selfheal.c | 199 ++-------------------------------
e7a346
 2 files changed, 12 insertions(+), 188 deletions(-)
e7a346
e7a346
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
e7a346
index a785876..9d429af 100644
e7a346
--- a/xlators/cluster/dht/src/dht-common.h
e7a346
+++ b/xlators/cluster/dht/src/dht-common.h
e7a346
@@ -312,6 +312,7 @@ struct dht_local {
e7a346
                 uint32_t                overlaps_cnt;
e7a346
                 uint32_t                down;
e7a346
                 uint32_t                misc;
e7a346
+                uint32_t                missing_cnt;
e7a346
                 dht_selfheal_dir_cbk_t  dir_cbk;
e7a346
                 dht_selfheal_layout_t   healer;
e7a346
                 dht_need_heal_t         should_heal;
e7a346
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
e7a346
index 53c59a2..5812f12 100644
e7a346
--- a/xlators/cluster/dht/src/dht-selfheal.c
e7a346
+++ b/xlators/cluster/dht/src/dht-selfheal.c
e7a346
@@ -359,7 +359,8 @@ dht_should_heal_layout (call_frame_t *frame, dht_layout_t **heal,
e7a346
         ret = dht_layout_anomalies (frame->this, &local->loc, *ondisk,
e7a346
                                     &local->selfheal.hole_cnt,
e7a346
                                     &local->selfheal.overlaps_cnt,
e7a346
-                                    NULL, &local->selfheal.down,
e7a346
+                                    &local->selfheal.missing_cnt,
e7a346
+                                    &local->selfheal.down,
e7a346
                                     &local->selfheal.misc, NULL);
e7a346
 
e7a346
         if (ret < 0)
e7a346
@@ -1015,115 +1016,6 @@ dht_layout_index_from_conf (dht_layout_t *layout, xlator_t *xlator)
e7a346
         return i;
e7a346
 }
e7a346
 
e7a346
-
e7a346
-static int
e7a346
-dht_selfheal_dir_xattr_for_nameless_lookup (call_frame_t *frame, loc_t *loc,
e7a346
-                                            dht_layout_t  *layout)
e7a346
-{
e7a346
-        dht_local_t     *local = NULL;
e7a346
-        int             missing_xattr = 0;
e7a346
-        int             i = 0;
e7a346
-        xlator_t        *this = NULL;
e7a346
-        dht_conf_t      *conf = NULL;
e7a346
-        dht_layout_t    *dummy = NULL;
e7a346
-        int             j = 0;
e7a346
-
e7a346
-        local = frame->local;
e7a346
-        this = frame->this;
e7a346
-        conf = this->private;
e7a346
-
e7a346
-        for (i = 0; i < layout->cnt; i++) {
e7a346
-                if (layout->list[i].err != -1 || !layout->list[i].stop) {
e7a346
-                        /* err != -1 would mean xattr present on the directory
e7a346
-                           or the directory is non existent.
e7a346
-                           !layout->list[i].stop would mean layout absent
e7a346
-                        */
e7a346
-
e7a346
-                        continue;
e7a346
-                }
e7a346
-                missing_xattr++;
e7a346
-        }
e7a346
-
e7a346
-        /* Also account for subvolumes with no-layout. Used for zero'ing out
e7a346
-           the layouts and for setting quota key's if present */
e7a346
-
e7a346
-        /* Send  where either the subvol is not part of layout,
e7a346
-         * or it is part of the layout but error is non-zero but error
e7a346
-         * is not equal to -1 or ENOENT.
e7a346
-         */
e7a346
-
e7a346
-        for (i = 0; i < conf->subvolume_cnt; i++) {
e7a346
-                if (dht_is_subvol_part_of_layout (layout, conf->subvolumes[i])
e7a346
-                    == _gf_false) {
e7a346
-                        missing_xattr++;
e7a346
-                        continue;
e7a346
-                }
e7a346
-
e7a346
-                j = dht_layout_index_from_conf (layout, conf->subvolumes[i]);
e7a346
-
e7a346
-                if ((j != -1) && (layout->list[j].err != -1) &&
e7a346
-                   (layout->list[j].err != 0) &&
e7a346
-                   (layout->list[j].err != ENOENT)) {
e7a346
-                        missing_xattr++;
e7a346
-                }
e7a346
-
e7a346
-        }
e7a346
-
e7a346
-
e7a346
-        gf_msg_trace (this->name, 0,
e7a346
-                      "%d subvolumes missing xattr for %s",
e7a346
-                      missing_xattr, loc->path);
e7a346
-
e7a346
-        if (missing_xattr == 0) {
e7a346
-                dht_selfheal_dir_finish (frame, this, 0, 1);
e7a346
-                return 0;
e7a346
-        }
e7a346
-
e7a346
-        local->call_cnt = missing_xattr;
e7a346
-
e7a346
-        if (gf_log_get_loglevel () >= GF_LOG_DEBUG)
e7a346
-                dht_log_new_layout_for_dir_selfheal (this, loc, layout);
e7a346
-
e7a346
-        for (i = 0; i < layout->cnt; i++) {
e7a346
-                if (layout->list[i].err != -1 || !layout->list[i].stop)
e7a346
-                        continue;
e7a346
-
e7a346
-                dht_selfheal_dir_xattr_persubvol (frame, loc, layout, i, NULL);
e7a346
-
e7a346
-                if (--missing_xattr == 0)
e7a346
-                        break;
e7a346
-        }
e7a346
-
e7a346
-        dummy = dht_layout_new (this, 1);
e7a346
-        if (!dummy)
e7a346
-                goto out;
e7a346
-
e7a346
-        for (i = 0; i < conf->subvolume_cnt && missing_xattr; i++) {
e7a346
-              if (dht_is_subvol_part_of_layout (layout, conf->subvolumes[i])
e7a346
-                  == _gf_false) {
e7a346
-                        dht_selfheal_dir_xattr_persubvol (frame, loc, dummy, 0,
e7a346
-                                                          conf->subvolumes[i]);
e7a346
-                        missing_xattr--;
e7a346
-                        continue;
e7a346
-              }
e7a346
-
e7a346
-                j = dht_layout_index_from_conf (layout, conf->subvolumes[i]);
e7a346
-
e7a346
-                if ((j != -1) && (layout->list[j].err != -1) &&
e7a346
-                    (layout->list[j].err != ENOENT) &&
e7a346
-                    (layout->list[j].err != 0)) {
e7a346
-                        dht_selfheal_dir_xattr_persubvol (frame, loc, dummy, 0,
e7a346
-                                                          conf->subvolumes[i]);
e7a346
-                        missing_xattr--;
e7a346
-                }
e7a346
-        }
e7a346
-
e7a346
-        dht_layout_unref (this, dummy);
e7a346
-out:
e7a346
-        return 0;
e7a346
-
e7a346
-}
e7a346
-
e7a346
 int
e7a346
 dht_selfheal_dir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
e7a346
                               int op_ret, int op_errno, struct iatt *statpre,
e7a346
@@ -2296,7 +2188,8 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,
e7a346
         dht_layout_anomalies (this, loc, layout,
e7a346
                               &local->selfheal.hole_cnt,
e7a346
                               &local->selfheal.overlaps_cnt,
e7a346
-                              NULL, &local->selfheal.down,
e7a346
+                              &local->selfheal.missing_cnt,
e7a346
+                              &local->selfheal.down,
e7a346
                               &local->selfheal.misc, NULL);
e7a346
 
e7a346
         down     = local->selfheal.down;
e7a346
@@ -2325,14 +2218,14 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,
e7a346
 
e7a346
         dht_layout_sort_volname (layout);
e7a346
         local->heal_layout = _gf_true;
e7a346
-        ret = dht_selfheal_dir_getafix (frame, loc, layout);
e7a346
 
e7a346
-        if (ret == -1) {
e7a346
-                gf_msg (this->name, GF_LOG_INFO, 0,
e7a346
-                        DHT_MSG_DIR_SELFHEAL_FAILED,
e7a346
-                        "Directory selfheal failed: "
e7a346
-                        "Unable to form layout for directory %s",
e7a346
-                        loc->path);
e7a346
+        /* Ignore return value as it can be inferred from result of
e7a346
+         * dht_layout_anomalies
e7a346
+         */
e7a346
+        dht_selfheal_dir_getafix (frame, loc, layout);
e7a346
+
e7a346
+        if (!(local->selfheal.hole_cnt || local->selfheal.overlaps_cnt ||
e7a346
+              local->selfheal.missing_cnt)) {
e7a346
                 local->heal_layout = _gf_false;
e7a346
         }
e7a346
 
e7a346
@@ -2352,76 +2245,6 @@ sorry_no_fix:
e7a346
 }
e7a346
 
e7a346
 int
e7a346
-dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame,
e7a346
-                                            dht_selfheal_dir_cbk_t dir_cbk,
e7a346
-                                            loc_t *loc, dht_layout_t *layout)
e7a346
-{
e7a346
-        dht_local_t     *local  = NULL;
e7a346
-        uint32_t        down    = 0;
e7a346
-        uint32_t        misc    = 0;
e7a346
-        int             ret     = 0;
e7a346
-        xlator_t        *this   = NULL;
e7a346
-
e7a346
-        local = frame->local;
e7a346
-        this = frame->this;
e7a346
-        dht_layout_anomalies (this, loc, layout,
e7a346
-                              &local->selfheal.hole_cnt,
e7a346
-                              &local->selfheal.overlaps_cnt,
e7a346
-                              NULL, &local->selfheal.down,
e7a346
-                              &local->selfheal.misc, NULL);
e7a346
-
e7a346
-        down     = local->selfheal.down;
e7a346
-        misc     = local->selfheal.misc;
e7a346
-
e7a346
-        local->selfheal.dir_cbk = dir_cbk;
e7a346
-        local->selfheal.layout = dht_layout_ref (this, layout);
e7a346
-
e7a346
-        if (down) {
e7a346
-                gf_msg (this->name, GF_LOG_WARNING, 0,
e7a346
-                        DHT_MSG_SUBVOL_DOWN_ERROR,
e7a346
-                        "%d subvolumes down -- not fixing", down);
e7a346
-                ret = 0;
e7a346
-                goto sorry_no_fix;
e7a346
-        }
e7a346
-
e7a346
-        if (misc) {
e7a346
-                gf_msg (this->name, GF_LOG_WARNING, 0,
e7a346
-                        DHT_MSG_SUBVOL_ERROR,
e7a346
-                        "%d subvolumes have unrecoverable errors", misc);
e7a346
-                ret = 0;
e7a346
-                goto sorry_no_fix;
e7a346
-        }
e7a346
-
e7a346
-        dht_layout_sort_volname (layout);
e7a346
-        ret = dht_selfheal_dir_getafix (frame, loc, layout);
e7a346
-
e7a346
-        if (ret == -1) {
e7a346
-                gf_msg (this->name, GF_LOG_WARNING, 0,
e7a346
-                        DHT_MSG_LAYOUT_FORM_FAILED,
e7a346
-                        "not able to form layout for the directory");
e7a346
-                goto sorry_no_fix;
e7a346
-        }
e7a346
-
e7a346
-        ret = dht_selfheal_layout_lock (frame, layout, _gf_false,
e7a346
-                                     dht_selfheal_dir_xattr_for_nameless_lookup,
e7a346
-                                        dht_should_heal_layout);
e7a346
-
e7a346
-        if (ret < 0) {
e7a346
-                goto sorry_no_fix;
e7a346
-        }
e7a346
-
e7a346
-        return 0;
e7a346
-
e7a346
-sorry_no_fix:
e7a346
-        /* TODO: need to put appropriate local->op_errno */
e7a346
-        dht_selfheal_dir_finish (frame, this, ret, 1);
e7a346
-
e7a346
-        return 0;
e7a346
-
e7a346
-
e7a346
-}
e7a346
-
e7a346
-int
e7a346
 dht_selfheal_restore (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,
e7a346
                       loc_t *loc, dht_layout_t *layout)
e7a346
 {
e7a346
-- 
e7a346
1.8.3.1
e7a346