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