summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c72
1 files changed, 71 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 70c50803f..7739f2f37 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1680,7 +1680,11 @@ glusterd_store_volinfo_atomic_update (glusterd_volinfo_t *volinfo)
ret = gf_store_rename_tmppath (volinfo->shandle);
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,
+ buf);
+ if (ret)
+ goto out;
out:
if (ret)
gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename "
@@ -1970,6 +1974,7 @@ glusterd_store_global_info (xlator_t *this)
char path[PATH_MAX] = {0,};
gf_store_handle_t *handle = NULL;
char *uuid_str = NULL;
+ char buf[256] = {0, };
conf = this->private;
@@ -2022,6 +2027,14 @@ glusterd_store_global_info (xlator_t *this)
goto out;
}
+ snprintf (buf, sizeof (buf), "%"PRIu64, conf->snap_max_limit);
+ ret = gf_store_save_value (handle->fd,
+ GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT, buf);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Storing snap-max-limit failed ret = %d", ret);
+ goto out;
+ }
ret = gf_store_rename_tmppath (handle);
out:
if (ret && (handle->fd > 0))
@@ -2093,6 +2106,57 @@ out:
return ret;
}
+int
+glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit)
+{
+ char *limit_str = NULL;
+ glusterd_conf_t *priv = NULL;
+ int ret = -1;
+ uint64_t tmp_limit = 0;
+ char *tmp = NULL;
+ char path[PATH_MAX] = {0,};
+ gf_store_handle_t *handle = NULL;
+
+ priv = this->private;
+
+ if (!priv->handle) {
+ snprintf (path, PATH_MAX, "%s/%s", priv->workdir,
+ GLUSTERD_INFO_FILE);
+ ret = gf_store_handle_retrieve (path, &handle);
+
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Unable to get store "
+ "handle!");
+ goto out;
+ }
+
+ priv->handle = handle;
+ }
+
+ ret = gf_store_retrieve_value (priv->handle,
+ GLUSTERD_STORE_KEY_SNAP_MAX_LIMIT,
+ &limit_str);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "No previous snap limit present");
+ goto out;
+ }
+
+ tmp_limit = strtoul (limit_str, &tmp, 10);
+ if ((tmp_limit <= 0) || (tmp && strlen (tmp) > 1)) {
+ gf_log (this->name, GF_LOG_WARNING, "invalid version number");
+ goto out;
+ }
+
+ *limit = tmp_limit;
+
+ ret = 0;
+out:
+ if (limit_str)
+ GF_FREE (limit_str);
+
+ return ret;
+}
static int
glusterd_restore_op_version (xlator_t *this)
{
@@ -2140,6 +2204,9 @@ 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;
@@ -2645,6 +2712,9 @@ 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 (is_key_glusterd_hooks_friendly (key)) {