Blob Blame History Raw
From 14d7f4d6163d8f4d97b70c467a93f8048683570b Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Sun, 26 Feb 2017 23:00:21 +0530
Subject: [PATCH 340/361] glusterd: add portmap details in glusterd statedump

glusterd statedump file doesn't have information on the ports and its
associated brick details. This is quite problematic if any setup ends up
with stale ports and the only way to find the issue out is to gdb into
the process which is always not available. This patch attempts to fill
in this gap.

mainline:
> BUG: 1426948
> Reviewed-on: https://review.gluster.org/16764
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Prashanth Pai <ppai@redhat.com>
(cherry picked from commit aea641981dcca5d7bb83f4ad574174e8ea539ac1)

BUG: 1426950
Change-Id: I26b4fe753d752366ddf865ca3eeae3b4d577d555
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/101321
Tested-by: Milind Changire <mchangir@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-statedump.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c
index a01a6b8..94a39be 100644
--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c
@@ -188,8 +188,8 @@ glusterd_dump_priv (xlator_t *this)
         int                   index                    = 1;
         glusterd_conf_t      *priv                     = NULL;
         char                  key[GF_DUMP_MAX_BUF_LEN] = {0,};
-        glusterd_peerinfo_t  *peerinfo                 = NULL;
-        glusterd_volinfo_t   *volinfo                  = NULL;
+        int                   port                     = 0;
+        struct pmap_registry *pmap                     = NULL;
 
         GF_VALIDATE_OR_GOTO ("glusterd", this, out);
 
@@ -235,8 +235,28 @@ glusterd_dump_priv (xlator_t *this)
                 gf_proc_dump_build_key (key, "glusterd", "scrub.online");
                 gf_proc_dump_write (key, "%d", priv->scrub_svc.online);
 
+                /* Dump peer details */
                 GLUSTERD_DUMP_PEERS (&priv->peers, uuid_list, _gf_false);
+
+                /* Dump pmap data structure from base port to last alloc */
+                pmap = priv->pmap;
+                for (port = pmap->base_port; port <= pmap->last_alloc;
+                     port++) {
+                        gf_proc_dump_build_key (key, "glusterd", "pmap_port");
+                        gf_proc_dump_write (key, "%d", port);
+                        gf_proc_dump_build_key (key, "glusterd",
+                                                "pmap[%d].type", port);
+                        gf_proc_dump_write (key, "%d", pmap->ports[port].type);
+                        gf_proc_dump_build_key (key, "glusterd",
+                                                "pmap[%d].brickname", port);
+                        gf_proc_dump_write (key, "%s",
+                                            pmap->ports[port].brickname);
+
+                }
+                /* Dump client details */
                 glusterd_dump_client_details (priv);
+
+                /* Dump mgmt_v3_lock from the dictionary if any */
                 glusterd_dict_mgmt_v3_lock_statedump(priv->mgmt_v3_lock);
                 dict_dump_to_statedump (priv->opts, "options", "glusterd");
         }
-- 
1.8.3.1