From 02157e7d4f31459f76cfb412099f49e851d76ebc Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Tue, 29 Oct 2013 17:55:24 +0530 Subject: mgmt/glusterd: store option to update only snap_list.info Change-Id: I16b17ca60b5f9b34b7d238d8a3424a3b7a1dc435 Signed-off-by: shishir gowda --- cli/src/cli-cmd-parser.c | 1 - xlators/mgmt/glusterd/src/glusterd-store.c | 51 ++++++++++++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd-store.h | 2 ++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index b7078ff28..352a2cc9b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3166,7 +3166,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 bbff2f4bb..70c50803f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1384,6 +1384,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) { diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index ece2003d8..4244d2e54 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -145,4 +145,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 -- cgit