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