f338ef
From 4d65506ddfa0245dcaa13b14ca13b2ea762df37d Mon Sep 17 00:00:00 2001
f338ef
From: Mohammed Rafi KC <rkavunga@redhat.com>
f338ef
Date: Thu, 11 Jul 2019 12:48:51 +0530
f338ef
Subject: [PATCH 243/255] Revert "glusterfsd/cleanup: Protect graph object
f338ef
 under a lock"
f338ef
f338ef
This reverts commit 11b64d494c52004002f900888694d20ef8af6df6.
f338ef
f338ef
BUG: 1471742
f338ef
Change-Id: I2717207d87ad213722de33c24e451502ed4aff48
f338ef
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/175952
f338ef
Tested-by: RHGS Build Bot <nigelb@redhat.com>
f338ef
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
f338ef
---
f338ef
 libglusterfs/src/graph.c                        | 58 ++++++++++---------------
f338ef
 libglusterfs/src/statedump.c                    | 16 ++-----
f338ef
 tests/bugs/glusterd/optimized-basic-testcases.t |  4 +-
f338ef
 3 files changed, 28 insertions(+), 50 deletions(-)
f338ef
f338ef
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
f338ef
index 18fb2d9..4c8b02d 100644
f338ef
--- a/libglusterfs/src/graph.c
f338ef
+++ b/libglusterfs/src/graph.c
f338ef
@@ -1392,12 +1392,8 @@ glusterfs_graph_cleanup(void *arg)
f338ef
     }
f338ef
     pthread_mutex_unlock(&ctx->notify_lock);
f338ef
 
f338ef
-    pthread_mutex_lock(&ctx->cleanup_lock);
f338ef
-    {
f338ef
-        glusterfs_graph_fini(graph);
f338ef
-        glusterfs_graph_destroy(graph);
f338ef
-    }
f338ef
-    pthread_mutex_unlock(&ctx->cleanup_lock);
f338ef
+    glusterfs_graph_fini(graph);
f338ef
+    glusterfs_graph_destroy(graph);
f338ef
 out:
f338ef
     return NULL;
f338ef
 }
f338ef
@@ -1472,37 +1468,31 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
f338ef
 
f338ef
     if (!ctx || !ctx->active || !volfile_obj)
f338ef
         goto out;
f338ef
+    parent_graph = ctx->active;
f338ef
+    graph = volfile_obj->graph;
f338ef
+    if (!graph)
f338ef
+        goto out;
f338ef
+    if (graph->first)
f338ef
+        xl = graph->first;
f338ef
 
f338ef
-    pthread_mutex_lock(&ctx->cleanup_lock);
f338ef
-    {
f338ef
-        parent_graph = ctx->active;
f338ef
-        graph = volfile_obj->graph;
f338ef
-        if (!graph)
f338ef
-            goto unlock;
f338ef
-        if (graph->first)
f338ef
-            xl = graph->first;
f338ef
-
f338ef
-        last_xl = graph->last_xl;
f338ef
-        if (last_xl)
f338ef
-            last_xl->next = NULL;
f338ef
-        if (!xl || xl->cleanup_starting)
f338ef
-            goto unlock;
f338ef
+    last_xl = graph->last_xl;
f338ef
+    if (last_xl)
f338ef
+        last_xl->next = NULL;
f338ef
+    if (!xl || xl->cleanup_starting)
f338ef
+        goto out;
f338ef
 
f338ef
-        xl->cleanup_starting = 1;
f338ef
-        gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_DETACH_STARTED,
f338ef
-               "detaching child %s", volfile_obj->vol_id);
f338ef
+    xl->cleanup_starting = 1;
f338ef
+    gf_msg("mgmt", GF_LOG_INFO, 0, LG_MSG_GRAPH_DETACH_STARTED,
f338ef
+           "detaching child %s", volfile_obj->vol_id);
f338ef
 
f338ef
-        list_del_init(&volfile_obj->volfile_list);
f338ef
-        glusterfs_mux_xlator_unlink(parent_graph->top, xl);
f338ef
-        parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph);
f338ef
-        parent_graph->xl_count -= graph->xl_count;
f338ef
-        parent_graph->leaf_count -= graph->leaf_count;
f338ef
-        default_notify(xl, GF_EVENT_PARENT_DOWN, xl);
f338ef
-        parent_graph->id++;
f338ef
-        ret = 0;
f338ef
-    }
f338ef
-unlock:
f338ef
-    pthread_mutex_unlock(&ctx->cleanup_lock);
f338ef
+    list_del_init(&volfile_obj->volfile_list);
f338ef
+    glusterfs_mux_xlator_unlink(parent_graph->top, xl);
f338ef
+    parent_graph->last_xl = glusterfs_get_last_xlator(parent_graph);
f338ef
+    parent_graph->xl_count -= graph->xl_count;
f338ef
+    parent_graph->leaf_count -= graph->leaf_count;
f338ef
+    default_notify(xl, GF_EVENT_PARENT_DOWN, xl);
f338ef
+    parent_graph->id++;
f338ef
+    ret = 0;
f338ef
 out:
f338ef
     if (!ret) {
f338ef
         list_del_init(&volfile_obj->volfile_list);
f338ef
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
f338ef
index 0d58f8f..0cf80c0 100644
f338ef
--- a/libglusterfs/src/statedump.c
f338ef
+++ b/libglusterfs/src/statedump.c
f338ef
@@ -805,17 +805,11 @@ gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx)
f338ef
     int brick_count = 0;
f338ef
     int len = 0;
f338ef
 
f338ef
+    gf_proc_dump_lock();
f338ef
+
f338ef
     if (!ctx)
f338ef
         goto out;
f338ef
 
f338ef
-    /*
f338ef
-     * Multiplexed daemons can change the active graph when attach/detach
f338ef
-     * is called. So this has to be protected with the cleanup lock.
f338ef
-     */
f338ef
-    if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name))
f338ef
-        pthread_mutex_lock(&ctx->cleanup_lock);
f338ef
-    gf_proc_dump_lock();
f338ef
-
f338ef
     if (!mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name) &&
f338ef
         (ctx && ctx->active)) {
f338ef
         top = ctx->active->first;
f338ef
@@ -929,11 +923,7 @@ gf_proc_dump_info(int signum, glusterfs_ctx_t *ctx)
f338ef
 out:
f338ef
     GF_FREE(dump_options.dump_path);
f338ef
     dump_options.dump_path = NULL;
f338ef
-    if (ctx) {
f338ef
-        gf_proc_dump_unlock();
f338ef
-        if (mgmt_is_multiplexed_daemon(ctx->cmd_args.process_name))
f338ef
-            pthread_mutex_unlock(&ctx->cleanup_lock);
f338ef
-    }
f338ef
+    gf_proc_dump_unlock();
f338ef
 
f338ef
     return;
f338ef
 }
f338ef
diff --git a/tests/bugs/glusterd/optimized-basic-testcases.t b/tests/bugs/glusterd/optimized-basic-testcases.t
f338ef
index 110f1b9..d700b5e 100644
f338ef
--- a/tests/bugs/glusterd/optimized-basic-testcases.t
f338ef
+++ b/tests/bugs/glusterd/optimized-basic-testcases.t
f338ef
@@ -289,9 +289,7 @@ mkdir -p /xyz/var/lib/glusterd/abc
f338ef
 TEST  $CLI volume create "test" $H0:/xyz/var/lib/glusterd/abc
f338ef
 EXPECT 'Created' volinfo_field "test" 'Status';
f338ef
 
f338ef
-#While taking a statedump, there is a TRY_LOCK on call_frame, which might may cause
f338ef
-#failure. So Adding a EXPECT_WITHIN
f338ef
-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "^1$" generate_statedump_and_check_for_glusterd_info
f338ef
+EXPECT "1" generate_statedump_and_check_for_glusterd_info
f338ef
 
f338ef
 cleanup_statedump `pidof glusterd`
f338ef
 cleanup
f338ef
-- 
f338ef
1.8.3.1
f338ef