d1681e
From 548895f0333a0706ec9475efc3b28456d591f093 Mon Sep 17 00:00:00 2001
d1681e
From: Gaurav Yadav <gyadav@redhat.com>
d1681e
Date: Fri, 27 Oct 2017 16:04:46 +0530
d1681e
Subject: [PATCH 41/74] glusterd: persist brickinfo's port change into
d1681e
 glusterd's store
d1681e
d1681e
Problem:
d1681e
Consider a case where node reboot is performed and prior to reboot
d1681e
brick was listening to 49153. Post reboot glusterd assigned 49152
d1681e
to brick and started the brick process but the new port was never
d1681e
persisted. Now when glusterd restarts glusterd always read the port
d1681e
from its persisted store i.e 49153 however pmap signin happens with
d1681e
the correct port i.e 49152.
d1681e
d1681e
Fix:
d1681e
Make sure when glusterd_brick_start is called, glusterd_store_volinfo is
d1681e
eventually invoked.
d1681e
d1681e
>upstream mainline patch : https://review.gluster.org/#/c/18579/
d1681e
d1681e
Change-Id: Ic0efbd48c51d39729ed951a42922d0e59f7115a1
d1681e
Signed-off-by: Gaurav Yadav <gyadav@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/121878
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
Tested-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
---
d1681e
 xlators/mgmt/glusterd/src/glusterd-handshake.c      | 18 +++++++++---------
d1681e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c          |  9 ++++++++-
d1681e
 xlators/mgmt/glusterd/src/glusterd-server-quorum.c  | 16 ++++++++++++++++
d1681e
 xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 10 ++++++++++
d1681e
 xlators/mgmt/glusterd/src/glusterd-utils.c          | 19 +++++++++++++++++++
d1681e
 5 files changed, 62 insertions(+), 10 deletions(-)
d1681e
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
d1681e
index c7e419c..8dfb528 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
d1681e
@@ -658,6 +658,15 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
d1681e
         }
d1681e
 
d1681e
         brickinfo->snap_status = 0;
d1681e
+        ret = glusterd_brick_start (snap_vol, brickinfo, _gf_false);
d1681e
+        if (ret) {
d1681e
+                gf_msg (this->name, GF_LOG_WARNING, 0,
d1681e
+                        GD_MSG_BRICK_DISCONNECTED, "starting the "
d1681e
+                        "brick %s:%s for the snap %s failed",
d1681e
+                        brickinfo->hostname, brickinfo->path,
d1681e
+                        snap->snapname);
d1681e
+                goto out;
d1681e
+        }
d1681e
         ret = glusterd_store_volinfo (snap_vol,
d1681e
                                       GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
         if (ret) {
d1681e
@@ -668,15 +677,6 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
d1681e
                 goto out;
d1681e
         }
d1681e
 
d1681e
-        ret = glusterd_brick_start (snap_vol, brickinfo, _gf_false);
d1681e
-        if (ret) {
d1681e
-                gf_msg (this->name, GF_LOG_WARNING, 0,
d1681e
-                        GD_MSG_BRICK_DISCONNECTED, "starting the "
d1681e
-                        "brick %s:%s for the snap %s failed",
d1681e
-                        brickinfo->hostname, brickinfo->path,
d1681e
-                        snap->snapname);
d1681e
-                goto out;
d1681e
-        }
d1681e
 out:
d1681e
         if (device)
d1681e
                 GF_FREE (device);
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
index 96e0860..9641b4f 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
d1681e
@@ -2415,8 +2415,15 @@ glusterd_start_bricks (glusterd_volinfo_t *volinfo)
d1681e
                                   brickinfo->path);
d1681e
                         goto out;
d1681e
                 }
d1681e
-        }
d1681e
 
d1681e
+        }
d1681e
+        ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
+        if (ret) {
d1681e
+                gf_msg (THIS->name, GF_LOG_ERROR, 0, GD_MSG_VOLINFO_STORE_FAIL,
d1681e
+                        "Failed to write volinfo for volume %s",
d1681e
+                        volinfo->volname);
d1681e
+                goto out;
d1681e
+        }
d1681e
         ret = 0;
d1681e
 out:
d1681e
         return ret;
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
d1681e
index a4637f8..659ff9d 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
d1681e
@@ -12,6 +12,7 @@
d1681e
 #include "glusterd-utils.h"
d1681e
 #include "glusterd-messages.h"
d1681e
 #include "glusterd-server-quorum.h"
d1681e
+#include "glusterd-store.h"
d1681e
 #include "glusterd-syncop.h"
d1681e
 #include "glusterd-op-sm.h"
d1681e
 
d1681e
@@ -309,6 +310,7 @@ void
d1681e
 glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo,
d1681e
                                   gf_boolean_t meets_quorum)
d1681e
 {
d1681e
+        int                   ret           = -1;
d1681e
         glusterd_brickinfo_t *brickinfo     = NULL;
d1681e
         gd_quorum_status_t   quorum_status  = NOT_APPLICABLE_QUORUM;
d1681e
         gf_boolean_t         follows_quorum = _gf_false;
d1681e
@@ -365,6 +367,20 @@ glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo,
d1681e
                         glusterd_brick_start (volinfo, brickinfo, _gf_false);
d1681e
         }
d1681e
         volinfo->quorum_status = quorum_status;
d1681e
+        if (quorum_status == MEETS_QUORUM) {
d1681e
+                /* bricks might have been restarted and so as the port change
d1681e
+                 * might have happened
d1681e
+                 */
d1681e
+                ret = glusterd_store_volinfo (volinfo,
d1681e
+                                              GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
+                if (ret) {
d1681e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                GD_MSG_VOLINFO_STORE_FAIL,
d1681e
+                                "Failed to write volinfo for volume %s",
d1681e
+                                volinfo->volname);
d1681e
+                        goto out;
d1681e
+                }
d1681e
+        }
d1681e
 out:
d1681e
         return;
d1681e
 }
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
d1681e
index 6fb49c3..4cbade1 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
d1681e
@@ -1680,6 +1680,16 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
d1681e
                 }
d1681e
                 if (glusterd_is_volume_started (snap_vol)) {
d1681e
                         (void) glusterd_start_bricks (snap_vol);
d1681e
+                        ret = glusterd_store_volinfo
d1681e
+                                               (snap_vol,
d1681e
+                                                GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
+                        if (ret) {
d1681e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                        GD_MSG_VOLINFO_STORE_FAIL, "Failed to "
d1681e
+                                        "write volinfo for volume %s",
d1681e
+                                        snap_vol->volname);
d1681e
+                                goto out;
d1681e
+                        }
d1681e
                 } else {
d1681e
                         (void) glusterd_stop_bricks(snap_vol);
d1681e
                 }
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
index f34e218..bb236df 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
@@ -6003,6 +6003,15 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
d1681e
                                 glusterd_brick_start (volinfo, brickinfo,
d1681e
                                                      _gf_false);
d1681e
                         }
d1681e
+                        ret = glusterd_store_volinfo
d1681e
+                                (volinfo, GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
+                        if (ret) {
d1681e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                        GD_MSG_VOLINFO_STORE_FAIL, "Failed to "
d1681e
+                                        "write volinfo for volume %s",
d1681e
+                                        volinfo->volname);
d1681e
+                                goto out;
d1681e
+                        }
d1681e
                 }
d1681e
         }
d1681e
 
d1681e
@@ -6034,6 +6043,16 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
d1681e
                                 glusterd_brick_start (volinfo, brickinfo,
d1681e
                                                       _gf_false);
d1681e
                         }
d1681e
+                        ret = glusterd_store_volinfo
d1681e
+                                (volinfo, GLUSTERD_VOLINFO_VER_AC_NONE);
d1681e
+                        if (ret) {
d1681e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
+                                        GD_MSG_VOLINFO_STORE_FAIL, "Failed to "
d1681e
+                                        "write volinfo for volume %s",
d1681e
+                                        volinfo->volname);
d1681e
+                                goto out;
d1681e
+                        }
d1681e
+
d1681e
                 }
d1681e
         }
d1681e
         ret = 0;
d1681e
-- 
d1681e
1.8.3.1
d1681e