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