74b1de
From 3bcffadcd77eebe6b4f7e5015ad41ec7c1d1ec3e Mon Sep 17 00:00:00 2001
74b1de
From: Mohit Agrawal <moagrawal@redhat.com>
74b1de
Date: Thu, 11 Apr 2019 20:38:53 +0530
74b1de
Subject: [PATCH 096/124] core: Brick is not able to detach successfully in
74b1de
 brick_mux environment
74b1de
74b1de
Problem: In brick_mux environment, while volumes are stopped in a
74b1de
         loop bricks are not detached successfully. Brick's are not
74b1de
         detached because xprtrefcnt has not become 0 for detached brick.
74b1de
         At the time of initiating brick detach process server_notify
74b1de
         saves xprtrefcnt on detach brick and once counter has become
74b1de
         0 then server_rpc_notify spawn a server_graph_janitor_threads
74b1de
         for cleanup brick resources.xprtrefcnt has not become 0 because
74b1de
         socket framework is not working due to assigning 0 as a fd for socket.
74b1de
         In commit dc25d2c1eeace91669052e3cecc083896e7329b2
74b1de
         there was a change in changelog fini to close htime_fd if htime_fd is not
74b1de
         negative, by default htime_fd is 0 so it close 0 also.
74b1de
74b1de
Solution: Initialize htime_fd to -1 after just allocate changelog_priv
74b1de
          by GF_CALLOC
74b1de
74b1de
> Fixes: bz#1699025
74b1de
> Change-Id: I5f7ca62a0eb1c0510c3e9b880d6ab8af8d736a25
74b1de
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
74b1de
> (Cherry picked from commit b777d83001d8006420b6c7d2d88fe68950aa7e00)
74b1de
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22549/
74b1de
74b1de
Fixes: bz#1698919
74b1de
Change-Id: Ib5b74aa0818235625f8aac7c23d4daa599da3fd1
74b1de
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
74b1de
Reviewed-on: https://code.engineering.redhat.com/gerrit/167826
74b1de
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
74b1de
Tested-by: RHGS Build Bot <nigelb@redhat.com>
74b1de
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
74b1de
---
74b1de
 .../bug-1699025-brick-mux-detach-brick-fd-issue.t  | 33 ++++++++++++++++++++++
74b1de
 xlators/features/changelog/src/changelog.c         |  1 +
74b1de
 2 files changed, 34 insertions(+)
74b1de
 create mode 100644 tests/bugs/core/bug-1699025-brick-mux-detach-brick-fd-issue.t
74b1de
74b1de
diff --git a/tests/bugs/core/bug-1699025-brick-mux-detach-brick-fd-issue.t b/tests/bugs/core/bug-1699025-brick-mux-detach-brick-fd-issue.t
74b1de
new file mode 100644
74b1de
index 0000000..1acbaa8
74b1de
--- /dev/null
74b1de
+++ b/tests/bugs/core/bug-1699025-brick-mux-detach-brick-fd-issue.t
74b1de
@@ -0,0 +1,33 @@
74b1de
+#!/bin/bash
74b1de
+
74b1de
+. $(dirname $0)/../../include.rc
74b1de
+. $(dirname $0)/../../volume.rc
74b1de
+. $(dirname $0)/../../cluster.rc
74b1de
+
74b1de
+function count_brick_processes {
74b1de
+        pgrep glusterfsd | wc -l
74b1de
+}
74b1de
+
74b1de
+cleanup
74b1de
+
74b1de
+#bug-1444596 - validating brick mux
74b1de
+
74b1de
+TEST glusterd
74b1de
+TEST $CLI volume create $V0 $H0:$B0/brick{0,1}
74b1de
+TEST $CLI volume create $V1 $H0:$B0/brick{2,3}
74b1de
+
74b1de
+TEST $CLI volume set all cluster.brick-multiplex on
74b1de
+
74b1de
+TEST $CLI volume start $V0
74b1de
+TEST $CLI volume start $V1
74b1de
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 4 online_brick_count
74b1de
+EXPECT 1 count_brick_processes
74b1de
+
74b1de
+TEST $CLI volume stop $V1
74b1de
+# At the time initialize brick daemon it always keeps open
74b1de
+# standard fd's (0, 1 , 2) so after stop 1 volume fd's should
74b1de
+# be open
74b1de
+nofds=$(ls -lrth /proc/`pgrep glusterfsd`/fd | grep dev/null | wc -l)
74b1de
+TEST [ $((nofds)) -eq 3 ]
74b1de
+
74b1de
+cleanup
74b1de
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
74b1de
index 1f22a97..d9025f3 100644
74b1de
--- a/xlators/features/changelog/src/changelog.c
74b1de
+++ b/xlators/features/changelog/src/changelog.c
74b1de
@@ -2740,6 +2740,7 @@ init(xlator_t *this)
74b1de
     GF_ATOMIC_INIT(priv->clntcnt, 0);
74b1de
     GF_ATOMIC_INIT(priv->xprtcnt, 0);
74b1de
     INIT_LIST_HEAD(&priv->xprt_list);
74b1de
+    priv->htime_fd = -1;
74b1de
 
74b1de
     ret = changelog_init_options(this, priv);
74b1de
     if (ret)
74b1de
-- 
74b1de
1.8.3.1
74b1de