From 5d57885a1b63ba89406c0dbd02bb254eacf531bd Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Mon, 16 Dec 2013 03:09:58 +0000 Subject: glusterd/snapshot: Introducing snap-max-hard-limit and snap-max-soft-limit Note: Manually adding this patch again as this patch got missed in git reset option done on remote development branch Change-Id: I9e81c5ec003c1e1722d0fcb27dd87c365ee43ff4 Signed-off-by: Avra Sengupta Signed-off-by: Rajesh Joseph --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 456 ++++++++++++++------------ xlators/mgmt/glusterd/src/glusterd-store.c | 85 ++++- xlators/mgmt/glusterd/src/glusterd-store.h | 3 +- xlators/mgmt/glusterd/src/glusterd-utils.c | 34 +- xlators/mgmt/glusterd/src/glusterd.c | 3 - xlators/mgmt/glusterd/src/glusterd.h | 6 +- 6 files changed, 347 insertions(+), 240 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index d21377924..cd9ed3f23 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -395,14 +395,61 @@ out: } int -glusterd_snapshot_config_limit_prevalidate (dict_t *dict, char **op_errstr, - int config_command) +snap_max_limits_validate (dict_t *dict, char *key, + char **op_errstr) +{ + char err_str[PATH_MAX] = ""; + glusterd_conf_t *conf = NULL; + int ret = -1; + uint64_t value = 0; + uint64_t max_limit = GLUSTERD_SNAPS_MAX_LIMIT; + xlator_t *this = NULL; + + this = THIS; + + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (key); + GF_ASSERT (op_errstr); + + conf = this->private; + + GF_ASSERT (conf); + + ret = dict_get_uint64 (dict, key, &value); + if (ret) { + snprintf (err_str, PATH_MAX,"Failed to get the" + " value for %s", key); + *op_errstr = gf_strdup (err_str); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + goto out; + } + + if ((value < 0) || + (value > max_limit)) { + ret = -1; + snprintf (err_str, PATH_MAX, "Invalid %s " + "%"PRIu64 ". Expected range 0 - %"PRIu64, + key, value, max_limit); + *op_errstr = gf_strdup (err_str); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + goto out; + } + + ret = 0; +out: + return ret; +} + +int +glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) { char *volname = NULL; + char *key = NULL; glusterd_volinfo_t *volinfo = NULL; - uint64_t limit = 0; xlator_t *this = NULL; int ret = -1; + int config_command = 0; char err_str[PATH_MAX] = {0,}; glusterd_conf_t *conf = NULL; @@ -416,70 +463,29 @@ glusterd_snapshot_config_limit_prevalidate (dict_t *dict, char **op_errstr, GF_ASSERT (conf); - switch (config_command) { + ret = dict_get_int32 (dict, "config-command", &config_command); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "failed to get config-command type"); + goto out; + } - case GF_SNAP_CONFIG_SYS_MAX: - ret = dict_get_uint64 (dict, "limit", &limit); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " snapshot limit"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - if (limit < 0 || limit > GLUSTERD_SNAPS_MAX_LIMIT) { - ret = -1; - snprintf (err_str, PATH_MAX,"Invalid max snap limit " - "%"PRIu64 ". Expected range 0 - %"PRIu64, - limit, conf->snap_max_limit); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - break; + ret = dict_get_str (dict, "config-key", &key); - case GF_SNAP_CONFIG_VOL_MAX: - // volume wide limit - ret = dict_get_str (dict, "volname", &volname); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volume name"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - ret = glusterd_volinfo_find (volname, &volinfo); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volinfo for volume %s", volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - ret = dict_get_uint64 (dict, "limit", &limit); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " snapshot limit volinfo for volume %s", - volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - if (limit < 0 || limit > conf->snap_max_limit) { - ret = -1; - snprintf (err_str, PATH_MAX,"Invalid max snap limit " - "%"PRIu64 " for volume %s. Expected range" - " 0 - %"PRIu64, limit, volname, - conf->snap_max_limit); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; + switch (config_command) { + case GF_SNAP_CONFIG_TYPE_SET: + if ((!strncmp (key, "snap-max-hard-limit", strlen(key))) || + (!strncmp (key, "snap-max-soft-limit", strlen(key)))) { + /* Validations for snap-max-hard-limit and snap-max-soft-limit */ + ret = snap_max_limits_validate (dict, key, op_errstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "%s validation failed.", key); + goto out; + } } break; - case GF_SNAP_CONFIG_CG_MAX: - break; - case GF_SNAP_CONFIG_DISPLAY: ret = dict_get_str (dict, "volname", &volname); if (ret) { @@ -489,14 +495,14 @@ glusterd_snapshot_config_limit_prevalidate (dict_t *dict, char **op_errstr, gf_log (this->name, GF_LOG_ERROR, "%s", err_str); goto out; } - if (!strncmp (volname, "all", 3)) { + if (!strncmp (volname, "all", strlen(volname))) { ret = 0; goto out; } ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volinfo for volume %s", volname); + snprintf (err_str, PATH_MAX,"Volume %s does not exist.", + volname); *op_errstr = gf_strdup (err_str); gf_log (this->name, GF_LOG_ERROR, "%s", err_str); goto out; @@ -509,39 +515,6 @@ out: return ret; } -int -glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr) -{ - int config_command = 0; - xlator_t *this = NULL; - int ret = -1; - - this = THIS; - ret = dict_get_int32 (dict, "config-command", &config_command); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "failed to get config-command type"); - goto out; - } - - switch (config_command) { - case GF_SNAP_CONFIG_SYS_MAX: - case GF_SNAP_CONFIG_VOL_MAX: - case GF_SNAP_CONFIG_CG_MAX: - case GF_SNAP_CONFIG_DISPLAY: - ret = glusterd_snapshot_config_limit_prevalidate (dict, - op_errstr, - config_command); - break; - default: - ret = -1; - gf_log (this->name, GF_LOG_ERROR, "Incorrect config op"); - break; - } -out: - return ret; -} - int glusterd_snap_create_pre_val_use_rsp_dict (dict_t *dst, dict_t *src) { @@ -1679,17 +1652,17 @@ glusterd_snapshot_vol_get_snaplist_lk (dict_t *dict, char *keyprefix, goto out; } - if (conf->snap_max_limit < volinfo->snap_max_limit) { - snap_limit = conf->snap_max_limit; - gf_log(this->name, GF_LOG_DEBUG, "system snap_limit is " - "lesser than volume snap_limit, snap_limit value " - "is set to %ld",snap_limit); + if (conf->snap_max_hard_limit < volinfo->snap_max_hard_limit) { + snap_limit = conf->snap_max_hard_limit; + gf_log(this->name, GF_LOG_DEBUG, "system snap-max-hard-limit is" + " lesser than volume snap-max-hard-limit, " + "snap-max-hard-limit value is set to %ld", snap_limit); } else { - snap_limit = volinfo->snap_max_limit ; - gf_log(this->name, GF_LOG_DEBUG, "volume snap_limit is " - "lesser than system snap_limit, snap_limit value " - "is set to %ld",snap_limit); + snap_limit = volinfo->snap_max_hard_limit ; + gf_log(this->name, GF_LOG_DEBUG, "volume snap-max-hard-limit is" + " lesser than system snap-max-hard-limit, " + "snap-max-hard-limit value is set to %ld",snap_limit); } if (snap_limit > volinfo->snap_count) @@ -4121,152 +4094,233 @@ out: } int -glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr, - dict_t *rsp_dict) +snap_max_limits_set_commit (dict_t *dict, char *key, char *volname, + char **op_errstr) { - char *volname = NULL; + char err_str[PATH_MAX] = ""; + glusterd_conf_t *conf = NULL; glusterd_volinfo_t *volinfo = NULL; - uint64_t limit = 0; - xlator_t *this = NULL; int ret = -1; - char err_str[PATH_MAX] = {0,}; - glusterd_conf_t *conf = NULL; - int config_command = 0; + uint64_t value = 0; + xlator_t *this = NULL; this = THIS; GF_ASSERT (this); GF_ASSERT (dict); - GF_ASSERT (rsp_dict); + GF_ASSERT (key); + GF_ASSERT (volname); GF_ASSERT (op_errstr); conf = this->private; GF_ASSERT (conf); - ret = dict_get_int32 (dict, "config-command", &config_command); + ret = dict_get_uint64 (dict, key, &value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "failed to get config-command type"); + snprintf (err_str, PATH_MAX,"Failed to get the" + " value for %s", key); goto out; } - switch (config_command) { + /* TODO: Initiate auto deletion when there is a limit change */ + if (!strncmp (volname, "all", strlen(volname))) { + /* For system limit */ + if (!strncmp (key, "snap-max-hard-limit", strlen(key))) + conf->snap_max_hard_limit = value; + else + conf->snap_max_soft_limit = value; - case GF_SNAP_CONFIG_SYS_MAX: - ret = dict_get_uint64 (dict, "limit", &limit); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " snapshot limit"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - conf->snap_max_limit = limit; ret = glusterd_store_global_info (this); if (ret) { - snprintf (err_str, PATH_MAX,"Failed to store the" - " snapshot limit volinfo for system"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - break; - - case GF_SNAP_CONFIG_VOL_MAX: - // volume wide limit - ret = dict_get_str (dict, "volname", &volname); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volume name"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + snprintf (err_str, PATH_MAX,"Failed to store %s " + "for system", key); goto out; } + } else { + /* For one volume */ ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { snprintf (err_str, PATH_MAX,"Failed to get the" " volinfo for volume %s", volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); goto out; } - ret = dict_get_uint64 (dict, "limit", &limit); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " snapshot limit volinfo for volume %s", - volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - volinfo->snap_max_limit = limit; + + if (!strncmp (key, "snap-max-hard-limit", strlen(key))) + volinfo->snap_max_hard_limit = value; + else + volinfo->snap_max_soft_limit = value; + ret = glusterd_store_volinfo (volinfo, - GLUSTERD_VOLINFO_VER_AC_INCREMENT); + GLUSTERD_VOLINFO_VER_AC_INCREMENT); if (ret) { - snprintf (err_str, PATH_MAX,"Failed to store the" - " snapshot limit volinfo for volume %s", - volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + snprintf (err_str, PATH_MAX,"Failed to store %s " + "for volume %s", key, volname); goto out; } - break; + } - case GF_SNAP_CONFIG_CG_MAX: - break; - case GF_SNAP_CONFIG_DISPLAY: - ret = dict_get_str (dict, "volname", &volname); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volume name"); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - goto out; - } - if (!strncmp (volname, "all", 3)) { - limit = conf->snap_max_limit; - } else { - ret = glusterd_volinfo_find (volname, &volinfo); - if (ret) { - snprintf (err_str, PATH_MAX,"Failed to get the" - " volinfo for volume %s", volname); - *op_errstr = gf_strdup (err_str); - gf_log (this->name, GF_LOG_ERROR, "%s", - err_str); - goto out; - } - limit = volinfo->snap_max_limit; - } + ret = 0; +out: + if (ret) { + *op_errstr = gf_strdup (err_str); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + } - ret = dict_set_uint64 (rsp_dict, "limit", limit); + return ret; +} + +int +snap_max_limits_display_commit (dict_t *rsp_dict, char *key, char *volname, + char **op_errstr) +{ + char err_str[PATH_MAX] = ""; + glusterd_conf_t *conf = NULL; + glusterd_volinfo_t *volinfo = NULL; + int ret = -1; + uint64_t value = 0; + xlator_t *this = NULL; + + this = THIS; + + GF_ASSERT (this); + GF_ASSERT (rsp_dict); + GF_ASSERT (key); + GF_ASSERT (volname); + GF_ASSERT (op_errstr); + + conf = this->private; + + GF_ASSERT (conf); + + if (!strncmp (volname, "all", strlen(volname))) { + /* For system limit */ + if (!strncmp (key, "snap-max-hard-limit", strlen(key))) + value = conf->snap_max_hard_limit; + else + value = conf->snap_max_soft_limit; + } else { + /* For one volume */ + ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { snprintf (err_str, PATH_MAX,"Failed to get the" - " set limit for volume %s", - volname); + " volinfo for volume %s", volname); *op_errstr = gf_strdup (err_str); gf_log (this->name, GF_LOG_ERROR, "%s", err_str); goto out; } - break; - default: - break; + if (!strncmp (key, "snap-max-hard-limit", strlen(key))) + value = volinfo->snap_max_hard_limit; + else + value = volinfo->snap_max_soft_limit; } - ret = dict_set_str (rsp_dict, "volname", volname); + ret = dict_set_uint64 (rsp_dict, key, value); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to set the" - " volume name"); + snprintf (err_str, PATH_MAX,"Failed to set %s " + "for volume %s", key, volname); + *op_errstr = gf_strdup (err_str); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); goto out; } - ret = dict_set_int32 (dict, "config-command", config_command); + ret = 0; +out: + return ret; +} + +int +glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr, + dict_t *rsp_dict) +{ + char *volname = NULL; + char *key = NULL; + xlator_t *this = NULL; + int ret = -1; + char err_str[PATH_MAX] = {0,}; + glusterd_conf_t *conf = NULL; + int config_command = 0; + + this = THIS; + + GF_ASSERT (this); + GF_ASSERT (dict); + GF_ASSERT (rsp_dict); + GF_ASSERT (op_errstr); + + conf = this->private; + + GF_ASSERT (conf); + + ret = dict_get_int32 (dict, "config-command", &config_command); if (ret) { gf_log (this->name, GF_LOG_ERROR, - "failed to set config-command type"); + "failed to get config-command type"); goto out; } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + snprintf (err_str, PATH_MAX,"Failed to get the" + " volume name"); + *op_errstr = gf_strdup (err_str); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + goto out; + } + + ret = dict_get_str (dict, "config-key", &key); + + switch (config_command) { + case GF_SNAP_CONFIG_TYPE_SET: + if ((!strncmp (key, "snap-max-hard-limit", strlen(key))) || + (!strncmp (key, "snap-max-soft-limit", strlen(key)))) { + /* Commit ops for snap-max-hard-limit and snap-max-soft-limit */ + ret = snap_max_limits_set_commit (dict, key, volname, op_errstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "%s set commit failed.", key); + goto out; + } + } + break; + + case GF_SNAP_CONFIG_DISPLAY: + if (!key) { + /* For all options */ + ret = snap_max_limits_display_commit (rsp_dict, "snap-max-hard-limit", + volname, op_errstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "snap-max-hard-limit " + "display commit failed."); + goto out; + } + + ret = snap_max_limits_display_commit (rsp_dict, "snap-max-soft-limit", + volname, op_errstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "snap-max-soft-limit " + "display commit failed."); + goto out; + } + } else if ((!strncmp (key, "snap-max-hard-limit", strlen(key))) || + (!strncmp (key, "snap-max-soft-limit", strlen(key)))) { + /* Commit ops for snap-max-hard-limit or snap-max-soft-limit */ + ret = snap_max_limits_display_commit (rsp_dict, key, + volname, op_errstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "%s display commit failed.", key); + goto out; + } + } + break; + default: + break; + } + out: gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret); return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 88ac2bf6e..f37ad9bec 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -702,11 +702,24 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo) if (ret) goto out; } - snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->snap_max_limit); - ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT, + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->snap_max_hard_limit); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, buf); - if (ret) + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Unable to write snap-max-hard-limit"); goto out; + } + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->snap_max_soft_limit); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT, + buf); + if (ret) { + gf_log (THIS->name, GF_LOG_ERROR, + "Unable to write snap-max-soft-limit"); + goto out; + } out: if (ret) @@ -2064,14 +2077,24 @@ glusterd_store_global_info (xlator_t *this) goto out; } - snprintf (buf, sizeof (buf), "%"PRIu64, conf->snap_max_limit); + snprintf (buf, sizeof (buf), "%"PRIu64, conf->snap_max_hard_limit); ret = gf_store_save_value (handle->fd, - GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT, buf); + GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, buf); if (ret) { gf_log (this->name, GF_LOG_ERROR, - "Storing snap-max-limit failed ret = %d", ret); + "Storing snap-max-hard-limit failed ret = %d", ret); goto out; } + + snprintf (buf, sizeof (buf), "%"PRIu64, conf->snap_max_soft_limit); + ret = gf_store_save_value (handle->fd, + GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT, buf); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Storing snap-max-soft-limit failed ret = %d", ret); + goto out; + } + ret = gf_store_rename_tmppath (handle); out: if (ret && (handle->fd > 0)) @@ -2144,7 +2167,7 @@ out: } int -glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit) +glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit, char *key) { char *limit_str = NULL; glusterd_conf_t *priv = NULL; @@ -2154,8 +2177,13 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit) char path[PATH_MAX] = {0,}; gf_store_handle_t *handle = NULL; + GF_ASSERT (this); priv = this->private; + GF_ASSERT (priv); + GF_ASSERT (limit); + GF_ASSERT (key); + if (!priv->handle) { snprintf (path, PATH_MAX, "%s/%s", priv->workdir, GLUSTERD_INFO_FILE); @@ -2171,11 +2199,11 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit) } ret = gf_store_retrieve_value (priv->handle, - GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT, + key, &limit_str); if (ret) { gf_log (this->name, GF_LOG_DEBUG, - "No previous snap limit present"); + "No previous %s present", key); goto out; } @@ -2197,12 +2225,33 @@ out: static int glusterd_restore_op_version (xlator_t *this) { - glusterd_conf_t *conf = NULL; - int ret = 0; - int op_version = 0; + glusterd_conf_t *conf = NULL; + int ret = 0; + int op_version = 0; + int snap_max_limit = GLUSTERD_SNAPS_MAX_LIMIT; conf = this->private; + ret = glusterd_retrieve_sys_snap_max_limit (this, + &conf->snap_max_hard_limit, + GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, + "Unable to retrieve system snap-max-hard-limit, " + "setting it to %d", snap_max_limit); + conf->snap_max_hard_limit = GLUSTERD_SNAPS_MAX_LIMIT; + } + + ret = glusterd_retrieve_sys_snap_max_limit (this, + &conf->snap_max_soft_limit, + GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, + "Unable to retrieve system snap-max-soft-limit, " + "setting it to %d", snap_max_limit); + conf->snap_max_soft_limit = GLUSTERD_SNAPS_MAX_LIMIT; + } + ret = glusterd_retrieve_op_version (this, &op_version); if (!ret) { if ((op_version < GD_OP_VERSION_MIN) || @@ -2241,9 +2290,6 @@ glusterd_restore_op_version (xlator_t *this) " op-version to minimum : %d", GD_OP_VERSION_MIN); conf->op_version = GD_OP_VERSION_MIN; } - ret = glusterd_retrieve_sys_snap_max_limit (this, &conf->snap_max_limit); - if (ret) - conf->snap_max_limit = GLUSTERD_SNAPS_MAX_LIMIT; ret = 0; out: return ret; @@ -2750,9 +2796,12 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap) } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_CAPS, strlen (GLUSTERD_STORE_KEY_VOL_CAPS))) { volinfo->caps = atoi (value); - } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT, - strlen (GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT))) { - volinfo->snap_max_limit = (uint64_t) atoll (value); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT, + strlen (GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT))) { + volinfo->snap_max_hard_limit = (uint64_t) atoll (value); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT, + strlen (GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT))) { + volinfo->snap_max_soft_limit = (uint64_t) atoll (value); } else if (!strncmp (key, GLUSTERD_STORE_KEY_PARENT_VOLNAME, strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) { strncpy (volinfo->parent_volname, value, sizeof(volinfo->parent_volname) - 1); diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index 69ee30dd3..13d408c44 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -68,7 +68,8 @@ typedef enum glusterd_store_ver_ac_{ #define GLUSTERD_STORE_KEY_SNAP_STATUS "status" #define GLUSTERD_STORE_KEY_SNAP_COUNT "count" #define GLUSTERD_STORE_KEY_CG_VOL_COUNT "count" -#define GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT "snap-max-limit" +#define GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT "snap-max-hard-limit" +#define GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT "snap-max-soft-limit" #define GLUSTERD_STORE_KEY_BRICK_HOSTNAME "hostname" #define GLUSTERD_STORE_KEY_BRICK_PATH "path" diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 7c68947b8..6947facbd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -463,10 +463,8 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo) snprintf (new_volinfo->parent_volname, GLUSTERD_MAX_VOLUME_NAME, "N/A"); - if (conf) - new_volinfo->snap_max_limit = conf->snap_max_limit; - else - new_volinfo->snap_max_limit = GLUSTERD_SNAPS_MAX_LIMIT; + new_volinfo->snap_max_hard_limit = GLUSTERD_SNAPS_MAX_LIMIT; + new_volinfo->snap_max_soft_limit = GLUSTERD_SNAPS_MAX_LIMIT; new_volinfo->xl = THIS; @@ -7857,9 +7855,9 @@ out: int glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) { - int ret = -1; - uint64_t limit = 0; - int config_command = 0; + int ret = -1; + uint64_t value = 0; + int config_command = 0; if (!dst || !src) { gf_log ("", GF_LOG_ERROR, "Source or Destination " @@ -7876,16 +7874,22 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src) switch (config_command) { case GF_SNAP_CONFIG_DISPLAY: - ret = dict_get_uint64 (src, "limit", &limit); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to fetch limit"); - goto out; + ret = dict_get_uint64 (src, "snap-max-hard-limit", &value); + if (!ret) { + ret = dict_set_uint64 (dst, "snap-max-hard-limit", value); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to set snap_max_hard_limit"); + goto out; + } } - ret = dict_set_uint64 (dst, "limit", limit); - if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to set limit"); - goto out; + ret = dict_get_uint64 (src, "snap-max-soft-limit", &value); + if (!ret) { + ret = dict_set_uint64 (dst, "snap-max-soft-limit", value); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to set snap_max_soft_limit"); + goto out; + } } break; diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 268acc776..8b97a4e26 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1322,9 +1322,6 @@ init (xlator_t *this) conf->gfs_mgmt = &gd_brick_prog; strncpy (conf->workdir, workdir, PATH_MAX); - conf->snap_max_limit = GLUSTERD_SNAPS_MAX_LIMIT; - //TODO: read from saved value and update - synclock_init (&conf->big_lock); pthread_mutex_init (&conf->xprt_lock, NULL); INIT_LIST_HEAD (&conf->xprt_list); diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 648a88452..343e6fe4d 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -158,7 +158,8 @@ typedef struct { rpcsvc_t *uds_rpc; /* RPCSVC for the unix domain socket */ uint32_t base_port; struct list_head snap_cg; - uint64_t snap_max_limit; + uint64_t snap_max_hard_limit; + uint64_t snap_max_soft_limit; char *snap_bricks_directory; } glusterd_conf_t; @@ -285,7 +286,8 @@ struct glusterd_volinfo_ { int type; int brick_count; uint64_t snap_count; - uint64_t snap_max_limit; + uint64_t snap_max_hard_limit; + uint64_t snap_max_soft_limit; struct list_head vol_list; struct list_head bricks; struct list_head snaps; -- cgit