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