21ab4e
From 4aa08b618d71213a36b366d7d0b10236174acd0b Mon Sep 17 00:00:00 2001
21ab4e
From: Atin Mukherjee <amukherj@redhat.com>
21ab4e
Date: Sun, 14 May 2017 12:34:15 +0530
21ab4e
Subject: [PATCH 433/473] brick mux: Detach brick on posix health check failure
21ab4e
21ab4e
With brick mux enabled, we'd need to detach a particular brick if the
21ab4e
underlying backend has gone bad. This patch addresses the same.
21ab4e
21ab4e
>Reviewed-on: https://review.gluster.org/17287
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
21ab4e
21ab4e
Change-Id: Icfd469c7407cd2d21d02e4906375ec770afeacc3
21ab4e
BUG: 1450806
21ab4e
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106263
21ab4e
---
21ab4e
 configure.ac                              |  4 ++--
21ab4e
 glusterfsd/src/glusterfsd-mgmt.c          |  2 +-
21ab4e
 glusterfsd/src/glusterfsd.h               |  2 ++
21ab4e
 xlators/storage/posix/src/Makefile.am     |  2 +-
21ab4e
 xlators/storage/posix/src/posix-helpers.c | 25 ++++++++++++++++++++++---
21ab4e
 5 files changed, 28 insertions(+), 7 deletions(-)
21ab4e
21ab4e
diff --git a/configure.ac b/configure.ac
21ab4e
index d51fa87..22272d4 100644
21ab4e
--- a/configure.ac
21ab4e
+++ b/configure.ac
21ab4e
@@ -282,10 +282,10 @@ AC_ARG_ENABLE([debug],
21ab4e
                              [Enable debug build options.]))
21ab4e
 if test "x$enable_debug" = "xyes"; then
21ab4e
         BUILD_DEBUG=yes
21ab4e
-        CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
21ab4e
+        CFLAGS="${CFLAGS} -g -rdynamic -O0 -DDEBUG"
21ab4e
 else
21ab4e
         BUILD_DEBUG=no
21ab4e
-        CFLAGS="${CFLAGS} -g -O2"
21ab4e
+        CFLAGS="${CFLAGS} -g -rdynamic"
21ab4e
 fi
21ab4e
 
21ab4e
 case $host_os in
21ab4e
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
index 607eac7..968570c 100644
21ab4e
--- a/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
+++ b/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
@@ -186,7 +186,7 @@ glusterfs_terminate_response_send (rpcsvc_request_t *req, int op_ret)
21ab4e
         return ret;
21ab4e
 }
21ab4e
 
21ab4e
-static void
21ab4e
+void
21ab4e
 glusterfs_autoscale_threads (glusterfs_ctx_t *ctx, int incr)
21ab4e
 {
21ab4e
         struct event_pool       *pool           = ctx->event_pool;
21ab4e
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
21ab4e
index e13896d..4d697f3 100644
21ab4e
--- a/glusterfsd/src/glusterfsd.h
21ab4e
+++ b/glusterfsd/src/glusterfsd.h
21ab4e
@@ -122,6 +122,8 @@ int glusterfs_volume_top_write_perf (uint32_t blk_size, uint32_t blk_count,
21ab4e
 int glusterfs_volume_top_read_perf (uint32_t blk_size, uint32_t blk_count,
21ab4e
                                     char *brick_path, double *throughput,
21ab4e
                                     double *time);
21ab4e
+void
21ab4e
+glusterfs_autoscale_threads (glusterfs_ctx_t *ctx, int incr);
21ab4e
 
21ab4e
 extern glusterfs_ctx_t *glusterfsd_ctx;
21ab4e
 #endif /* __GLUSTERFSD_H__ */
21ab4e
diff --git a/xlators/storage/posix/src/Makefile.am b/xlators/storage/posix/src/Makefile.am
21ab4e
index 4e3fd3d..227bff2 100644
21ab4e
--- a/xlators/storage/posix/src/Makefile.am
21ab4e
+++ b/xlators/storage/posix/src/Makefile.am
21ab4e
@@ -15,7 +15,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
21ab4e
             -I$(top_srcdir)/rpc/xdr/src \
21ab4e
             -I$(top_srcdir)/rpc/rpc-lib/src
21ab4e
 
21ab4e
-AM_CFLAGS = -fno-strict-aliasing -Wall $(GF_CFLAGS)
21ab4e
+AM_CFLAGS = -fno-strict-aliasing -Wall $(GF_CFLAGS) -I$(top_srcdir)/glusterfsd/src
21ab4e
 
21ab4e
 CLEANFILES =
21ab4e
 
21ab4e
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
21ab4e
index 276ba3c..72f76c0 100644
21ab4e
--- a/xlators/storage/posix/src/posix-helpers.c
21ab4e
+++ b/xlators/storage/posix/src/posix-helpers.c
21ab4e
@@ -51,6 +51,7 @@
21ab4e
 #include "hashfn.h"
21ab4e
 #include "glusterfs-acl.h"
21ab4e
 #include "events.h"
21ab4e
+#include "glusterfsd.h"
21ab4e
 #include <sys/types.h>
21ab4e
 
21ab4e
 char *marker_xattrs[] = {"trusted.glusterfs.quota.*",
21ab4e
@@ -1843,9 +1844,11 @@ posix_health_check_thread_proc (void *data)
21ab4e
         struct posix_private *priv               = NULL;
21ab4e
         uint32_t              interval           = 0;
21ab4e
         int                   ret                = -1;
21ab4e
-        xlator_t                *top             = NULL;
21ab4e
-        xlator_list_t           **trav_p         = NULL;
21ab4e
-        int                     count            = 0;
21ab4e
+        xlator_t             *top                = NULL;
21ab4e
+        xlator_t             *victim             = NULL;
21ab4e
+        xlator_list_t       **trav_p             = NULL;
21ab4e
+        int                   count              = 0;
21ab4e
+        gf_boolean_t          victim_found       = _gf_false;
21ab4e
 
21ab4e
         this = data;
21ab4e
         priv = this->private;
21ab4e
@@ -1921,6 +1924,22 @@ abort:
21ab4e
                 if (ret == 0)
21ab4e
                         kill (getpid(), SIGKILL);
21ab4e
 
21ab4e
+        } else {
21ab4e
+                for (trav_p = &top->children; *trav_p;
21ab4e
+                     trav_p = &(*trav_p)->next) {
21ab4e
+                        victim = (*trav_p)->xlator;
21ab4e
+                        if (victim &&
21ab4e
+                            strcmp (victim->name, priv->base_path) == 0) {
21ab4e
+                                victim_found = _gf_true;
21ab4e
+                                break;
21ab4e
+                        }
21ab4e
+                }
21ab4e
+                if (victim_found) {
21ab4e
+                        top->notify (top, GF_EVENT_TRANSPORT_CLEANUP, victim);
21ab4e
+                        glusterfs_mgmt_pmap_signout (glusterfsd_ctx,
21ab4e
+                                                     priv->base_path);
21ab4e
+                        glusterfs_autoscale_threads (THIS->ctx, -1);
21ab4e
+                }
21ab4e
         }
21ab4e
 
21ab4e
         return NULL;
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e