summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-01-16 05:15:57 +0530
committerSachin Pandit <spandit@redhat.com>2014-01-16 08:42:35 +0530
commit19a9d8bdfcf86dbe4008d548161ec3d43ee9e978 (patch)
tree03b6450b71c054a6f06dea5f1f5eee1918893da0
parent6cb4c91339e5e6452bbb3de6d5f2e75c50d687bc (diff)
glusterd/snapshot : Making snap time persistent.
Change-Id: I2d07717ee01751e481571ce420b0f84711ea9597 Signed-off-by: Sachin Pandit <spandit@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c72
1 files changed, 61 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 16cafdc..8468231 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);