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