7f4c2a
From ee77fa7ac83f1d5b3b77c032bf97374f34304a64 Mon Sep 17 00:00:00 2001
7f4c2a
From: Atin Mukherjee <amukherj@redhat.com>
7f4c2a
Date: Tue, 23 Jun 2015 15:40:32 +0530
7f4c2a
Subject: [PATCH 132/190] glusterd: use mkdir_p for creating rundir
7f4c2a
7f4c2a
snapdsvc initialization is now dependent on all subsequent directories and
7f4c2a
volfile creations.
7f4c2a
7f4c2a
However this may not hold true correct for all the cases. While importing a
7f4c2a
volume we would need to start the service before the store creation.
7f4c2a
7f4c2a
To avoid this dependency, use mkdir_p instead of mkdir to create rundir
7f4c2a
7f4c2a
Change-Id: Ib251043398c40f1b76378e3bc6d0c36c1fe4cca3
7f4c2a
BUG: 1234720
7f4c2a
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
7f4c2a
Reviewed-on: http://review.gluster.org/11364
7f4c2a
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
7f4c2a
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
7f4c2a
Reviewed-by: Kaushal M <kaushal@redhat.com>
7f4c2a
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/51469
7f4c2a
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
7f4c2a
Tested-by: Vijay Bellur <vbellur@redhat.com>
7f4c2a
---
7f4c2a
 xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c |    2 +-
7f4c2a
 xlators/mgmt/glusterd/src/glusterd-utils.c    |   14 +++++++-------
7f4c2a
 2 files changed, 8 insertions(+), 8 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
7f4c2a
index 1a68afb..04096a4 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
7f4c2a
@@ -23,7 +23,7 @@ glusterd_svc_create_rundir (char *rundir)
7f4c2a
 {
7f4c2a
         int ret      = -1;
7f4c2a
 
7f4c2a
-        ret = mkdir (rundir, 0777);
7f4c2a
+        ret = mkdir_p (rundir, 0777, _gf_true);
7f4c2a
         if ((ret == -1) && (EEXIST != errno)) {
7f4c2a
                 gf_msg (THIS->name, GF_LOG_ERROR, errno,
7f4c2a
                         GD_MSG_CREATE_DIR_FAILED, "Unable to create rundir %s",
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
7f4c2a
index f374f94..ab68f71 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
7f4c2a
@@ -3802,6 +3802,13 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
7f4c2a
                 (void) glusterd_delete_stale_volume (old_volinfo, new_volinfo);
7f4c2a
         }
7f4c2a
 
7f4c2a
+        ret = glusterd_snapdsvc_init (new_volinfo);
7f4c2a
+        if (ret) {
7f4c2a
+                gf_log (this->name, GF_LOG_ERROR, "Failed to initialize "
7f4c2a
+                        "snapdsvc for volume %s", new_volinfo->volname);
7f4c2a
+                goto out;
7f4c2a
+        }
7f4c2a
+
7f4c2a
         if (glusterd_is_volume_started (new_volinfo)) {
7f4c2a
                 (void) glusterd_start_bricks (new_volinfo);
7f4c2a
                 if (glusterd_is_snapd_enabled (new_volinfo)) {
7f4c2a
@@ -3817,13 +3824,6 @@ glusterd_import_friend_volume (dict_t *peer_data, size_t count)
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
-        ret = glusterd_snapdsvc_init (new_volinfo);
7f4c2a
-        if (ret) {
7f4c2a
-                gf_log (this->name, GF_LOG_ERROR, "Failed to initialize "
7f4c2a
-                        "snapdsvc for volume %s", new_volinfo->volname);
7f4c2a
-                goto out;
7f4c2a
-        }
7f4c2a
-
7f4c2a
         ret = glusterd_create_volfiles_and_notify_services (new_volinfo);
7f4c2a
         if (ret)
7f4c2a
                 goto out;
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a