From fc7a70ad87dbb456685a86b2dcca75b06d02930e Mon Sep 17 00:00:00 2001
From: Avra Sengupta <asengupt@redhat.com>
Date: Fri, 12 Jun 2015 17:13:05 +0530
Subject: [PATCH 097/101] glusterd/uss/snapshot: Intialise snapdsvc after volfiles are created
snapd svc should be initialised only after all
relevant volfiles and directories are created.
>Reviewed-on: http://review.gluster.org/11227/
Change-Id: I96770cfc0b350599cd60ff74f5ecec08145c3105
BUG: 1230635
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51027
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-snapshot.c | 18 +++++++++---------
xlators/mgmt/glusterd/src/glusterd-utils.c | 21 +++++++++++++--------
xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 12 +++++++-----
3 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index f779bff..654310c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -9454,15 +9454,6 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
/* Use the same version as the original version */
new_volinfo->version = orig_vol->version;
- /* Initialize the snapd service */
- ret = glusterd_snapdsvc_init (new_volinfo);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd "
- "service for volume %s", orig_vol->volname);
- goto out;
- }
-
/* Copy the snap vol info to the new_volinfo.*/
ret = glusterd_snap_volinfo_restore (dict, rsp_dict, new_volinfo,
snap_vol, volcount);
@@ -9533,6 +9524,15 @@ gd_restore_snap_volume (dict_t *dict, dict_t *rsp_dict,
goto out;
}
+ /* Initialize the snapd service */
+ ret = glusterd_snapdsvc_init (new_volinfo);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize snapd "
+ "service for volume %s", orig_vol->volname);
+ goto out;
+ }
+
ret = 0;
out:
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 23a60d2..f374f94 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3784,14 +3784,6 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
goto out;
}
- ret = glusterd_snapdsvc_init (new_volinfo);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- GD_MSG_SNAPD_INIT_FAIL, "Failed to initialize "
- "snapdsvc for volume %s", new_volinfo->volname);
- goto out;
- }
-
ret = glusterd_volinfo_find (new_volinfo->volname, &old_volinfo);
if (0 == ret) {
/* snapdsvc initialization of old_volinfo is also required here
@@ -3819,6 +3811,19 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
}
ret = glusterd_store_volinfo (new_volinfo, GLUSTERD_VOLINFO_VER_AC_NONE);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+ "volinfo for volume %s", new_volinfo->volname);
+ goto out;
+ }
+
+ ret = glusterd_snapdsvc_init (new_volinfo);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to initialize "
+ "snapdsvc for volume %s", new_volinfo->volname);
+ goto out;
+ }
+
ret = glusterd_create_volfiles_and_notify_services (new_volinfo);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index ac66efe..7872314 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -2279,16 +2279,18 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
volinfo->caps = caps;
- ret = glusterd_snapdsvc_init (volinfo);
+ ret = glusterd_store_volinfo (volinfo,
+ GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret) {
- *op_errstr = gf_strdup ("Failed to initialize snapd service");
+ glusterd_store_delete_volume (volinfo);
+ *op_errstr = gf_strdup ("Failed to store the "
+ "Volume information");
goto out;
}
- ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+ ret = glusterd_snapdsvc_init (volinfo);
if (ret) {
- glusterd_store_delete_volume (volinfo);
- *op_errstr = gf_strdup ("Failed to store the Volume information");
+ *op_errstr = gf_strdup ("Failed to initialize snapd service");
goto out;
}
--
1.7.1