diff options
| author | hari gowtham <hgowtham@redhat.com> | 2016-04-19 14:01:09 +0530 | 
|---|---|---|
| committer | Atin Mukherjee <amukherj@redhat.com> | 2017-03-18 18:19:45 -0400 | 
| commit | 78222bff29f27fc3b4f500ff2f7bd323c418d09e (patch) | |
| tree | ee769968d8cd9125db30ca8b0ed250e490c58a4e | |
| parent | 870a1d66f56345df38b70baa31ae314e2cde789c (diff) | |
TIER: watermark check during low watermark reset
PROBLEM: during a low watermark reset, checking of whether
the low watermark is lower than hi watermark is not done.
FIX: This patch checks if the hi watermark value is higher
the default low watermark. Else throws an failure of the reset
command
Change-Id: I8b49090c6bccce6d45c2e8076ab766047a2a6162
BUG: 1328342
Signed-off-by: hari gowtham <hgowtham@redhat.com>
Reviewed-on: https://review.gluster.org/14028
Smoke: Gluster Build System <jenkins@build.gluster.org>
Tested-by: hari gowtham <hari.gowtham005@gmail.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
| -rwxr-xr-x | tests/basic/tier/tier.t | 6 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-messages.h | 10 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 86 | 
3 files changed, 101 insertions, 1 deletions
diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t index a5bd09f8028..308e22c74db 100755 --- a/tests/basic/tier/tier.t +++ b/tests/basic/tier/tier.t @@ -113,6 +113,12 @@ TEST ! $CLI volume set $V0 cluster.watermark-low 90  TEST ! $CLI volume set $V0 cluster.read-freq-threshold -12  TEST ! $CLI volume set $V0 cluster.write-freq-threshold -12 +#check for watermark reset +TEST $CLI volume set $V0 cluster.watermark-low 10 +TEST $CLI volume set $V0 cluster.watermark-hi 30 +TEST ! $CLI volume reset $V0 cluster.watermark-low +TEST $CLI volume reset $V0 cluster.watermark-hi +TEST $CLI volume reset $V0 cluster.watermark-low  # stop the volume and restart it. The rebalance daemon should restart.  cd /tmp diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index 28c73d23d82..d185db0d2e5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -41,7 +41,7 @@  #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD -#define GLFS_NUM_MESSAGES       597 +#define GLFS_NUM_MESSAGES       598  #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)  /* Messaged with message IDs */ @@ -4835,6 +4835,14 @@   */  #define GD_MSG_NO_SIG_TO_PID_ZERO                  (GLUSTERD_COMP_BASE + 597) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define GD_MSG_TIER_WATERMARK_RESET_FAIL           (GLUSTERD_COMP_BASE + 598)  /*------------*/ diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 5169f414e94..75469d68e26 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1449,6 +1449,82 @@ out:          }          return ret;  } +static int +glusterd_water_limit_check (glusterd_volinfo_t *volinfo, gf_boolean_t is_hi, +                char **op_errstr) +{ + +        int                                     ret            = -1; +        char                                    *default_value = NULL; +        char                                    *temp          = NULL; +        uint64_t                                wm             = 0; +        uint64_t                                default_wm     = 0; +        struct volopt_map_entry                 *vmap          = NULL; +        xlator_t                                *this          = NULL; +        extern struct volopt_map_entry          glusterd_volopt_map[]; +        char                                    msg[2048]      = {0}; + +        this = THIS; +        GF_ASSERT (this); + +        if (is_hi) +                ret = glusterd_volinfo_get (volinfo, +                                            "cluster.watermark-low", &temp); +        else +                ret = glusterd_volinfo_get (volinfo, +                                            "cluster.watermark-hi", &temp); +        if (ret) { +                gf_msg (this->name, GF_LOG_ERROR, 0, +                        GD_MSG_VOLINFO_GET_FAIL, "failed to get watermark"); +                goto out; +        } + +        gf_string2bytesize_uint64 (temp, &wm); + +        if (is_hi) +                for (vmap = glusterd_volopt_map; vmap->key; vmap++) { +                        if (strcmp (vmap->key, "cluster.watermark-hi") == 0) +                                default_value = vmap->value; +                } +        else +                for (vmap = glusterd_volopt_map; vmap->key; vmap++) { +                        if (strcmp (vmap->key, "cluster.watermark-low") == 0) +                                default_value = vmap->value; +                } + +        gf_string2bytesize_uint64 (default_value, &default_wm); + +        if (is_hi) { +                if (default_wm <= wm) { +                        snprintf (msg, sizeof (msg), "Resetting hi-watermark " +                                  "to default will make it lower or equal to " +                                  "the low-watermark, which is an invalid " +                                  "configuration state. Please lower the " +                                  "low-watermark first to the desired value " +                                  "and then reset the hi-watermark."); +                        ret = -1; +                        goto out; +                } +        } else { +                if (default_wm >= wm) { +                        snprintf (msg, sizeof (msg), "Resetting low-watermark " +                                  "to default will make it higher or equal to " +                                  "the hi-watermark, which is an invalid " +                                  "configuration state. Please raise the " +                                  "hi-watermark first to the desired value " +                                  "and then reset the low-watermark."); +                        ret = -1; +                        goto out; +                } +        } +out: +        if (msg[0] != '\0') { +                gf_msg (THIS->name, GF_LOG_ERROR, 0, +                        GD_MSG_TIER_WATERMARK_RESET_FAIL, "%s", msg); +                *op_errstr = gf_strdup (msg); +        } +        return ret; +}  static int  glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr) @@ -1525,6 +1601,16 @@ glusterd_op_stage_reset_volume (dict_t *dict, char **op_errstr)                  if (exists == -1) {                          ret = -1;                          goto out; +                } else if (strcmp (key, "cluster.watermark-low") == 0) { +                        ret = glusterd_water_limit_check (volinfo, _gf_false, +                                        op_errstr); +                        if (ret) +                                return ret; +                } else if (strcmp (key, "cluster.watermark-hi") == 0) { +                        ret = glusterd_water_limit_check (volinfo, _gf_true, +                                        op_errstr); +                        if (ret) +                                return ret;                  }                  if (!exists) {  | 
