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