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