|
|
cb8e9e |
From d2f48b625c0d7d361b62f7a4f1a698bef3d67dc9 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
cb8e9e |
Date: Tue, 17 Mar 2015 19:57:47 +0530
|
|
|
cb8e9e |
Subject: [PATCH 302/304] snapshot:cleanup snaps during unprobe
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Backport of http://review.gluster.org/#/c/9930/
|
|
|
cb8e9e |
|
|
|
cb8e9e |
When doing an unprobe, the volume that doesnot
|
|
|
cb8e9e |
contain any brick of the particular node will be
|
|
|
cb8e9e |
deleted. So the snaps associated with that volume
|
|
|
cb8e9e |
should also delete
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: I9f3d23bd11b254ebf7d7722cc1e12455d6b024ff
|
|
|
cb8e9e |
BUG: 1238111
|
|
|
cb8e9e |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: http://review.gluster.org/9930
|
|
|
cb8e9e |
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
cb8e9e |
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
|
|
|
cb8e9e |
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/56396
|
|
|
cb8e9e |
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
xlators/mgmt/glusterd/src/glusterd-sm.c | 9 ++
|
|
|
cb8e9e |
.../mgmt/glusterd/src/glusterd-snapshot-utils.c | 89 ++++++++++++++++++++
|
|
|
cb8e9e |
.../mgmt/glusterd/src/glusterd-snapshot-utils.h | 5 +
|
|
|
cb8e9e |
xlators/mgmt/glusterd/src/glusterd-snapshot.c | 23 +-----
|
|
|
cb8e9e |
4 files changed, 104 insertions(+), 22 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
cb8e9e |
index 8e91cef..f0159b2 100644
|
|
|
cb8e9e |
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
cb8e9e |
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
|
|
|
cb8e9e |
@@ -635,6 +635,15 @@ glusterd_peer_detach_cleanup (glusterd_conf_t *priv)
|
|
|
cb8e9e |
gf_msg (THIS->name, GF_LOG_INFO, 0,
|
|
|
cb8e9e |
GD_MSG_STALE_VOL_DELETE_INFO,
|
|
|
cb8e9e |
"Deleting stale volume %s", volinfo->volname);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = glusterd_cleanup_snaps_for_volume (volinfo);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
+ GD_MSG_VOL_DELETE_FAIL,
|
|
|
cb8e9e |
+ "Error deleting snapshots for volume %s",
|
|
|
cb8e9e |
+ volinfo->volname);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
ret = glusterd_delete_volume (volinfo);
|
|
|
cb8e9e |
if (ret) {
|
|
|
cb8e9e |
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
cb8e9e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
cb8e9e |
index acc4e42..ccea9ff 100644
|
|
|
cb8e9e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
cb8e9e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
|
|
|
cb8e9e |
@@ -40,6 +40,95 @@
|
|
|
cb8e9e |
* This function restores the atime and mtime of marker.tstamp
|
|
|
cb8e9e |
* if present from snapped marker.tstamp file.
|
|
|
cb8e9e |
*/
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+glusterd_snapobject_delete (glusterd_snap_t *snap)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ if (snap == NULL) {
|
|
|
cb8e9e |
+ gf_msg(THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_PARAM_NULL, "snap is NULL");
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ cds_list_del_init (&snap->snap_list);
|
|
|
cb8e9e |
+ cds_list_del_init (&snap->volumes);
|
|
|
cb8e9e |
+ if (LOCK_DESTROY(&snap->lock))
|
|
|
cb8e9e |
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_LOCK_DESTROY_FAILED,
|
|
|
cb8e9e |
+ "Failed destroying lock"
|
|
|
cb8e9e |
+ "of snap %s", snap->snapname);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ GF_FREE (snap->description);
|
|
|
cb8e9e |
+ GF_FREE (snap);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+/*
|
|
|
cb8e9e |
+ * This function is to be called only from glusterd_peer_detach_cleanup()
|
|
|
cb8e9e |
+ * as this continues to delete snaps inspite of faiure while deleting
|
|
|
cb8e9e |
+ * one, as we don't want to fail peer_detach in such a case.
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+glusterd_cleanup_snaps_for_volume (glusterd_volinfo_t *volinfo)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ int32_t op_ret = 0;
|
|
|
cb8e9e |
+ int32_t ret = 0;
|
|
|
cb8e9e |
+ xlator_t *this = NULL;
|
|
|
cb8e9e |
+ glusterd_volinfo_t *snap_vol = NULL;
|
|
|
cb8e9e |
+ glusterd_volinfo_t *dummy_snap_vol = NULL;
|
|
|
cb8e9e |
+ glusterd_snap_t *snap = NULL;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ this = THIS;
|
|
|
cb8e9e |
+ GF_ASSERT (this);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ cds_list_for_each_entry_safe (snap_vol, dummy_snap_vol,
|
|
|
cb8e9e |
+ &volinfo->snap_volumes,
|
|
|
cb8e9e |
+ snapvol_list) {
|
|
|
cb8e9e |
+ ret = glusterd_store_delete_volume (snap_vol);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ gf_msg(this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_VOL_DELETE_FAIL, "Failed to remove "
|
|
|
cb8e9e |
+ "volume %s from store", snap_vol->volname);
|
|
|
cb8e9e |
+ op_ret = ret;
|
|
|
cb8e9e |
+ continue;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = glusterd_volinfo_delete (snap_vol);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ gf_msg(this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_VOL_DELETE_FAIL, "Failed to remove "
|
|
|
cb8e9e |
+ "volinfo %s ", snap_vol->volname);
|
|
|
cb8e9e |
+ op_ret = ret;
|
|
|
cb8e9e |
+ continue;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ snap = snap_vol->snapshot;
|
|
|
cb8e9e |
+ ret = glusterd_store_delete_snap (snap);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ gf_msg(this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_VOL_DELETE_FAIL, "Failed to remove "
|
|
|
cb8e9e |
+ "snap %s from store", snap->snapname);
|
|
|
cb8e9e |
+ op_ret = ret;
|
|
|
cb8e9e |
+ continue;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = glusterd_snapobject_delete (snap);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
+ GD_MSG_VOL_DELETE_FAIL, "Failed to delete "
|
|
|
cb8e9e |
+ "snap object %s", snap->snapname);
|
|
|
cb8e9e |
+ op_ret = ret;
|
|
|
cb8e9e |
+ continue;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ return op_ret;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
glusterd_snap_geo_rep_restore (glusterd_volinfo_t *snap_volinfo,
|
|
|
cb8e9e |
glusterd_volinfo_t *new_volinfo)
|
|
|
cb8e9e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
cb8e9e |
index ce8d7d4..63d39e8 100644
|
|
|
cb8e9e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
cb8e9e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
cb8e9e |
@@ -38,6 +38,11 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
|
|
|
cb8e9e |
glusterd_volinfo_t *new_volinfo,
|
|
|
cb8e9e |
glusterd_volinfo_t *snap_volinfo,
|
|
|
cb8e9e |
int32_t volcount);
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+glusterd_snapobject_delete (glusterd_snap_t *snap);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+glusterd_cleanup_snaps_for_volume (glusterd_volinfo_t *volinfo);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
glusterd_missed_snapinfo_new (glusterd_missed_snap_info **missed_snapinfo);
|
|
|
cb8e9e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
cb8e9e |
index 080aa88..6f10ebc 100644
|
|
|
cb8e9e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
cb8e9e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
cb8e9e |
@@ -86,6 +86,7 @@ typedef struct snap_create_args_ snap_create_args_t;
|
|
|
cb8e9e |
then the snap device will be /dev/<group-name>/<snapname>.
|
|
|
cb8e9e |
This function takes care of building the path for the snap device.
|
|
|
cb8e9e |
*/
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
char *
|
|
|
cb8e9e |
glusterd_build_snap_device_path (char *device, char *snapname,
|
|
|
cb8e9e |
int32_t brickcount)
|
|
|
cb8e9e |
@@ -2961,28 +2962,6 @@ out:
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
-glusterd_snapobject_delete (glusterd_snap_t *snap)
|
|
|
cb8e9e |
-{
|
|
|
cb8e9e |
- if (snap == NULL) {
|
|
|
cb8e9e |
- gf_msg(THIS->name, GF_LOG_WARNING, EINVAL,
|
|
|
cb8e9e |
- GD_MSG_INVALID_ENTRY, "snap is NULL");
|
|
|
cb8e9e |
- return -1;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- cds_list_del_init (&snap->snap_list);
|
|
|
cb8e9e |
- cds_list_del_init (&snap->volumes);
|
|
|
cb8e9e |
- if (LOCK_DESTROY(&snap->lock))
|
|
|
cb8e9e |
- gf_msg (THIS->name, GF_LOG_WARNING, 0,
|
|
|
cb8e9e |
- GD_MSG_LOCK_DESTROY_FAILED, "Failed destroying lock"
|
|
|
cb8e9e |
- "of snap %s", snap->snapname);
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- GF_FREE (snap->description);
|
|
|
cb8e9e |
- GF_FREE (snap);
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- return 0;
|
|
|
cb8e9e |
-}
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
-int32_t
|
|
|
cb8e9e |
glusterd_snap_remove (dict_t *rsp_dict,
|
|
|
cb8e9e |
glusterd_snap_t *snap,
|
|
|
cb8e9e |
gf_boolean_t remove_lvm,
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|