summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
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 26351944f..83c2a2fba 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1381,6 +1381,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;