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