diff options
author | shishir gowda <sgowda@redhat.com> | 2013-10-29 17:55:24 +0530 |
---|---|---|
committer | shishir gowda <sgowda@redhat.com> | 2013-10-29 17:55:54 +0530 |
commit | 5ce3051ca7bfb86e8ab1784c85d4064d5042c491 (patch) | |
tree | e9c1773d60b2c6a6f053ba475e2d685f633aef7e | |
parent | c722df970f7e3b576a9432907b62b7de03265b0f (diff) |
mgmt/glusterd: store option to update only snap_list.info
Change-Id: I16b17ca60b5f9b34b7d238d8a3424a3b7a1dc435
Signed-off-by: shishir gowda <sgowda@redhat.com>
-rw-r--r-- | cli/src/cli-cmd-parser.c | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 51 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.h | 2 |
3 files changed, 53 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 8b77c2463..5aa8545a3 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3069,7 +3069,6 @@ out: int32_t cli_snap_config_parse (const char **words, int wordcount, dict_t *options) { - dict_t *dict = NULL; char *volname = NULL; int ret = -1; char *key = NULL; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 26351944f..83c2a2fba 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1381,6 +1381,57 @@ unlock: } int32_t +glusterd_store_perform_snap_list_store (glusterd_volinfo_t *volinfo) +{ + int fd = -1; + int32_t ret = -1; + glusterd_snap_t *entry = NULL; + glusterd_snap_t *tmp = NULL; + uint64_t count = 0; + char buf[PATH_MAX] = {0,}; + + GF_ASSERT (volinfo); + + ret = glusterd_store_create_snap_list_sh_on_absence (volinfo); + if (ret) + goto out; + fd = gf_store_mkstemp (volinfo->snap_list_shandle); + if (fd <= 0) { + ret = -1; + goto out; + } + + LOCK (&volinfo->lock); + { + list_for_each_entry_safe (entry, tmp, &volinfo->snaps, + snap_list) { + ret = glusterd_store_snap_list_write (fd, entry, count); + if (ret) + goto unlock; + count++; + } + snprintf (buf, sizeof(buf), "%"PRIu64, count); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_COUNT, + buf); + if (ret) + goto unlock; + } +unlock: + UNLOCK (&volinfo->lock); + + ret = gf_store_rename_tmppath (volinfo->snap_list_shandle); + if (ret) + goto out; + +out: + if (ret && (fd > 0)) + gf_store_unlink_tmppath (volinfo->snap_list_shandle); + if (fd > 0) + close (fd); + gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} +int32_t glusterd_store_perform_snap_store (glusterd_volinfo_t *volinfo) { int fd = -1; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index dbae35760..5772809d7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -143,4 +143,6 @@ int32_t glusterd_store_perform_volume_store (glusterd_volinfo_t *volinfo); int32_t glusterd_store_perform_snap_store (glusterd_volinfo_t *volinfo); +int32_t +glusterd_store_perform_snap_list_store (glusterd_volinfo_t *volinfo); #endif |