diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index e9a98ea694d..d185ba82979 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -2960,7 +2960,8 @@ int32_t glusterd_snap_remove (dict_t *rsp_dict, glusterd_snap_t *snap, gf_boolean_t remove_lvm, - gf_boolean_t force) + gf_boolean_t force, + gf_boolean_t is_clone) { int ret = -1; int save_ret = 0; @@ -2995,14 +2996,20 @@ glusterd_snap_remove (dict_t *rsp_dict, } } - ret = glusterd_store_delete_snap (snap); - if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, - GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove snap %s " - "from store", snap->snapname); - save_ret = ret; - if (!force) - goto out; + /* A clone does not persist snap info in /var/lib/glusterd/snaps/ * + * and hence there is no snap info to be deleted from there * + */ + if (!is_clone) { + ret = glusterd_store_delete_snap (snap); + if (ret) { + gf_msg(this->name, GF_LOG_WARNING, 0, + GD_MSG_SNAP_REMOVE_FAIL, + "Failed to remove snap %s from store", + snap->snapname); + save_ret = ret; + if (!force) + goto out; + } } ret = glusterd_snapobject_delete (snap); @@ -4403,7 +4410,8 @@ out: if (ret) { if (snap) glusterd_snap_remove (rsp_dict, snap, - _gf_true, _gf_true); + _gf_true, _gf_true, + _gf_false); snap = NULL; } @@ -5981,7 +5989,8 @@ glusterd_snapshot_remove_commit (dict_t *dict, char **op_errstr, } } - ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_false); + ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_false, + _gf_false); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_SNAP_REMOVE_FAIL, "Failed to remove snap %s", @@ -6053,7 +6062,8 @@ glusterd_do_snap_cleanup (dict_t *dict, char **op_errstr, dict_t *rsp_dict) goto out; } - ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_true); + ret = glusterd_snap_remove (rsp_dict, snap, _gf_true, _gf_true, + _gf_false); if (ret) { /* Ignore failure as this is a cleanup of half cooked snapshot */ @@ -6343,7 +6353,7 @@ out: if (ret) { if (snap) glusterd_snap_remove (rsp_dict, snap, - _gf_true, _gf_true); + _gf_true, _gf_true, _gf_true); snap = NULL; } @@ -6479,7 +6489,8 @@ out: if (ret) { if (snap) glusterd_snap_remove (rsp_dict, snap, - _gf_true, _gf_true); + _gf_true, _gf_true, + _gf_true); snap = NULL; } @@ -6677,7 +6688,8 @@ out: if (ret) { if (snap) glusterd_snap_remove (rsp_dict, snap, - _gf_true, _gf_true); + _gf_true, _gf_true, + _gf_false); snap = NULL; } @@ -7722,7 +7734,8 @@ glusterd_handle_snap_limit (dict_t *dict, dict_t *rsp_dict) } ret = glusterd_snap_remove (rsp_dict, snap, - _gf_true, _gf_true); + _gf_true, _gf_true, + _gf_false); if (ret) gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_SNAP_REMOVE_FAIL, @@ -7758,27 +7771,6 @@ glusterd_snapshot_clone_postvalidate (dict_t *dict, int32_t op_ret, priv = this->private; GF_ASSERT (priv); - if (op_ret) { - ret = dict_get_int32 (dict, "cleanup", &cleanup); - if (!ret && cleanup) { - ret = glusterd_do_snap_cleanup (dict, op_errstr, - rsp_dict); - if (ret) { - gf_msg (this->name, GF_LOG_WARNING, 0, - GD_MSG_SNAP_CLEANUP_FAIL, "cleanup " - "operation failed"); - goto out; - } - } - /* Irrespective of status of cleanup its better - * to return from this function. As the functions - * following this block is not required to be - * executed in case of failure scenario. - */ - ret = 0; - goto out; - } - ret = dict_get_str (dict, "clonename", &clonename); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, @@ -7795,16 +7787,29 @@ glusterd_snapshot_clone_postvalidate (dict_t *dict, int32_t op_ret, goto out; } - ret = glusterd_snapshot_update_snaps_post_validate (dict, - op_errstr, - rsp_dict); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - GD_MSG_SNAP_CREATION_FAIL, "Failed to " - "create snapshot"); + if (snap_vol) + snap = snap_vol->snapshot; + + /* Fetch snap object from snap_vol and delete it all in case of * + * a failure, or else, just delete the snap object as it is not * + * needed in case of a clone * + */ + if (op_ret) { + ret = dict_get_int32 (dict, "cleanup", &cleanup); + if (!ret && cleanup && snap) { + glusterd_snap_remove (rsp_dict, snap, + _gf_true, _gf_true, + _gf_true); + } + /* Irrespective of status of cleanup its better + * to return from this function. As the functions + * following this block is not required to be + * executed in case of failure scenario. + */ + ret = 0; goto out; } - snap = snap_vol->snapshot; + ret = glusterd_snapobject_delete (snap); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, @@ -8341,7 +8346,8 @@ glusterd_snapshot_restore_cleanup (dict_t *rsp_dict, volname); /* Now delete the snap entry. */ - ret = glusterd_snap_remove (rsp_dict, snap, _gf_false, _gf_true); + ret = glusterd_snap_remove (rsp_dict, snap, _gf_false, _gf_true, + _gf_false); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_SNAP_REMOVE_FAIL, "Failed to delete " |