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