summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-06-26 07:51:02 +0530
committerVijay Bellur <vbellur@redhat.com>2014-09-23 02:00:22 -0700
commitb98ed29cf6c1b999a025dff2269118a9198bd987 (patch)
treeffc1031036bc104b979ae4e24ada47cabec578f2 /xlators/mgmt
parent794d9fbe00b71aa80e841530f00af9b8f81c8f21 (diff)
cli/snapshot : gluster volume info should not show the options which are not set explicitly.
Problem : Even though snap-max-hard-limit, snap-max-soft-limit and auto-delete values were not set explicitly, It was getting showed in the output of gluster volume info. Solution : Check if the value is already present in dictionary (That means, it is set), If value is not present then consider the default value, NOTE : This patch doesn't solve the problem where the values which is set globally are being displayed in gluster volume info Change-Id: I61445b3d2a12eb68c38a19bea53b9051ad028050 BUG: 1145020 Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/8191 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-by: Kaushal M <kaushal@redhat.com> Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/8793 Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c285
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c178
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c13
4 files changed, 222 insertions, 257 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 148acec8882..79242afc500 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -207,19 +207,19 @@ int
snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
char *op_errstr, int len)
{
- char err_str[PATH_MAX] = "";
- char buf[PATH_MAX] = "";
- glusterd_conf_t *conf = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- int ret = -1;
- uint64_t active_hard_limit = 0;
- uint64_t snap_max_limit = 0;
- uint64_t soft_limit_value = -1;
- uint64_t count = 0;
- xlator_t *this = NULL;
- uint64_t opt_hard_max = 0;
- uint64_t opt_soft_max = 0;
- char *auto_delete = NULL;
+ char err_str[PATH_MAX] = "";
+ char buf[PATH_MAX] = "";
+ glusterd_conf_t *conf = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ int ret = -1;
+ uint64_t active_hard_limit = 0;
+ uint64_t snap_max_limit = 0;
+ uint64_t soft_limit_value = -1;
+ uint64_t count = 0;
+ xlator_t *this = NULL;
+ uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ uint64_t opt_soft_max = GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT;
+ char *auto_delete = "disable";
this = THIS;
@@ -231,25 +231,13 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
GF_ASSERT (conf);
- ret = dict_get_uint64 (conf->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
- &opt_hard_max);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
- }
- ret = dict_get_uint64 (conf->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
- &opt_soft_max);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from options",
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
- goto out;
- }
+ /* config values snap-max-hard-limit and snap-max-soft-limit are
+ * optional and hence we are not erroring out if values are not
+ * present
+ */
+ gd_get_snap_conf_values_if_present (conf->opts, &opt_hard_max,
+ &opt_soft_max);
if (!volname) {
/* For system limit */
@@ -395,15 +383,12 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
goto out;
}
- ret = dict_get_str (conf->opts,
- GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
+ /* "auto-delete" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
+ ret = dict_get_str (conf->opts, GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
&auto_delete);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from options",
- GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE);
- goto out;
- }
ret = dict_set_dynstr_with_alloc (rsp_dict,
GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
@@ -1042,7 +1027,7 @@ snap_max_hard_limits_validate (dict_t *dict, char *volname,
int ret = -1;
uint64_t max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
xlator_t *this = NULL;
- uint64_t opt_hard_max = 0;
+ uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
this = THIS;
@@ -1068,14 +1053,18 @@ snap_max_hard_limits_validate (dict_t *dict, char *volname,
}
}
+ /* "snap-max-hard-limit" might not be set by user explicitly,
+ * in that case it's better to use the default value.
+ * Hence not erroring out if Key is not found.
+ */
ret = dict_get_uint64 (conf->opts,
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
&opt_hard_max);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
+ ret = 0;
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ "opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
}
/* volume snap-max-hard-limit cannot exceed system snap-max-hard-limit.
@@ -1118,8 +1107,8 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
uint64_t soft_limit = 0;
gf_loglevel_t loglevel = GF_LOG_ERROR;
uint64_t max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
- char *req_auto_delete = NULL;
- char *cur_auto_delete = NULL;
+ char cur_auto_delete = 0;
+ int req_auto_delete = 0;
this = THIS;
@@ -1138,12 +1127,11 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
goto out;
}
- ret = dict_get_uint64 (dict, "snap-max-hard-limit", &hard_limit);
-
- ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit);
-
- ret = dict_get_str (dict, GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
- &req_auto_delete);
+ /* config values snap-max-hard-limit and snap-max-soft-limit are
+ * optional and hence we are not erroring out if values are not
+ * present
+ */
+ gd_get_snap_conf_values_if_present (dict, &hard_limit, &soft_limit);
ret = dict_get_str (dict, "volname", &volname);
@@ -1183,23 +1171,42 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
break;
}
- if (req_auto_delete) {
- ret = dict_get_str (conf->opts,
- GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
- &cur_auto_delete);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "get auto-delete value from options");
- goto out;
- }
+ /* If hard_limit or soft_limit is set then need not check
+ * for auto-delete
+ */
+ if (hard_limit || soft_limit) {
+ ret = 0;
+ goto out;
+ }
- if (strcmp (req_auto_delete, cur_auto_delete) == 0) {
- ret = -1;
- snprintf (err_str, PATH_MAX, "auto-delete "
- "is already %sd", req_auto_delete);
- goto out;
- }
+ req_auto_delete = dict_get_str_boolean (dict,
+ GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
+ _gf_false);
+ if (req_auto_delete < 0) {
+ ret = -1;
+ snprintf (err_str, sizeof (err_str), "Please enter a "
+ "valid boolean value for auto-delete");
+ goto out;
+ }
+
+ /* Ignoring the error as the auto-delete is optional and
+ * might not be present in the options dictionary.
+ */
+ cur_auto_delete = dict_get_str_boolean (conf->opts,
+ GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
+ _gf_false);
+
+ if (cur_auto_delete == req_auto_delete) {
+ ret = -1;
+ if (cur_auto_delete == _gf_true)
+ snprintf (err_str, sizeof (err_str),
+ "auto-delete is already enabled");
+ else
+ snprintf (err_str, sizeof (err_str),
+ "auto-delete is already disabled");
+ goto out;
}
+
default:
break;
}
@@ -1626,26 +1633,26 @@ int
glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
dict_t *rsp_dict)
{
- char *volname = NULL;
- char *snapname = NULL;
- char *device = NULL;
- char key[PATH_MAX] = "";
- char snap_volname[64] = "";
- char err_str[PATH_MAX] = "";
- int ret = -1;
- int64_t i = 0;
- int64_t volcount = 0;
- int64_t brick_count = 0;
- int64_t brick_order = 0;
- glusterd_brickinfo_t *brickinfo = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- xlator_t *this = NULL;
- uuid_t *snap_volid = NULL;
- gf_loglevel_t loglevel = GF_LOG_ERROR;
- glusterd_conf_t *conf = NULL;
- int64_t effective_max_limit = 0;
- int flags = 0;
- uint64_t opt_hard_max = 0;
+ char *volname = NULL;
+ char *snapname = NULL;
+ char *device = NULL;
+ char key[PATH_MAX] = "";
+ char snap_volname[64] = "";
+ char err_str[PATH_MAX] = "";
+ int ret = -1;
+ int64_t i = 0;
+ int64_t volcount = 0;
+ int64_t brick_count = 0;
+ int64_t brick_order = 0;
+ glusterd_brickinfo_t *brickinfo = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ xlator_t *this = NULL;
+ uuid_t *snap_volid = NULL;
+ gf_loglevel_t loglevel = GF_LOG_ERROR;
+ glusterd_conf_t *conf = NULL;
+ int64_t effective_max_limit = 0;
+ int flags = 0;
+ uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
this = THIS;
GF_ASSERT (op_errstr);
@@ -1659,8 +1666,8 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
if (volcount <= 0) {
- snprintf (err_str, sizeof (err_str), "Invalid volume count %"PRId64
- " supplied", volcount);
+ snprintf (err_str, sizeof (err_str),
+ "Invalid volume count %"PRId64" supplied", volcount);
ret = -1;
goto out;
}
@@ -1722,14 +1729,18 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
goto out;
}
+ /* "snap-max-hard-limit" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
ret = dict_get_uint64 (conf->opts,
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
&opt_hard_max);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
+ ret = 0;
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present "
+ "in opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
}
if (volinfo->snap_max_hard_limit < opt_hard_max)
@@ -2456,7 +2467,7 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
glusterd_volinfo_t *origin_vol = NULL;
glusterd_conf_t *conf = NULL;
xlator_t *this = NULL;
- uint64_t opt_hard_max = 0;
+ uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
this = THIS;
conf = this->private;
@@ -2526,16 +2537,18 @@ glusterd_snapshot_get_snapvol_detail (dict_t *dict,
goto out;
}
- /* Snaps available */
-
+ /* "snap-max-hard-limit" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
ret = dict_get_uint64 (conf->opts,
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
&opt_hard_max);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
+ ret = 0;
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ "opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
}
if (opt_hard_max < origin_vol->snap_max_hard_limit) {
@@ -2821,7 +2834,7 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
glusterd_volinfo_t *tmp_vol = NULL;
glusterd_conf_t *conf = NULL;
xlator_t *this = NULL;
- uint64_t opt_hard_max = 0;
+ uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
this = THIS;
conf = this->private;
@@ -2837,15 +2850,18 @@ glusterd_snapshot_get_info_by_volume (dict_t *dict, char *volname,
goto out;
}
- /* Snaps available */
+ /* "snap-max-hard-limit" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
ret = dict_get_uint64 (conf->opts,
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
&opt_hard_max);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
+ ret = 0;
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present in "
+ "opts dictionary",
GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
}
if (opt_hard_max < volinfo->snap_max_hard_limit) {
@@ -5482,15 +5498,18 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
goto out;
}
- /* Ignore the return value of the following dict_get,
- * as they are optional
- */
ret = dict_get_str (dict, "volname", &volname);
- ret = dict_get_uint64 (dict, "snap-max-hard-limit", &hard_limit);
-
- ret = dict_get_uint64 (dict, "snap-max-soft-limit", &soft_limit);
+ /* config values snap-max-hard-limit and snap-max-soft-limit are
+ * optional and hence we are not erroring out if values are not
+ * present
+ */
+ gd_get_snap_conf_values_if_present (dict, &hard_limit,
+ &soft_limit);
+ /* Ignoring the return value as auto-delete is optional and
+ * might not be present in the request dictionary.
+ */
ret = dict_get_str (dict, GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
&auto_delete);
@@ -6281,8 +6300,8 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
glusterd_snap_t *snap = NULL;
glusterd_volinfo_t *tmp_volinfo = NULL;
glusterd_volinfo_t *other_volinfo = NULL;
- uint64_t opt_max_hard = 0;
- uint64_t opt_max_soft = 0;
+ uint64_t opt_max_hard = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ uint64_t opt_max_soft = GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT;
this = THIS;
GF_ASSERT (this);
@@ -6314,15 +6333,12 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
goto out;
}
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
- &opt_max_hard);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
- }
+ /* config values snap-max-hard-limit and snap-max-soft-limit are
+ * optional and hence we are not erroring out if values are not
+ * present
+ */
+ gd_get_snap_conf_values_if_present (priv->opts, &opt_max_hard,
+ &opt_max_soft);
/* The minimum of the 2 limits i.e system wide limit and
volume wide limit will be considered
@@ -6332,16 +6348,6 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict)
else
effective_max_limit = opt_max_hard;
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
- &opt_max_soft);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
- goto out;
- }
-
limit = (opt_max_soft * effective_max_limit)/100;
count = volinfo->snap_count - limit;
@@ -6450,18 +6456,17 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
goto out;
}
- ret = dict_get_str (priv->opts, GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
- &auto_delete);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "the value of auto-delete from options");
- goto out;
- }
-
- //ignore the errors of autodelete
- if (strcmp (auto_delete, "enable") == 0)
+ /* "auto-delete" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
+ ret = dict_get_str_boolean (priv->opts,
+ GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
+ _gf_false);
+ if ( _gf_true == ret ) {
+ //ignore the errors of autodelete
ret = glusterd_handle_snap_limit (dict, rsp_dict);
-
+ }
ret = 0;
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index cfebadc3e1d..712fb9687ca 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -10311,6 +10311,8 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
int ret = -1;
int config_command = 0;
uint64_t i = 0;
+ uint64_t hard_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ uint64_t soft_limit = GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT;
uint64_t value = 0;
uint64_t voldisplaycount = 0;
@@ -10329,9 +10331,13 @@ 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, "snap-max-hard-limit", &value);
+ ret = dict_get_uint64 (src,
+ GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
+ &hard_limit);
if (!ret) {
- ret = dict_set_uint64 (dst, "snap-max-hard-limit", value);
+ ret = dict_set_uint64 (dst,
+ GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
+ hard_limit);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to set snap_max_hard_limit");
@@ -10343,14 +10349,18 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
goto out;
}
- ret = dict_get_uint64 (src, "snap-max-soft-limit", &value);
+ ret = dict_get_uint64 (src,
+ GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
+ &soft_limit);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to get snap_max_soft_limit");
goto out;
}
- ret = dict_set_uint64 (dst, "snap-max-soft-limit", value);
+ ret = dict_set_uint64 (dst,
+ GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
+ soft_limit);
if (ret) {
gf_log ("", GF_LOG_ERROR,
"Unable to set snap_max_soft_limit");
@@ -13421,81 +13431,13 @@ out:
}
int32_t
-glusterd_check_and_set_config_limit (glusterd_conf_t *priv)
-{
- int32_t ret = -1;
- xlator_t *this = NULL;
- uint64_t hard_limit = 0;
- uint64_t soft_limit = 0;
- char *auto_delete = NULL;
-
- GF_ASSERT (priv);
- this = THIS;
- GF_ASSERT (this);
-
-
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
- &hard_limit);
- if (ret) {
- ret = dict_set_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
- GLUSTERD_SNAPS_MAX_HARD_LIMIT);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "store %s during glusterd init",
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
- }
- }
-
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
- &soft_limit);
- if (ret) {
- ret = dict_set_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
- GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "store %s during glusterd init",
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
- goto out;
- }
- }
-
- ret = dict_get_str (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
- &auto_delete);
- if (ret) {
- ret = dict_set_dynstr_with_alloc (priv->opts, "auto-delete",
- "disable");
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to store "
- "auto-delete value as disabled during "
- "glusterd init");
- goto out;
- }
- }
-
- ret = glusterd_store_options (this, priv->opts);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Unable to store version");
- return ret;
- }
-out:
- return ret;
-}
-
-int32_t
glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo, dict_t *dict)
{
int32_t ret = -1;
- uint64_t opt_max_hard = 0;
- uint64_t opt_max_soft = 0;
+ uint64_t opt_max_hard = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ uint64_t opt_max_soft = GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT;
uint64_t limit = 0;
- char *auto_delete = NULL;
+ int auto_delete = 0;
uint64_t effective_max_limit = 0;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
@@ -13508,44 +13450,29 @@ glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo, dict_t *dict)
priv = this->private;
GF_ASSERT (priv);
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
- &opt_max_hard);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s", GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
- goto out;
- }
+ /* config values snap-max-hard-limit and snap-max-soft-limit are
+ * optional and hence we are not erroring out if values are not
+ * present
+ */
+ gd_get_snap_conf_values_if_present (priv->opts, &opt_max_hard,
+ &opt_max_soft);
+
+ /* "auto-delete" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
+ auto_delete = dict_get_str_boolean (priv->opts,
+ GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
+ _gf_false);
if (volinfo->snap_max_hard_limit < opt_max_hard)
effective_max_limit = volinfo->snap_max_hard_limit;
else
effective_max_limit = opt_max_hard;
- ret = dict_get_uint64 (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
- &opt_max_soft);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "%s from opts dictionary",
- GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
- goto out;
- }
-
- ret = dict_get_str (priv->opts,
- GLUSTERD_STORE_KEY_SNAP_AUTO_DELETE,
- &auto_delete);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "auto-delete from options dictionary");
- goto out;
- }
-
limit = (opt_max_soft * effective_max_limit)/100;
- if (volinfo->snap_count >= limit &&
- (strcmp (auto_delete, "enable") != 0)) {
-
+ if (volinfo->snap_count >= limit && auto_delete != _gf_true) {
gf_log (this->name, GF_LOG_WARNING, "Soft-limit "
"(value = %"PRIu64") of volume %s is reached. "
"Snapshot creation is not possible once effective "
@@ -13561,6 +13488,47 @@ glusterd_is_snap_soft_limit_reached (glusterd_volinfo_t *volinfo, dict_t *dict)
}
goto out;
}
+ ret = 0;
out :
return ret;
}
+
+/* This function initializes the parameter sys_hard_limit,
+ * sys_soft_limit and auto_delete value to the value set
+ * in dictionary, If value is not present then it is
+ * initialized to default values. Hence this function does not
+ * return any values.
+ */
+void
+gd_get_snap_conf_values_if_present (dict_t *dict, uint64_t *sys_hard_limit,
+ uint64_t *sys_soft_limit)
+{
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ GF_ASSERT (dict);
+
+ /* "snap-max-hard-limit" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
+ if (dict_get_uint64 (dict, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
+ sys_hard_limit)) {
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present in"
+ "dictionary",
+ GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT);
+ }
+
+ /* "snap-max-soft-limit" might not be set by user explicitly,
+ * in that case it's better to consider the default value.
+ * Hence not erroring out if Key is not found.
+ */
+ if (dict_get_uint64 (dict, GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT,
+ sys_soft_limit)) {
+ gf_log (this->name, GF_LOG_DEBUG, "%s is not present in"
+ "dictionary",
+ GLUSTERD_STORE_KEY_SNAP_MAX_SOFT_LIMIT);
+ }
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index c277445ce61..dfff95f01a1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -899,4 +899,7 @@ glusterd_update_fstype (char *orig_brick_path,
int
glusterd_update_fs_label (glusterd_brickinfo_t *brickinfo);
+void
+gd_get_snap_conf_values_if_present (dict_t *opts, uint64_t *sys_hard_limit,
+ uint64_t *sys_soft_limit);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 5a6e55ef39e..f4ead6115e3 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -200,7 +200,7 @@ glusterd_options_init (xlator_t *this)
ret = glusterd_store_retrieve_options (this);
if (ret == 0) {
- goto set;
+ goto out;
}
ret = dict_set_str (priv->opts, GLUSTERD_GLOBAL_OPT_VERSION,
@@ -213,17 +213,6 @@ glusterd_options_init (xlator_t *this)
gf_log (this->name, GF_LOG_ERROR, "Unable to store version");
return ret;
}
-
-set:
- if (priv->op_version >= GD_OP_VERSION_3_6_0) {
- ret = glusterd_check_and_set_config_limit (priv);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed "
- "to set config limit in options");
- return ret;
- }
- }
-
out:
return 0;
}