From d74c10603196a57c5fa033aaeb55f93f7ef7b4be Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Mon, 5 May 2014 14:34:55 +0530 Subject: glusterd/snapshot: volume gets deleted if restore fails If the restore command fails in pre-validate phase then main volume gets deleted. Fix: Perform cleanup only when pre-validate passes. Change-Id: I7128c8582c3dd166a5683babb7e136ad0b56f0ac BUG: 1061685 Signed-off-by: Rajesh Joseph Reviewed-on: http://review.gluster.org/7665 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index c42aac57936..44a987ef8b2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -6378,6 +6378,7 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret, int ret = -1; char *name = NULL; char *volname = NULL; + int cleanup = 0; glusterd_snap_t *snap = NULL; glusterd_volinfo_t *volinfo = NULL; xlator_t *this = NULL; @@ -6428,6 +6429,13 @@ glusterd_snapshot_restore_postop (dict_t *dict, int32_t op_ret, goto out; } } else { /* On failure revert snapshot restore */ + ret = dict_get_int32 (dict, "cleanup", &cleanup); + /* Perform cleanup only when required */ + if (ret || (0 == cleanup)) { + ret = 0; + goto out; + } + ret = glusterd_snapshot_revert_partial_restored_vol (volinfo, _gf_false); if (ret) { -- cgit