summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-10-31 09:51:21 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 14:45:14 +0530
commitb831d59836547b7d5d21afb38af2629036864c57 (patch)
tree5f633ea70e47636eec02d46e9b5486814ac98bde /xlators/mgmt/glusterd/src/glusterd-store.c
parent8537ebec13e6a84568f75e35851e43a76c70abaf (diff)
mgmt/glusterd: store for snapshot description
Change-Id: I0ba50ba2963edf8d890a2dc78d48d42db7f71ae2 Signed-off-by: shishir gowda <sgowda@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c37
1 files changed, 35 insertions, 2 deletions
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"