summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-10-29 17:55:24 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 14:39:42 +0530
commit02157e7d4f31459f76cfb412099f49e851d76ebc (patch)
tree77176971a3eb32959f10766a95895fc04d34085b /xlators/mgmt/glusterd/src/glusterd-store.c
parent096b23f187d0b3ccbed25d8bd02723a61cc4da2d (diff)
mgmt/glusterd: store option to update only snap_list.info
Change-Id: I16b17ca60b5f9b34b7d238d8a3424a3b7a1dc435 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.c51
1 files changed, 51 insertions, 0 deletions
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
@@ -1385,6 +1385,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)
{
int fd = -1;