From 19a9d8bdfcf86dbe4008d548161ec3d43ee9e978 Mon Sep 17 00:00:00 2001 From: Sachin Pandit Date: Thu, 16 Jan 2014 05:15:57 +0530 Subject: glusterd/snapshot : Making snap time persistent. Change-Id: I2d07717ee01751e481571ce420b0f84711ea9597 Signed-off-by: Sachin Pandit --- xlators/mgmt/glusterd/src/glusterd-store.c | 72 +++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 11 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 16cafdc8e..84682316d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1226,15 +1226,19 @@ glusterd_store_snap_list_write (int fd, glusterd_snap_t *snap, uint64_t count) snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_NAME, count); ret = gf_store_save_value (fd, key, snap->snap_name); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to store snap-name of " + "snap %s", snap->snap_name); goto out; + } if ( strlen(snap->cg_name) > 0 ) { snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_CG_NAME, count); ret = gf_store_save_value (fd, key, snap->cg_name); if (ret) { - gf_log ("", GF_LOG_ERROR, "Failed to store cg_name"); + gf_log ("", GF_LOG_ERROR, "Failed to store cg_name " + "of snap %s", snap->snap_name); goto out; } } @@ -1242,29 +1246,50 @@ glusterd_store_snap_list_write (int fd, glusterd_snap_t *snap, uint64_t count) snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_ID, count); ret = gf_store_save_value (fd, key, uuid_utoa(snap->snap_id)); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to store snap-ID of " + "snap %s", snap->snap_name); goto out; + } snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_CG_ID, count); ret = gf_store_save_value (fd, key, uuid_utoa(snap->cg_id)); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to store CG-ID of snap %s", + snap->snap_name); goto out; - + } snprintf (buf, sizeof (buf), "%d", snap->snap_status); snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_STATUS, count); ret = gf_store_save_value (fd, key, buf); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to store snap-status of " + "snap %s", snap->snap_name); goto out; + } if (snap->description) { snprintf (buf, sizeof (buf), "%s", snap->description); snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_DESC, count); ret = gf_store_save_value (fd, key, buf); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to store snap-description " + "of snap %s", snap->snap_name); goto out; + } + } + + snprintf (buf, sizeof (buf), "%ld", snap->time_stamp); + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_TIMESTAMP, count); + ret = gf_store_save_value (fd, key, buf); + if (ret){ + gf_log ("", GF_LOG_ERROR, "Failed to store snap-time of %s", + snap->snap_name); + goto out; } out: @@ -3262,8 +3287,11 @@ glusterd_store_retrieve_snap_list (char *volname) snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_NAME, count); ret = gf_store_retrieve_value (shandle, key, &value); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to retrieve " + "snap name"); goto out; + } strncpy (snap->snap_name, value, strlen(value)); GF_FREE (value); @@ -3273,8 +3301,11 @@ glusterd_store_retrieve_snap_list (char *volname) GLUSTERD_STORE_KEY_SNAP_STATUS, count); ret = gf_store_retrieve_value (shandle, key, &value); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to retrieve " + "snap-status of snap %s", snap->snap_name); goto out; + } snap->snap_status = atoi (value); GF_FREE (value); @@ -3283,18 +3314,37 @@ glusterd_store_retrieve_snap_list (char *volname) snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_ID, count); ret = gf_store_retrieve_value (shandle, key, &value); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to retrieve " + "snap-ID of snap %s", snap->snap_name); goto out; + } uuid_parse (value, snap->snap_id); GF_FREE (value); value = NULL; + snprintf (key, sizeof (key), "%s-%"PRIu64, + GLUSTERD_STORE_KEY_SNAP_TIMESTAMP, count); + ret = gf_store_retrieve_value (shandle, key, &value); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to retrieve" + " Time-stamp of snap %s", snap->snap_name); + goto out; + } + + snap->time_stamp = atoi (value); + GF_FREE (value); + value = NULL; + snprintf (key, sizeof (key), "%s-%"PRIu64, GLUSTERD_STORE_KEY_SNAP_CG_ID, count); ret = gf_store_retrieve_value (shandle, key, &value); - if (ret) + if (ret) { + gf_log ("", GF_LOG_ERROR, "Failed to retrieve" + " snap CG-ID of snap %s", snap->snap_name); goto out; + } uuid_parse (value, snap->cg_id); GF_FREE (value); -- cgit