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