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