50dc83
From 8cc6d8af00303c445b94715c92fe9e3e01edb867 Mon Sep 17 00:00:00 2001
50dc83
From: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
Date: Mon, 24 Jun 2019 15:49:04 +0530
50dc83
Subject: [PATCH 218/221] graph/shd: Use glusterfs_graph_deactivate to free the
50dc83
 xl rec
50dc83
50dc83
We were using glusterfs_graph_fini to free the xl rec from
50dc83
glusterfs_process_volfp as well as glusterfs_graph_cleanup.
50dc83
50dc83
Instead we can use glusterfs_graph_deactivate, which does
50dc83
fini as well as other common rec free.
50dc83
50dc83
Backport of:https://review.gluster.org/#/c/glusterfs/+/22904/
50dc83
50dc83
>Change-Id: Ie4a5f2771e5254aa5ed9f00c3672a6d2cc8e4bc1
50dc83
>Updates: bz#1716695
50dc83
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
50dc83
Change-Id: I09d7124366bc690ceca9e8d0adee8a0dc8081091
50dc83
BUG: 1711939
50dc83
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/174814
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           | 2 +-
50dc83
 libglusterfs/src/xlator.c          | 9 ++++++++-
50dc83
 xlators/features/shard/src/shard.c | 3 +++
50dc83
 3 files changed, 12 insertions(+), 2 deletions(-)
50dc83
50dc83
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
50dc83
index 27d9335..5b95fd6 100644
50dc83
--- a/libglusterfs/src/graph.c
50dc83
+++ b/libglusterfs/src/graph.c
50dc83
@@ -1394,7 +1394,7 @@ glusterfs_graph_cleanup(void *arg)
50dc83
 
50dc83
     pthread_mutex_lock(&ctx->cleanup_lock);
50dc83
     {
50dc83
-        glusterfs_graph_fini(graph);
50dc83
+        glusterfs_graph_deactivate(graph);
50dc83
         glusterfs_graph_destroy(graph);
50dc83
     }
50dc83
     pthread_mutex_unlock(&ctx->cleanup_lock);
50dc83
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
50dc83
index 71e1ed4..d9d3441 100644
50dc83
--- a/libglusterfs/src/xlator.c
50dc83
+++ b/libglusterfs/src/xlator.c
50dc83
@@ -659,6 +659,7 @@ xlator_fini_rec(xlator_t *xl)
50dc83
         trav = trav->next;
50dc83
     }
50dc83
 
50dc83
+    xl->cleanup_starting = 1;
50dc83
     if (xl->init_succeeded) {
50dc83
         if (xl->fini) {
50dc83
             old_THIS = THIS;
50dc83
@@ -666,8 +667,14 @@ xlator_fini_rec(xlator_t *xl)
50dc83
 
50dc83
             xl->fini(xl);
50dc83
 
50dc83
-            if (xl->local_pool)
50dc83
+            if (xl->local_pool) {
50dc83
                 mem_pool_destroy(xl->local_pool);
50dc83
+                xl->local_pool = NULL;
50dc83
+            }
50dc83
+            if (xl->itable) {
50dc83
+                inode_table_destroy(xl->itable);
50dc83
+                xl->itable = NULL;
50dc83
+            }
50dc83
 
50dc83
             THIS = old_THIS;
50dc83
         } else {
50dc83
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
50dc83
index b248767..31c7eec 100644
50dc83
--- a/xlators/features/shard/src/shard.c
50dc83
+++ b/xlators/features/shard/src/shard.c
50dc83
@@ -6785,6 +6785,9 @@ fini(xlator_t *this)
50dc83
 
50dc83
     GF_VALIDATE_OR_GOTO("shard", this, out);
50dc83
 
50dc83
+    /*Itable was not created by shard, hence setting to NULL.*/
50dc83
+    this->itable = NULL;
50dc83
+
50dc83
     mem_pool_destroy(this->local_pool);
50dc83
     this->local_pool = NULL;
50dc83
 
50dc83
-- 
50dc83
1.8.3.1
50dc83