From b831d59836547b7d5d21afb38af2629036864c57 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 31 Oct 2013 09:51:21 +0530 Subject: mgmt/glusterd: store for snapshot description Change-Id: I0ba50ba2963edf8d890a2dc78d48d42db7f71ae2 Signed-off-by: shishir gowda --- xlators/mgmt/glusterd/src/glusterd-store.c | 37 ++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index f24b319c9..7a0b7fc90 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1166,8 +1166,8 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo) GF_ASSERT (volinfo); if (volinfo->rebal.defrag_cmd == GF_DEFRAG_CMD_STATUS) { - ret = 0; - goto out; + ret = 0; + goto out; } snprintf (buf, sizeof (buf), "%d", volinfo->rebal.defrag_cmd); @@ -1223,6 +1223,16 @@ glusterd_store_snap_list_write (int fd, glusterd_snap_t *snap, uint64_t count) ret = gf_store_save_value (fd, key, buf); if (ret) goto out; + + if (snap->description) { + snprintf (buf, sizeof (buf), "%s\n", snap->description); + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_DESC, count); + ret = gf_store_save_value (fd, key, buf); + if (ret) + goto out; + } + out: gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); return ret; @@ -1257,6 +1267,14 @@ glusterd_store_snap_cg_write (int fd, glusterd_snap_cg_t *cg) ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_STATUS, buf); if (ret) goto out; + + if (cg->description) { + snprintf (buf, sizeof (buf), "%s\n", cg->description); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_DESC, + buf); + if (ret) + goto out; + } while (count < cg->volume_count) { ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_ID, uuid_utoa (cg->volumes[count].volume_id)); @@ -2998,6 +3016,9 @@ glusterd_store_retrieve_snap_cg (char *cg_name, glusterd_conf_t *priv) } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_CG_ID, sizeof (*key))) { uuid_parse (value, cg->cg_id); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_DESC, + sizeof (*key))) { + cg->description = gf_strdup (value); } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_ID, sizeof (*key))) { uuid_parse (key, vol_id); @@ -3131,6 +3152,18 @@ glusterd_store_retrieve_snap_list (char *volname) GF_FREE (value); value = NULL; + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_DESC, count); + ret = gf_store_retrieve_value (shandle, key, &value); + if (!ret) { + snap->description = value; + value = NULL; + } else { + ret = 0; + gf_log (THIS->name, GF_LOG_TRACE, "No desc for %s", + snap->snap_name); + } + ret = glusterd_add_snap (volinfo, snap); if (ret) { gf_log (THIS->name, GF_LOG_ERROR, "Failed to add %s to" -- cgit