summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-12-18 01:01:47 +0000
committerAvra Sengupta <asengupt@redhat.com>2014-01-07 15:26:25 +0530
commit4afa88d6cc39be11f122489900af07b57a50fcc4 (patch)
treed7a829bc7be6e98a2979ff35410ddccd674395bb
parenta783136347ed2716f3f0ee0ca284f291f4e29652 (diff)
glusterd/snapshot: Defining snap-max-soft-limit as a percentage of snap-max-hard-limit.
This patch also prohibits configuration of snap-max-hard-limit and snap-max-soft-limit for snap volumes. Also displaying the snapshot configs by reading data only from local node, as all config data will be in sync across the cluster. Change-Id: I635b925c02ed5b108cd10c7193b154ad82d5afad BUG: 1043792 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c45
-rw-r--r--cli/src/cli-cmd-snapshot.c2
-rw-r--r--cli/src/cli-rpc-ops.c104
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c320
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c23
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c80
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h5
7 files changed, 390 insertions, 189 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 2762f0cf4..59e951636 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -3203,8 +3203,11 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
GF_ASSERT (options);
GF_ASSERT (state);
- if ((wordcount < 3) || (wordcount > 5))
+ if ((wordcount != 3) && (wordcount != 5)) {
+ gf_log ("", GF_LOG_ERROR,
+ "Invalid wordcount(%d)", wordcount);
goto out;
+ }
volname = (char *)words[2];
@@ -3226,11 +3229,19 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
}
/* snapshot config <volname | all> [snap-max-hard-limit <count>
- * | snap-max-soft-limit <count>] */
+ * | snap-max-soft-limit <percent>] */
if (wordcount > 3) {
key = (char *) words[3];
value = (char *) words[4];
+ } else {
+ ret = dict_set_int32 (options, "config-command",
+ GF_SNAP_CONFIG_DISPLAY);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to set config-command");
+ ret = -1;
+ goto out;
+ }
}
if (key) {
@@ -3264,15 +3275,7 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
}
}
- if (!value) {
- ret = dict_set_int32 (options, "config-command",
- GF_SNAP_CONFIG_DISPLAY);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set config-command");
- ret = -1;
- goto out;
- }
- } else {
+ if (value) {
ret = dict_set_int32 (options, "config-command",
GF_SNAP_CONFIG_TYPE_SET);
if (ret) {
@@ -3288,17 +3291,18 @@ cli_snap_config_parse (const char **words, int wordcount, dict_t *options,
"Failed to set %s.", key);
goto out;
}
- }
- /* Ask question only for a set op */
- if (value && conf_vals && conf_vals->question) {
- answer = cli_cmd_get_confirmation (state,
- conf_vals->question);
- if (GF_ANSWER_NO == answer) {
- ret = -1;
- goto out;
+ /* Ask question only for a set op */
+ if (conf_vals->question) {
+ answer = cli_cmd_get_confirmation (state,
+ conf_vals->question);
+ if (GF_ANSWER_NO == answer) {
+ ret = -1;
+ goto out;
+ }
}
}
+
out:
return ret;
}
@@ -3619,7 +3623,8 @@ cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options,
}
case GF_SNAP_OPTION_TYPE_CONFIG:
{
- /* snapshot config <volname | all> [snap-max-hard-limit <count> | snap-max-soft-limit <count>] */
+ /* snapshot config <volname | all> [snap-max-hard-limit <count> |
+ * snap-max-soft-limit <percent>] */
ret = cli_snap_config_parse (words, wordcount, dict,
state);
if (ret) {
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
index 556278931..6d31dc2d5 100644
--- a/cli/src/cli-cmd-snapshot.c
+++ b/cli/src/cli-cmd-snapshot.c
@@ -90,7 +90,7 @@ struct cli_cmd snapshot_cmds[] = {
cli_cmd_snapshot_cbk,
"Snapshot List."
},
- {"snapshot config < volname | all > [ snap-max-hard-limit <count> | snap-max-soft-limit <count> ]",
+ {"snapshot config < volname | all > [ snap-max-hard-limit <count> | snap-max-soft-limit <percent> ]",
cli_cmd_snapshot_cbk,
"Snapshot Config."
},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 926c01b70..6ee039fbc 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7898,11 +7898,15 @@ out:
int
cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
{
+ char buf[PATH_MAX] = "";
char *volname = NULL;
char *key = NULL;
int ret = -1;
int config_command = 0;
uint64_t value = 0;
+ uint64_t soft_limit = 0;
+ uint64_t i = 0;
+ uint64_t voldisplaycount = 0;
GF_ASSERT (dict);
GF_ASSERT (rsp);
@@ -7917,8 +7921,7 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
ret = dict_get_int32 (dict, "config-command", &config_command);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch config type");
- ret = -1;
+ gf_log("", GF_LOG_ERROR, "Could not fetch config type");
goto out;
}
@@ -7926,7 +7929,6 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
if (ret) {
gf_log("", GF_LOG_ERROR, "Could not fetch "
"volname");
- ret = -1;
goto out;
}
@@ -7935,8 +7937,11 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
}
ret = dict_get_str (dict, "config-key", &key);
- if (ret)
- gf_log("", GF_LOG_ERROR, "No config-key set");
+ if (ret && config_command != GF_SNAP_CONFIG_DISPLAY) {
+ gf_log(THIS->name, GF_LOG_ERROR,
+ "Could not fetch config-key");
+ goto out;
+ }
switch (config_command) {
case GF_SNAP_CONFIG_TYPE_SET:
@@ -7945,49 +7950,74 @@ cli_snapshot_config_display (dict_t *dict, gf_cli_rsp *rsp)
break;
case GF_SNAP_CONFIG_DISPLAY :
- if (!key) {
- /* For all options */
- ret = dict_get_uint64 (dict, "snap-max-hard-limit",
- &value);
+ cli_out ("\nSnapshot System Configuration:");
+ ret = dict_get_uint64 (dict, "snap-max-hard-limit",
+ &value);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ "snap_max_hard_limit for %s", volname);
+ ret = -1;
+ goto out;
+ }
+ cli_out ("snap-max-hard-limit : %"PRIu64, value);
+
+ ret = dict_get_uint64 (dict, "snap-max-soft-limit",
+ &soft_limit);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ "snap-max-soft-limit for %s", volname);
+ ret = -1;
+ goto out;
+ }
+ cli_out ("snap-max-soft-limit : %"PRIu64"%%\n", soft_limit);
+
+ cli_out ("Snapshot Volume Configuration:");
+
+ ret = dict_get_uint64 (dict, "voldisplaycount",
+ &voldisplaycount);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch voldisplaycount");
+ ret = -1;
+ goto out;
+ }
+
+ for (i = 0; i < voldisplaycount; i++) {
+ snprintf (buf, sizeof(buf), "volume%ld-volname", i);
+ ret = dict_get_str (dict, buf, &volname);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "snap_max_hard_limit for %s", volname);
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
ret = -1;
goto out;
}
- cli_out ("snapshot config: snap-max-hard-limit for "
- "%s set to %"PRIu64,
- volname, value);
+ cli_out ("\nVolume : %s", volname);
- ret = dict_get_uint64 (dict, "snap-max-soft-limit",
- &value);
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-hard-limit", i);
+ ret = dict_get_uint64 (dict, buf, &value);
if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "snap-max-soft-limit for %s", volname);
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
ret = -1;
goto out;
}
- cli_out ("snapshot config: snap-max-soft-limit for "
- "%s set to %"PRIu64,
- volname, value);
- } else {
- if ((!strncmp (key, "snap-max-hard-limit", strlen(key))) ||
- (!strncmp (key, "snap-max-soft-limit", strlen(key)))) {
- ret = dict_get_uint64 (dict, key, &value);
- if (ret) {
- gf_log("", GF_LOG_DEBUG, "Could not fetch "
- "%s for %s", key, volname);
- ret = -1;
- goto out;
- }
- cli_out ("snapshot config: %s for "
- "%s set to %"PRIu64, key,
- volname, value);
+ cli_out ("snap-max-hard-limit : %"PRIu64, value);
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-soft-limit-value", i);
+ ret = dict_get_uint64 (dict, buf, &value);
+ if (ret) {
+ gf_log("", GF_LOG_ERROR, "Could not fetch "
+ " %s", buf);
+ ret = -1;
+ goto out;
}
- }
- break;
+ cli_out ("snap-max-soft-limit : %"PRIu64" (%"PRIu64"%%)",
+ value, soft_limit);
+ }
+ break;
default :
- break;
+ break;
}
ret = 0;
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index cd9ed3f23..1f6930718 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -395,20 +395,21 @@ out:
}
int
-snap_max_limits_validate (dict_t *dict, char *key,
- char **op_errstr)
+snap_max_limits_validate (dict_t *dict, char *volname, char *key,
+ uint64_t value, 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;
- uint64_t max_limit = GLUSTERD_SNAPS_MAX_LIMIT;
+ uint64_t max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
xlator_t *this = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (dict);
+ GF_ASSERT (volname);
GF_ASSERT (key);
GF_ASSERT (op_errstr);
@@ -416,13 +417,31 @@ snap_max_limits_validate (dict_t *dict, char *key,
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;
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (!ret) {
+ if (volinfo->is_snap_volume) {
+ ret = -1;
+ snprintf (err_str, PATH_MAX,"%s is a snap volume. "
+ "Configuring %s for a snap volume is "
+ "prohibited.", volname, key);
+ goto out;
+ }
+ }
+
+ if (!strcmp (key, "snap-max-hard-limit")) {
+ max_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
+ if ((max_limit > conf->snap_max_hard_limit) &&
+ (strncmp (volname, "all", strlen(volname))))
+ max_limit = conf->snap_max_hard_limit;
+ } else {
+ max_limit = GLUSTERD_SNAPS_MAX_SOFT_LIMIT_PERCENT;
+ if (strncmp (volname, "all", strlen(volname))) {
+ ret = -1;
+ snprintf (err_str, PATH_MAX, "%s is not configurable "
+ "for individual volumes. Configure %s for "
+ "system.", key, key);
+ goto out;
+ }
}
if ((value < 0) ||
@@ -431,13 +450,15 @@ snap_max_limits_validate (dict_t *dict, char *key,
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:
+ if (ret) {
+ *op_errstr = gf_strdup (err_str);
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ }
return ret;
}
@@ -452,6 +473,7 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
int config_command = 0;
char err_str[PATH_MAX] = {0,};
glusterd_conf_t *conf = NULL;
+ uint64_t value = 0;
this = THIS;
@@ -471,34 +493,27 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
}
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)))) {
- /* 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_DISPLAY:
- ret = dict_get_str (dict, "volname", &volname);
+ if (!ret) {
+ ret = dict_get_uint64 (dict, key, &value);
if (ret) {
snprintf (err_str, PATH_MAX,"Failed to get the"
- " volume name");
+ " value for %s", key);
*op_errstr = gf_strdup (err_str);
gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
goto out;
}
- if (!strncmp (volname, "all", strlen(volname))) {
- ret = 0;
- 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;
+ }
+
+ if (strncmp (volname, "all", strlen(volname))) {
ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
snprintf (err_str, PATH_MAX,"Volume %s does not exist.",
@@ -507,7 +522,23 @@ glusterd_snapshot_config_prevalidate (dict_t *dict, char **op_errstr)
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-limits */
+ ret = snap_max_limits_validate (dict, volname,
+ key, value, op_errstr);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "%s validation failed.", key);
+ goto out;
+ }
+ }
break;
+
default:
break;
}
@@ -4094,14 +4125,13 @@ out:
}
int
-snap_max_limits_set_commit (dict_t *dict, char *key, char *volname,
- char **op_errstr)
+snap_max_hard_limit_set_commit (dict_t *dict, char *key, uint64_t value,
+ 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;
@@ -4116,20 +4146,10 @@ snap_max_limits_set_commit (dict_t *dict, char *key, char *volname,
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);
- goto out;
- }
-
/* 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;
+ conf->snap_max_hard_limit = value;
ret = glusterd_store_global_info (this);
if (ret) {
@@ -4146,10 +4166,7 @@ snap_max_limits_set_commit (dict_t *dict, char *key, char *volname,
goto out;
}
- if (!strncmp (key, "snap-max-hard-limit", strlen(key)))
- volinfo->snap_max_hard_limit = value;
- else
- volinfo->snap_max_soft_limit = value;
+ volinfo->snap_max_hard_limit = value;
ret = glusterd_store_volinfo (volinfo,
GLUSTERD_VOLINFO_VER_AC_INCREMENT);
@@ -4166,26 +4183,28 @@ out:
*op_errstr = gf_strdup (err_str);
gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
}
-
return ret;
}
int
-snap_max_limits_display_commit (dict_t *rsp_dict, char *key, char *volname,
+snap_max_limits_display_commit (dict_t *rsp_dict, char *volname,
char **op_errstr)
{
char err_str[PATH_MAX] = "";
+ char buf[PATH_MAX] = "";
glusterd_conf_t *conf = NULL;
glusterd_volinfo_t *volinfo = NULL;
int ret = -1;
- uint64_t value = 0;
+ 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;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (rsp_dict);
- GF_ASSERT (key);
GF_ASSERT (volname);
GF_ASSERT (op_errstr);
@@ -4195,38 +4214,122 @@ snap_max_limits_display_commit (dict_t *rsp_dict, char *key, char *volname,
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;
+ list_for_each_entry (volinfo, &conf->volumes, vol_list) {
+ if (volinfo->is_snap_volume == _gf_true)
+ continue;
+ snap_max_limit = volinfo->snap_max_hard_limit;
+ if (snap_max_limit > conf->snap_max_hard_limit)
+ active_hard_limit = conf->snap_max_hard_limit;
+ else
+ active_hard_limit = snap_max_limit;
+ soft_limit_value = (active_hard_limit *
+ conf->snap_max_soft_limit) / 100;
+
+ snprintf (buf, sizeof(buf), "volume%ld-volname", count);
+ ret = dict_set_str (rsp_dict, buf, volinfo->volname);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-hard-limit", count);
+ ret = dict_set_uint64 (rsp_dict, buf, snap_max_limit);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-soft-limit-value", count);
+ ret = dict_set_uint64 (rsp_dict, buf, soft_limit_value);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+ count++;
+ }
+
+ ret = dict_set_uint64 (rsp_dict, "voldisplaycount", count);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set voldisplaycount");
+ goto out;
+ }
} else {
- /* For one volume */
+ /* 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;
}
- if (!strncmp (key, "snap-max-hard-limit", strlen(key)))
- value = volinfo->snap_max_hard_limit;
- else
- value = volinfo->snap_max_soft_limit;
+ snap_max_limit = volinfo->snap_max_hard_limit;
+ soft_limit_value = (volinfo->snap_max_hard_limit *
+ conf->snap_max_soft_limit) / 100;
+
+ snprintf (buf, sizeof(buf), "volume%ld-volname", count);
+ ret = dict_set_str (rsp_dict, buf, volinfo->volname);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-hard-limit", count);
+ ret = dict_set_uint64 (rsp_dict, buf, snap_max_limit);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-soft-limit-value", count);
+ ret = dict_set_uint64 (rsp_dict, buf, soft_limit_value);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set %s", buf);
+ goto out;
+ }
+ count++;
+
+ ret = dict_set_uint64 (rsp_dict, "voldisplaycount", count);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set voldisplaycount");
+ goto out;
+ }
+
}
- ret = dict_set_uint64 (rsp_dict, key, value);
+ ret = dict_set_uint64 (rsp_dict, "snap-max-hard-limit",
+ conf->snap_max_hard_limit);
if (ret) {
- 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);
+ snprintf (err_str, PATH_MAX,
+ "Failed to set sys-snap-max-hard-limit ");
+ goto out;
+ }
+
+ ret = dict_set_uint64 (rsp_dict, "snap-max-soft-limit",
+ conf->snap_max_soft_limit);
+ if (ret) {
+ snprintf (err_str, PATH_MAX,
+ "Failed to set sys-snap-max-hard-limit ");
goto out;
}
ret = 0;
out:
+ if (ret) {
+ *op_errstr = gf_strdup (err_str);
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ }
return ret;
}
@@ -4241,12 +4344,12 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
char err_str[PATH_MAX] = {0,};
glusterd_conf_t *conf = NULL;
int config_command = 0;
+ uint64_t value = 0;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (dict);
- GF_ASSERT (rsp_dict);
GF_ASSERT (op_errstr);
conf = this->private;
@@ -4270,51 +4373,56 @@ glusterd_snapshot_config_commit (dict_t *dict, char **op_errstr,
}
ret = dict_get_str (dict, "config-key", &key);
+ if (!ret) {
+ 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;
+ }
+ }
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 (!strncmp (key, "snap-max-hard-limit", strlen(key))) {
+ /* Commit ops for snap-max-hard-limit */
+ ret = snap_max_hard_limit_set_commit (dict, key, value,
+ volname, op_errstr);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"%s set commit failed.", key);
goto out;
}
- }
- break;
+ } else if (!strncmp (key, "snap-max-soft-limit", strlen(key))) {
+ /* For system limit */
+ conf->snap_max_soft_limit = value;
- 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);
+ ret = glusterd_store_global_info (this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "snap-max-hard-limit "
- "display commit failed.");
+ snprintf (err_str, PATH_MAX,"Failed to store %s "
+ "for system", key);
+ *op_errstr = gf_strdup (err_str);
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
goto out;
}
+ }
+ break;
- 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;
- }
+ case GF_SNAP_CONFIG_DISPLAY:
+ /* Reading data from local node only */
+ if (!is_origin_glusterd (dict)) {
+ ret = 0;
+ break;
+ }
+
+ ret = snap_max_limits_display_commit (rsp_dict, volname, op_errstr);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "snap-max-limit "
+ "display commit failed.");
+ goto out;
}
break;
default:
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index f37ad9bec..1a00aac88 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -712,15 +712,6 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
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)
gf_log (THIS->name, GF_LOG_ERROR, "Unable to write volume "
@@ -2228,7 +2219,6 @@ glusterd_restore_op_version (xlator_t *this)
glusterd_conf_t *conf = NULL;
int ret = 0;
int op_version = 0;
- int snap_max_limit = GLUSTERD_SNAPS_MAX_LIMIT;
conf = this->private;
@@ -2238,8 +2228,9 @@ glusterd_restore_op_version (xlator_t *this)
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;
+ "setting it to default value(%d)",
+ GLUSTERD_SNAPS_MAX_HARD_LIMIT);
+ conf->snap_max_hard_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
}
ret = glusterd_retrieve_sys_snap_max_limit (this,
@@ -2248,8 +2239,9 @@ glusterd_restore_op_version (xlator_t *this)
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;
+ "setting it to default value(%d)",
+ GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT);
+ conf->snap_max_soft_limit = GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT;
}
ret = glusterd_retrieve_op_version (this, &op_version);
@@ -2799,9 +2791,6 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
} 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-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 6947facbd..6e8ef080c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -463,8 +463,7 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
snprintf (new_volinfo->parent_volname, GLUSTERD_MAX_VOLUME_NAME, "N/A");
- new_volinfo->snap_max_hard_limit = GLUSTERD_SNAPS_MAX_LIMIT;
- new_volinfo->snap_max_soft_limit = GLUSTERD_SNAPS_MAX_LIMIT;
+ new_volinfo->snap_max_hard_limit = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
new_volinfo->xl = THIS;
@@ -7855,9 +7854,13 @@ out:
int
glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
{
+ char buf[PATH_MAX] = "";
+ char *volname = NULL;
int ret = -1;
- uint64_t value = 0;
int config_command = 0;
+ uint64_t i = 0;
+ uint64_t value = 0;
+ uint64_t voldisplaycount = 0;
if (!dst || !src) {
gf_log ("", GF_LOG_ERROR, "Source or Destination "
@@ -7881,13 +7884,78 @@ glusterd_snap_config_use_rsp_dict (dict_t *dst, dict_t *src)
gf_log ("", GF_LOG_ERROR, "Unable to set snap_max_hard_limit");
goto out;
}
+ } else {
+ /* Received dummy response from other nodes */
+ ret = 0;
+ 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 get snap_max_soft_limit");
+ goto out;
+ }
+
+ 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;
+ }
+
+ ret = dict_get_uint64 (src, "voldisplaycount", &voldisplaycount);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get voldisplaycount");
+ goto out;
+ }
+
+ ret = dict_set_uint64 (dst, "voldisplaycount", voldisplaycount);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to set voldisplaycount");
+ goto out;
+ }
+
+ for (i = 0; i < voldisplaycount; i++) {
+ snprintf (buf, sizeof(buf), "volume%ld-volname", i);
+ ret = dict_get_str (src, buf, &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to set snap_max_soft_limit");
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to get %s", buf);
+ goto out;
+ }
+ ret = dict_set_str (dst, buf, volname);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-hard-limit", i);
+ ret = dict_get_uint64 (src, buf, &value);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to get %s", buf);
+ goto out;
+ }
+ ret = dict_set_uint64 (dst, buf, value);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to set %s", buf);
+ goto out;
+ }
+
+ snprintf (buf, sizeof(buf),
+ "volume%ld-snap-max-soft-limit-value", i);
+ ret = dict_get_uint64 (src, buf, &value);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to get %s", buf);
+ goto out;
+ }
+ ret = dict_set_uint64 (dst, buf, value);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Unable to set %s", buf);
goto out;
}
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 343e6fe4d..f14b6737b 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -52,7 +52,9 @@
"S56glusterd-geo-rep-create-post.sh"
-#define GLUSTERD_SNAPS_MAX_LIMIT 256
+#define GLUSTERD_SNAPS_MAX_HARD_LIMIT 256
+#define GLUSTERD_SNAPS_DEF_SOFT_LIMIT_PERCENT 90
+#define GLUSTERD_SNAPS_MAX_SOFT_LIMIT_PERCENT 100
#define GLUSTERD_SERVER_QUORUM "server"
#define FMTSTR_CHECK_VOL_EXISTS "Volume %s does not exist"
@@ -287,7 +289,6 @@ struct glusterd_volinfo_ {
int brick_count;
uint64_t snap_count;
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;