a3470f
From dbf993f9c56c7ee995e9054b09c5552f88253bb3 Mon Sep 17 00:00:00 2001
a3470f
From: Ashish Pandey <aspandey@redhat.com>
a3470f
Date: Mon, 31 Jul 2017 12:45:21 +0530
a3470f
Subject: [PATCH 100/128] cluster/ec: Improve heal info command to handle
a3470f
 obvious cases
a3470f
a3470f
Problem:
a3470f
1 - If a brick is down and we see an index entry in
a3470f
.glusterfs/indices, we should show it in heal info
a3470f
output as it most certainly needs heal.
a3470f
a3470f
2 - The first problem is also not getting handled after
a3470f
ec_heal_inspect. Even if in ec_heal_inspect, lookup will
a3470f
mark need_heal as true, we don't handle it properly in
a3470f
ec_get_heal_info and continue with locked inspect which
a3470f
takes lot of time.
a3470f
a3470f
Solution:
a3470f
1 - In first case we need not to do any further invstigation.
a3470f
As soon as we see that a brick is down, we should say that
a3470f
this index entry needs heal for sure.
a3470f
a3470f
2 - In second case, if we have need_heal as _gf_true after
a3470f
ec_heal_inspect, we should show it as heal requires.
a3470f
a3470f
>Change-Id: Ibe7f9d7602cc0b382ba53bddaf75a2a2c3326aa6
a3470f
>BUG: 1476668
a3470f
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>
a3470f
Upstream Patch: https://review.gluster.org/#/c/17923/
a3470f
a3470f
BUG: 1509833
a3470f
Change-Id: Ibe7f9d7602cc0b382ba53bddaf75a2a2c3326aa6
a3470f
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/125194
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
---
a3470f
 xlators/cluster/ec/src/ec-common.h |  2 +-
a3470f
 xlators/cluster/ec/src/ec-heal.c   | 54 ++++++++++++++++++++++----------------
a3470f
 xlators/cluster/ec/src/ec-types.h  |  9 +++++++
a3470f
 3 files changed, 41 insertions(+), 24 deletions(-)
a3470f
a3470f
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
a3470f
index 0f7a252..dec81ca 100644
a3470f
--- a/xlators/cluster/ec/src/ec-common.h
a3470f
+++ b/xlators/cluster/ec/src/ec-common.h
a3470f
@@ -132,7 +132,7 @@ int32_t
a3470f
 ec_heal_inspect (call_frame_t *frame, ec_t *ec,
a3470f
                  inode_t *inode, unsigned char *locked_on,
a3470f
                  gf_boolean_t self_locked, gf_boolean_t thorough,
a3470f
-                 gf_boolean_t *need_heal);
a3470f
+                 ec_heal_need_t *need_heal);
a3470f
 int32_t
a3470f
 ec_get_heal_info (xlator_t *this, loc_t *loc, dict_t **dict);
a3470f
 #endif /* __EC_COMMON_H__ */
a3470f
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
a3470f
index bc25015..fd8c902 100644
a3470f
--- a/xlators/cluster/ec/src/ec-heal.c
a3470f
+++ b/xlators/cluster/ec/src/ec-heal.c
a3470f
@@ -2421,9 +2421,9 @@ ec_heal_do (xlator_t *this, void *data, loc_t *loc, int32_t partial)
a3470f
         intptr_t      bad            = 0;
a3470f
         ec_fop_data_t *fop           = data;
a3470f
         gf_boolean_t  blocking       = _gf_false;
a3470f
-        gf_boolean_t  need_heal      = _gf_false;
a3470f
+        ec_heal_need_t  need_heal    = EC_HEAL_NONEED;
a3470f
         unsigned char *up_subvols    = NULL;
a3470f
-	char up_bricks[32];
a3470f
+        char up_bricks[32];
a3470f
 
a3470f
         ec = this->private;
a3470f
 
a3470f
@@ -2470,7 +2470,8 @@ ec_heal_do (xlator_t *this, void *data, loc_t *loc, int32_t partial)
a3470f
          * triggers heals periodically which need not be thorough*/
a3470f
         ec_heal_inspect (frame, ec, loc->inode, up_subvols, _gf_false,
a3470f
                          !ec->shd.iamshd, &need_heal);
a3470f
-        if (!need_heal) {
a3470f
+
a3470f
+        if (need_heal == EC_HEAL_NONEED)  {
a3470f
                 gf_msg (ec->xl->name, GF_LOG_DEBUG, 0,
a3470f
                         EC_MSG_HEAL_FAIL, "Heal is not required for : %s ",
a3470f
                         uuid_utoa(loc->gfid));
a3470f
@@ -2776,18 +2777,18 @@ out:
a3470f
 static int32_t
a3470f
 _need_heal_calculate (ec_t *ec, uint64_t *dirty, unsigned char *sources,
a3470f
                       gf_boolean_t self_locked, int32_t lock_count,
a3470f
-                      gf_boolean_t *need_heal)
a3470f
+                      ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         int i = 0;
a3470f
         int source_count = 0;
a3470f
 
a3470f
         source_count = EC_COUNT (sources, ec->nodes);
a3470f
         if (source_count == ec->nodes) {
a3470f
-                *need_heal = _gf_false;
a3470f
+                *need_heal = EC_HEAL_NONEED;
a3470f
                 if (self_locked || lock_count == 0) {
a3470f
                         for (i = 0; i < ec->nodes; i++) {
a3470f
                                 if (dirty[i]) {
a3470f
-                                        *need_heal = _gf_true;
a3470f
+                                        *need_heal = EC_HEAL_MUST;
a3470f
                                         goto out;
a3470f
                                 }
a3470f
                         }
a3470f
@@ -2799,13 +2800,13 @@ _need_heal_calculate (ec_t *ec, uint64_t *dirty, unsigned char *sources,
a3470f
                                  * set and this indicates a problem in the
a3470f
                                  * inode.*/
a3470f
                                 if (dirty[i] > 1) {
a3470f
-                                        *need_heal = _gf_true;
a3470f
+                                        *need_heal = EC_HEAL_MUST;
a3470f
                                         goto out;
a3470f
                                 }
a3470f
                         }
a3470f
                 }
a3470f
         } else {
a3470f
-                *need_heal = _gf_true;
a3470f
+                *need_heal = EC_HEAL_MUST;
a3470f
         }
a3470f
 
a3470f
 out:
a3470f
@@ -2815,7 +2816,7 @@ out:
a3470f
 static int32_t
a3470f
 ec_need_metadata_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
                        int32_t lock_count, gf_boolean_t self_locked,
a3470f
-                       gf_boolean_t thorough, gf_boolean_t *need_heal)
a3470f
+                       gf_boolean_t thorough, ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         uint64_t           *dirty         = NULL;
a3470f
         unsigned char      *sources       = NULL;
a3470f
@@ -2836,10 +2837,10 @@ ec_need_metadata_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
 
a3470f
         ret = _need_heal_calculate (ec, dirty, sources, self_locked, lock_count,
a3470f
                                     need_heal);
a3470f
-        if (ret == ec->nodes && !(*need_heal)) {
a3470f
+        if (ret == ec->nodes && *need_heal == EC_HEAL_NONEED) {
a3470f
                 for (i = 1; i < ec->nodes; i++) {
a3470f
                         if (meta_versions[i] != meta_versions[0]) {
a3470f
-                                *need_heal = _gf_true;
a3470f
+                                *need_heal = EC_HEAL_MUST;
a3470f
                                 goto out;
a3470f
                         }
a3470f
                 }
a3470f
@@ -2851,7 +2852,7 @@ out:
a3470f
 static int32_t
a3470f
 ec_need_data_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
                    int32_t lock_count, gf_boolean_t self_locked,
a3470f
-                   gf_boolean_t thorough, gf_boolean_t *need_heal)
a3470f
+                   gf_boolean_t thorough, ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         uint64_t           *dirty         = NULL;
a3470f
         unsigned char      *sources       = NULL;
a3470f
@@ -2888,7 +2889,7 @@ out:
a3470f
 static int32_t
a3470f
 ec_need_entry_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
                     int32_t lock_count, gf_boolean_t self_locked,
a3470f
-                    gf_boolean_t thorough, gf_boolean_t *need_heal)
a3470f
+                    gf_boolean_t thorough, ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         uint64_t           *dirty         = NULL;
a3470f
         unsigned char      *sources       = NULL;
a3470f
@@ -2916,7 +2917,7 @@ out:
a3470f
 static int32_t
a3470f
 ec_need_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
               int32_t lock_count, gf_boolean_t self_locked,
a3470f
-              gf_boolean_t thorough, gf_boolean_t *need_heal)
a3470f
+              gf_boolean_t thorough, ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         int                ret            = 0;
a3470f
 
a3470f
@@ -2926,7 +2927,7 @@ ec_need_heal (ec_t *ec, inode_t *inode, default_args_cbk_t *replies,
a3470f
         if (ret < 0)
a3470f
                 goto out;
a3470f
 
a3470f
-        if (*need_heal)
a3470f
+        if (*need_heal == EC_HEAL_MUST)
a3470f
                 goto out;
a3470f
 
a3470f
         if (inode->ia_type == IA_IFREG) {
a3470f
@@ -2945,7 +2946,7 @@ int32_t
a3470f
 ec_heal_inspect (call_frame_t *frame, ec_t *ec,
a3470f
                  inode_t *inode, unsigned char *locked_on,
a3470f
                  gf_boolean_t self_locked, gf_boolean_t thorough,
a3470f
-                 gf_boolean_t *need_heal)
a3470f
+                 ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         loc_t              loc           = {0};
a3470f
         int                i             = 0;
a3470f
@@ -2989,7 +2990,7 @@ ec_heal_inspect (call_frame_t *frame, ec_t *ec,
a3470f
 
a3470f
         if (ret != ec->nodes) {
a3470f
                 ret = ec->nodes;
a3470f
-                *need_heal = _gf_true;
a3470f
+                *need_heal = EC_HEAL_MUST;
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
@@ -3009,6 +3010,9 @@ need_heal:
a3470f
         ret = ec_need_heal (ec, inode, replies, lock_count,
a3470f
                             self_locked, thorough, need_heal);
a3470f
 
a3470f
+        if (!self_locked && *need_heal == EC_HEAL_MUST) {
a3470f
+                *need_heal = EC_HEAL_MAYBE;
a3470f
+        }
a3470f
 out:
a3470f
         cluster_replies_wipe (replies, ec->nodes);
a3470f
         loc_wipe (&loc;;
a3470f
@@ -3020,7 +3024,7 @@ out:
a3470f
 
a3470f
 int32_t
a3470f
 ec_heal_locked_inspect (call_frame_t *frame, ec_t *ec, inode_t *inode,
a3470f
-                        gf_boolean_t *need_heal)
a3470f
+                        ec_heal_need_t *need_heal)
a3470f
 {
a3470f
         unsigned char      *locked_on  = NULL;
a3470f
         unsigned char      *up_subvols = NULL;
a3470f
@@ -3038,7 +3042,7 @@ ec_heal_locked_inspect (call_frame_t *frame, ec_t *ec, inode_t *inode,
a3470f
                                replies, locked_on, frame, ec->xl,
a3470f
                                ec->xl->name, inode, 0, 0);
a3470f
         if (ret != ec->nodes) {
a3470f
-                *need_heal = _gf_true;
a3470f
+                *need_heal = EC_HEAL_MUST;
a3470f
                 goto unlock;
a3470f
         }
a3470f
         ret = ec_heal_inspect (frame, ec, inode, locked_on, _gf_true, _gf_true,
a3470f
@@ -3055,7 +3059,7 @@ int32_t
a3470f
 ec_get_heal_info (xlator_t *this, loc_t *entry_loc, dict_t **dict_rsp)
a3470f
 {
a3470f
         int             ret             = -ENOMEM;
a3470f
-        gf_boolean_t    need_heal       = _gf_false;
a3470f
+        ec_heal_need_t  need_heal       = EC_HEAL_NONEED;
a3470f
         call_frame_t    *frame          = NULL;
a3470f
         ec_t            *ec             = NULL;
a3470f
         unsigned char   *up_subvols     = NULL;
a3470f
@@ -3068,6 +3072,10 @@ ec_get_heal_info (xlator_t *this, loc_t *entry_loc, dict_t **dict_rsp)
a3470f
         up_subvols = alloca0(ec->nodes);
a3470f
         ec_mask_to_char_array (ec->xl_up, up_subvols, ec->nodes);
a3470f
 
a3470f
+        if (EC_COUNT (up_subvols, ec->nodes) != ec->nodes) {
a3470f
+                need_heal = EC_HEAL_MUST;
a3470f
+                goto set_heal;
a3470f
+        }
a3470f
         frame = create_frame (this, this->ctx->pool);
a3470f
         if (!frame) {
a3470f
                 goto out;
a3470f
@@ -3092,16 +3100,16 @@ ec_get_heal_info (xlator_t *this, loc_t *entry_loc, dict_t **dict_rsp)
a3470f
 
a3470f
         ret = ec_heal_inspect (frame, ec, loc.inode, up_subvols, _gf_false,
a3470f
                                _gf_false, &need_heal);
a3470f
-        if (ret == ec->nodes && !need_heal) {
a3470f
+        if (ret == ec->nodes && need_heal == EC_HEAL_NONEED) {
a3470f
                 goto set_heal;
a3470f
         }
a3470f
-        need_heal = _gf_false;
a3470f
+        need_heal = EC_HEAL_NONEED;
a3470f
         ret = ec_heal_locked_inspect (frame, ec, loc.inode,
a3470f
                                       &need_heal);
a3470f
         if (ret < 0)
a3470f
                 goto out;
a3470f
 set_heal:
a3470f
-        if (need_heal) {
a3470f
+        if (need_heal == EC_HEAL_MUST) {
a3470f
                 ret =  ec_set_heal_info (dict_rsp, "heal");
a3470f
         } else {
a3470f
                 ret =  ec_set_heal_info (dict_rsp, "no-heal");
a3470f
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
a3470f
index 354b4ed..a891ff5 100644
a3470f
--- a/xlators/cluster/ec/src/ec-types.h
a3470f
+++ b/xlators/cluster/ec/src/ec-types.h
a3470f
@@ -17,6 +17,9 @@
a3470f
 
a3470f
 #define EC_GF_MAX_REGS 16
a3470f
 
a3470f
+enum _ec_heal_need;
a3470f
+typedef enum _ec_heal_need ec_heal_need_t;
a3470f
+
a3470f
 enum _ec_read_policy;
a3470f
 typedef enum _ec_read_policy ec_read_policy_t;
a3470f
 
a3470f
@@ -115,6 +118,12 @@ enum _ec_read_policy {
a3470f
         EC_READ_POLICY_MAX
a3470f
 };
a3470f
 
a3470f
+enum _ec_heal_need {
a3470f
+        EC_HEAL_NONEED,
a3470f
+        EC_HEAL_MAYBE,
a3470f
+        EC_HEAL_MUST
a3470f
+};
a3470f
+
a3470f
 struct _ec_config {
a3470f
     uint32_t version;
a3470f
     uint8_t  algorithm;
a3470f
-- 
a3470f
1.8.3.1
a3470f