summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2013-10-16 18:18:04 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 12:38:59 +0530
commitcc4fa72926f9ac517365d91ae6144530dc67c001 (patch)
tree9da64c3ceeda354726be21c6df118f2ce6616b5c /xlators/mgmt/glusterd/src/glusterd-store.c
parentd15ad38e8623f510fb1e121a8ff0d845a99238e4 (diff)
mgmt/glusterd: snapshot create command
This is still a work in progress. As of now, these things are done: * Take the snapshot of the backend brick * Create the new volume for the snapshot * Create the brick and the client volfiles * Store the snapshot related info in /var/lib/glusterd * Create the snap object representing the snapshot TODO: Start the brick processes for the snapshot Change-Id: I26fbb0f8e5cf004d4c1dbca51819bab1cd1bac15 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 97c8a5d4f..50e680064 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -46,7 +46,7 @@
#include <dirent.h>
void
-glusterd_replace_slash_with_hipen (char *str)
+glusterd_replace_slash_with_hyphen (char *str)
{
char *ptr = NULL;
@@ -105,7 +105,7 @@ glusterd_store_key_vol_brick_set (glusterd_brickinfo_t *brickinfo,
GF_ASSERT (len >= PATH_MAX);
snprintf (key_vol_brick, len, "%s", brickinfo->path);
- glusterd_replace_slash_with_hipen (key_vol_brick);
+ glusterd_replace_slash_with_hyphen (key_vol_brick);
}
static void
@@ -400,6 +400,10 @@ glusterd_store_snap_brickinfo (glusterd_volinfo_t *volinfo,
goto out;
ret = glusterd_store_perform_brick_store (brickinfo);
+ if (ret)
+ goto out;
+
+ ret = gf_store_rename_tmppath (brickinfo->shandle);
out:
gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
@@ -749,14 +753,15 @@ glusterd_store_snap_vol_dirpath_set (glusterd_volinfo_t *volinfo,
{
glusterd_conf_t *priv = NULL;
size_t strlen = 0;
+ char path[PATH_MAX] = {0,};
GF_ASSERT (volinfo);
priv = THIS->private;
GF_ASSERT (priv);
- glusterd_store_vol_snaps_dirpath_set (volinfo, snapdirpath, len);
- strlen = sizeof (snapdirpath) + sizeof (*snap_name);
- snprintf (snapdirpath, strlen, "%s/%s", snapdirpath, snap_name);
+ glusterd_store_vol_snaps_dirpath_set (volinfo, path, sizeof (path));
+ strlen = sizeof (path) + sizeof (*snap_name);
+ snprintf (snapdirpath, strlen, "%s/%s", path, snap_name);
}
/* creates GLUSTERD_VOLUME_DIR_PREFIX/<volname>/snaps directory */
static int32_t
@@ -999,7 +1004,7 @@ glusterd_store_snap_brickinfos (glusterd_volinfo_t *volinfo,
GF_ASSERT (volinfo);
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ list_for_each_entry (brickinfo, &snapinfo->bricks, brick_list) {
ret = glusterd_store_snap_brickinfo (volinfo, snapinfo,
brickinfo, brick_count,
vol_fd);
@@ -1198,9 +1203,14 @@ glusterd_store_perform_snap_volume_store (glusterd_volinfo_t *volinfo,
ret = glusterd_store_volinfo_write (fd, snap_volinfo);
if (ret)
goto out;
+
ret = glusterd_store_snap_brickinfos (volinfo, snap_volinfo, fd);
if (ret)
goto out;
+
+ ret = gf_store_rename_tmppath (snap_volinfo->shandle);
+ if (ret)
+ goto out;
out:
if (ret && (fd > 0))
gf_store_unlink_tmppath (volinfo->shandle);
@@ -1413,6 +1423,8 @@ glusterd_store_volume_cleanup_tmp (glusterd_volinfo_t *volinfo)
gf_store_unlink_tmppath (volinfo->rb_shandle);
gf_store_unlink_tmppath (volinfo->node_state_shandle);
+
+ gf_store_unlink_tmppath (volinfo->snap_list_shandle);
}
int32_t
@@ -2415,7 +2427,10 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
if (ret)
goto out;
- ret = glusterd_store_retrieve_bricks (volinfo, snap->snap_name);
+ if (snap)
+ ret = glusterd_store_retrieve_bricks (volinfo, snap->snap_name);
+ else
+ ret = glusterd_store_retrieve_bricks (volinfo, NULL);
if (ret)
goto out;
@@ -2720,7 +2735,8 @@ glusterd_store_retrieve_volumes (xlator_t *this)
ret = glusterd_volinfo_find (entry->d_name, &volinfo);
ret =
glusterd_store_create_snap_list_sh_on_absence (volinfo);
- ret = glusterd_store_perform_snap_list_store (volinfo);
+ ret = glusterd_store_perform_snap_store (volinfo);
+ //glusterd_store_perform_snap_list_store (volinfo);
}
glusterd_for_each_entry (entry, dir);