summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2013-12-13 11:53:21 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-01-15 13:53:32 +0530
commit727a63c3a5f9cab5af6089826d81df2035e1c0b6 (patch)
tree25c37ce129a65ed5af8ec9b52272bd98916fa206 /xlators/mgmt/glusterd/src/glusterd-utils.c
parent33c45ff71cb43eec7cdcee054a6a55b7c3aaa8fb (diff)
Snapshot: Gluster snapshot restore feature
Implemented gluster snapshot restore feature. The restore is done by replacing the origin volume with the snap volume. TODO: After the restore the snapshot volume should be deleted. As of now the deletion work is pending. Change-Id: Ib137fb6bb84a74030607ffa47f89cd705dc7e1ff Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 6cba5b467..dedfd890f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1542,7 +1542,7 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath));
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo,
+ GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname,
snap_volinfo->volname,
brickinfo, priv);
if (glusterd_is_service_running (pidfile, NULL))
@@ -1760,10 +1760,10 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo,
gf_boolean_t del_brick)
{
- xlator_t *this = NULL;
- glusterd_conf_t *priv = NULL;
- char pidfile[PATH_MAX] = {0,};
- int ret = 0;
+ xlator_t *this = NULL;
+ glusterd_conf_t *priv = NULL;
+ char pidfile[PATH_MAX] = {0,};
+ int ret = 0;
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
@@ -1816,7 +1816,7 @@ glusterd_snap_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
(void) glusterd_brick_disconnect (brickinfo);
- GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo,
+ GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo->volname,
snap_volinfo->volname,
brickinfo, priv);
ret = glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_false);
@@ -2159,6 +2159,15 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
+ snprintf (key, sizeof (key), "volume%d.is_volume_restored", count);
+ ret = dict_set_int32 (dict, key, volinfo->is_volume_restored);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set "
+ "is_volume_restored option for %s volume",
+ volinfo->volname);
+ goto out;
+ }
+
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.brick_count", count);
ret = dict_set_int32 (dict, key, volinfo->brick_count);
@@ -5191,7 +5200,6 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
char key[1024] = {0};
char base_key[1024] = {0};
char pidfile[PATH_MAX] = {0};
- char exp_path[PATH_MAX] = {0};
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
@@ -5226,11 +5234,10 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
if (volinfo->is_snap_volume == _gf_true) {
/* Fetching the snap pidfile using parent volname */
- GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, exp_path);
- snprintf (pidfile, sizeof(pidfile) - 1,
- "%s/vols/%s/snaps/%s/run/%s-%s.pid", priv->workdir,
- volinfo->parent_volname, volinfo->volname,
- brickinfo->hostname, exp_path);
+ GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile,
+ volinfo->parent_volname,
+ volinfo->volname,
+ brickinfo, priv);
} else
GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);