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