|
|
74b1de |
From b963fa8bb71963127147d33bf609f439dd5bd107 Mon Sep 17 00:00:00 2001
|
|
|
74b1de |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
74b1de |
Date: Thu, 27 Jun 2019 19:17:29 +0530
|
|
|
74b1de |
Subject: [PATCH 220/221] graph/shd: Use top down approach while cleaning
|
|
|
74b1de |
xlator
|
|
|
74b1de |
|
|
|
74b1de |
We were cleaning xlator from botton to top, which might
|
|
|
74b1de |
lead to problems when upper xlators trying to access
|
|
|
74b1de |
the xlator object loaded below.
|
|
|
74b1de |
|
|
|
74b1de |
One such scenario is when fd_unref happens as part of the
|
|
|
74b1de |
fini call which might lead to calling the releasedir to
|
|
|
74b1de |
lower xlator. This will lead to invalid mem access
|
|
|
74b1de |
|
|
|
74b1de |
Backport of:https://review.gluster.org/#/c/glusterfs/+/22968/
|
|
|
74b1de |
|
|
|
74b1de |
>Change-Id: I8a6cb619256fab0b0c01a2d564fc88287c4415a0
|
|
|
74b1de |
>Updates: bz#1716695
|
|
|
74b1de |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
74b1de |
|
|
|
74b1de |
Change-Id: I22bbf99e9451183b3e0fe61b57b2440ab4163fe5
|
|
|
74b1de |
BUG: 1711939
|
|
|
74b1de |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
74b1de |
Reviewed-on: https://code.engineering.redhat.com/gerrit/174882
|
|
|
74b1de |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
74b1de |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
74b1de |
---
|
|
|
74b1de |
libglusterfs/src/graph.c | 10 +++++++++-
|
|
|
74b1de |
xlators/features/bit-rot/src/stub/bit-rot-stub.c | 1 +
|
|
|
74b1de |
xlators/features/changelog/src/changelog.c | 1 +
|
|
|
74b1de |
xlators/features/cloudsync/src/cloudsync.c | 4 +++-
|
|
|
74b1de |
xlators/features/index/src/index.c | 1 +
|
|
|
74b1de |
xlators/features/quiesce/src/quiesce.c | 1 +
|
|
|
74b1de |
xlators/features/read-only/src/worm.c | 1 +
|
|
|
74b1de |
xlators/features/sdfs/src/sdfs.c | 1 +
|
|
|
74b1de |
xlators/features/selinux/src/selinux.c | 2 ++
|
|
|
74b1de |
xlators/features/trash/src/trash.c | 1 +
|
|
|
74b1de |
10 files changed, 21 insertions(+), 2 deletions(-)
|
|
|
74b1de |
|
|
|
74b1de |
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
|
|
|
74b1de |
index 5b95fd6..172dc61 100644
|
|
|
74b1de |
--- a/libglusterfs/src/graph.c
|
|
|
74b1de |
+++ b/libglusterfs/src/graph.c
|
|
|
74b1de |
@@ -1193,6 +1193,14 @@ glusterfs_graph_fini(glusterfs_graph_t *graph)
|
|
|
74b1de |
if (trav->init_succeeded) {
|
|
|
74b1de |
trav->cleanup_starting = 1;
|
|
|
74b1de |
trav->fini(trav);
|
|
|
74b1de |
+ if (trav->local_pool) {
|
|
|
74b1de |
+ mem_pool_destroy(trav->local_pool);
|
|
|
74b1de |
+ trav->local_pool = NULL;
|
|
|
74b1de |
+ }
|
|
|
74b1de |
+ if (trav->itable) {
|
|
|
74b1de |
+ inode_table_destroy(trav->itable);
|
|
|
74b1de |
+ trav->itable = NULL;
|
|
|
74b1de |
+ }
|
|
|
74b1de |
trav->init_succeeded = 0;
|
|
|
74b1de |
}
|
|
|
74b1de |
trav = trav->next;
|
|
|
74b1de |
@@ -1394,7 +1402,7 @@ glusterfs_graph_cleanup(void *arg)
|
|
|
74b1de |
|
|
|
74b1de |
pthread_mutex_lock(&ctx->cleanup_lock);
|
|
|
74b1de |
{
|
|
|
74b1de |
- glusterfs_graph_deactivate(graph);
|
|
|
74b1de |
+ glusterfs_graph_fini(graph);
|
|
|
74b1de |
glusterfs_graph_destroy(graph);
|
|
|
74b1de |
}
|
|
|
74b1de |
pthread_mutex_unlock(&ctx->cleanup_lock);
|
|
|
74b1de |
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
|
|
|
74b1de |
index 3f48a4b..03446be 100644
|
|
|
74b1de |
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
|
|
|
74b1de |
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
|
|
|
74b1de |
@@ -185,6 +185,7 @@ cleanup_lock:
|
|
|
74b1de |
pthread_mutex_destroy(&priv->lock);
|
|
|
74b1de |
free_mempool:
|
|
|
74b1de |
mem_pool_destroy(priv->local_pool);
|
|
|
74b1de |
+ priv->local_pool = NULL;
|
|
|
74b1de |
free_priv:
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
this->private = NULL;
|
|
|
74b1de |
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
|
|
|
74b1de |
index d9025f3..2862d1e 100644
|
|
|
74b1de |
--- a/xlators/features/changelog/src/changelog.c
|
|
|
74b1de |
+++ b/xlators/features/changelog/src/changelog.c
|
|
|
74b1de |
@@ -2790,6 +2790,7 @@ cleanup_options:
|
|
|
74b1de |
changelog_freeup_options(this, priv);
|
|
|
74b1de |
cleanup_mempool:
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
cleanup_priv:
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
error_return:
|
|
|
74b1de |
diff --git a/xlators/features/cloudsync/src/cloudsync.c b/xlators/features/cloudsync/src/cloudsync.c
|
|
|
74b1de |
index 26e512c..0ad987e 100644
|
|
|
74b1de |
--- a/xlators/features/cloudsync/src/cloudsync.c
|
|
|
74b1de |
+++ b/xlators/features/cloudsync/src/cloudsync.c
|
|
|
74b1de |
@@ -200,8 +200,10 @@ cs_init(xlator_t *this)
|
|
|
74b1de |
|
|
|
74b1de |
out:
|
|
|
74b1de |
if (ret == -1) {
|
|
|
74b1de |
- if (this->local_pool)
|
|
|
74b1de |
+ if (this->local_pool) {
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
+ }
|
|
|
74b1de |
|
|
|
74b1de |
cs_cleanup_private(priv);
|
|
|
74b1de |
|
|
|
74b1de |
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
|
|
|
74b1de |
index 2f2a6d0..4ece7ff 100644
|
|
|
74b1de |
--- a/xlators/features/index/src/index.c
|
|
|
74b1de |
+++ b/xlators/features/index/src/index.c
|
|
|
74b1de |
@@ -2478,6 +2478,7 @@ out:
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
this->private = NULL;
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
}
|
|
|
74b1de |
|
|
|
74b1de |
if (attr_inited)
|
|
|
74b1de |
diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c
|
|
|
74b1de |
index bfd1116..06f58c9 100644
|
|
|
74b1de |
--- a/xlators/features/quiesce/src/quiesce.c
|
|
|
74b1de |
+++ b/xlators/features/quiesce/src/quiesce.c
|
|
|
74b1de |
@@ -2536,6 +2536,7 @@ fini(xlator_t *this)
|
|
|
74b1de |
this->private = NULL;
|
|
|
74b1de |
|
|
|
74b1de |
mem_pool_destroy(priv->local_pool);
|
|
|
74b1de |
+ priv->local_pool = NULL;
|
|
|
74b1de |
LOCK_DESTROY(&priv->lock);
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
out:
|
|
|
74b1de |
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
|
|
|
74b1de |
index 24196f8..7d13180 100644
|
|
|
74b1de |
--- a/xlators/features/read-only/src/worm.c
|
|
|
74b1de |
+++ b/xlators/features/read-only/src/worm.c
|
|
|
74b1de |
@@ -569,6 +569,7 @@ fini(xlator_t *this)
|
|
|
74b1de |
mem_put(priv);
|
|
|
74b1de |
this->private = NULL;
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
out:
|
|
|
74b1de |
return;
|
|
|
74b1de |
}
|
|
|
74b1de |
diff --git a/xlators/features/sdfs/src/sdfs.c b/xlators/features/sdfs/src/sdfs.c
|
|
|
74b1de |
index f0247fd..164c632 100644
|
|
|
74b1de |
--- a/xlators/features/sdfs/src/sdfs.c
|
|
|
74b1de |
+++ b/xlators/features/sdfs/src/sdfs.c
|
|
|
74b1de |
@@ -1429,6 +1429,7 @@ void
|
|
|
74b1de |
fini(xlator_t *this)
|
|
|
74b1de |
{
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
return;
|
|
|
74b1de |
}
|
|
|
74b1de |
|
|
|
74b1de |
diff --git a/xlators/features/selinux/src/selinux.c b/xlators/features/selinux/src/selinux.c
|
|
|
74b1de |
index 58b4c5d..ce5fc90 100644
|
|
|
74b1de |
--- a/xlators/features/selinux/src/selinux.c
|
|
|
74b1de |
+++ b/xlators/features/selinux/src/selinux.c
|
|
|
74b1de |
@@ -256,6 +256,7 @@ out:
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
}
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
}
|
|
|
74b1de |
return ret;
|
|
|
74b1de |
}
|
|
|
74b1de |
@@ -284,6 +285,7 @@ fini(xlator_t *this)
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
|
|
|
74b1de |
return;
|
|
|
74b1de |
}
|
|
|
74b1de |
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
|
|
|
74b1de |
index d668436..eb5007b 100644
|
|
|
74b1de |
--- a/xlators/features/trash/src/trash.c
|
|
|
74b1de |
+++ b/xlators/features/trash/src/trash.c
|
|
|
74b1de |
@@ -2523,6 +2523,7 @@ out:
|
|
|
74b1de |
GF_FREE(priv);
|
|
|
74b1de |
}
|
|
|
74b1de |
mem_pool_destroy(this->local_pool);
|
|
|
74b1de |
+ this->local_pool = NULL;
|
|
|
74b1de |
}
|
|
|
74b1de |
return ret;
|
|
|
74b1de |
}
|
|
|
74b1de |
--
|
|
|
74b1de |
1.8.3.1
|
|
|
74b1de |
|