diff options
author | Avra Sengupta <asengupt@redhat.com> | 2013-12-16 03:09:58 +0000 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2014-01-06 15:59:43 +0530 |
commit | 5d57885a1b63ba89406c0dbd02bb254eacf531bd (patch) | |
tree | 81675d15f4d450ac80c2b67cf1e4b2e68a5405b2 /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | 31ed53e48a2066ba344c257856384ad105803281 (diff) |
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 <asengupt@redhat.com>
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 85 |
1 files changed, 67 insertions, 18 deletions
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); |