summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c65
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c12
3 files changed, 59 insertions, 24 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index 95b2de8818f..9e0e9e024ca 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -1875,6 +1875,12 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
above and along with it the originator glusterd also goes down?
Who will initiate the cleanup?
*/
+ ret = dict_set_int32 (req_dict, "cleanup", 1);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "failed to set dict");
+ goto unbarrier;
+ }
+
ret = glusterd_mgmt_v3_commit (conf, op, dict, req_dict,
&op_errstr, npeers);
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 399401d187a..395bda1dc00 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -4589,14 +4589,6 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
}
}
- snap->snap_status = GD_SNAP_STATUS_IN_USE;
- ret = glusterd_store_snap (snap);
- if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
- "object %s", snap->snapname);
- goto out;
- }
-
ret = 0;
out:
@@ -5425,6 +5417,9 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
int ret = -1;
+ int32_t cleanup = 0;
+ glusterd_snap_t *snap = NULL;
+ char *snapname = NULL;
this = THIS;
@@ -5436,23 +5431,49 @@ glusterd_snapshot_create_postvalidate (dict_t *dict, int32_t op_ret,
GF_ASSERT (priv);
if (op_ret) {
- ret = glusterd_do_snap_cleanup (dict, op_errstr, rsp_dict);
- if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "cleanup operation "
- "failed");
- goto out;
- }
- } else {
- ret = glusterd_snapshot_update_snaps_post_validate (dict,
- op_errstr,
- rsp_dict);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "create snapshot");
- goto out;
+ ret = dict_get_int32 (dict, "cleanup", &cleanup);
+ if (!ret && cleanup) {
+ ret = glusterd_do_snap_cleanup (dict, op_errstr,
+ rsp_dict);
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING, "cleanup "
+ "operation failed");
+ goto out;
+ }
}
}
+ ret = dict_get_str (dict, "snapname", &snapname);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Unable to fetch "
+ "snapname");
+ goto out;
+ }
+
+ snap = glusterd_find_snap_by_name (snapname);
+ if (!snap) {
+ gf_log (this->name, GF_LOG_ERROR, "unable to find snap "
+ "%s", snapname);
+ goto out;
+ }
+
+ snap->snap_status = GD_SNAP_STATUS_IN_USE;
+ ret = glusterd_store_snap (snap);
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING, "Could not store snap"
+ "object %s", snap->snapname);
+ goto out;
+ }
+
+ ret = glusterd_snapshot_update_snaps_post_validate (dict,
+ op_errstr,
+ rsp_dict);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ "create snapshot");
+ goto out;
+ }
+
ret = 0;
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ab635ff943f..0404e110cb5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -3987,11 +3987,19 @@ glusterd_restore ()
if (ret)
goto out;
- ret = glusterd_store_retrieve_snaps (this);
+ ret = glusterd_store_retrieve_peers (this);
if (ret)
goto out;
- ret = glusterd_store_retrieve_peers (this);
+ /* While retrieving snapshots, if the snapshot status
+ is not GD_SNAP_STATUS_IN_USE, then the snapshot is
+ cleaned up. To do that, the snap volume has to be
+ stopped by stopping snapshot volume's bricks. And for
+ that the snapshot bricks should be resolved. But without
+ retrieving the peers, resolving bricks will fail. So
+ do retrieving of snapshots after retrieving peers.
+ */
+ ret = glusterd_store_retrieve_snaps (this);
if (ret)
goto out;