|
|
21ab4e |
From 67ba8269f798aa5438be63da5c2cb73fe31edc1d Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Jeff Darcy <jdarcy@fb.com>
|
|
|
21ab4e |
Date: Fri, 7 Jul 2017 07:49:45 -0700
|
|
|
21ab4e |
Subject: [PATCH 591/593] gfapi+libglusterfs: fix mem_pools_fini without
|
|
|
21ab4e |
mem_pools_init case
|
|
|
21ab4e |
|
|
|
21ab4e |
The change consists of two parts: make sure it doesn't happen (in
|
|
|
21ab4e |
glfs.c), and make it harmless if it does (in mem-pool.c).
|
|
|
21ab4e |
|
|
|
21ab4e |
Upstream reference :
|
|
|
21ab4e |
>Change-Id: Icb7dda7a45dd3d1ade2ee3991bb6a22c8ec88424
|
|
|
21ab4e |
>BUG: 1468863
|
|
|
21ab4e |
>Signed-off-by: Jeff Darcy <jdarcy@fb.com>
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/17728
|
|
|
21ab4e |
>Tested-by: Jeff Darcy <jeff@pl.atyp.us>
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Icb7dda7a45dd3d1ade2ee3991bb6a22c8ec88424
|
|
|
21ab4e |
BUG: 1477668
|
|
|
21ab4e |
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/114351
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
api/src/glfs.c | 12 ++++++------
|
|
|
21ab4e |
libglusterfs/src/mem-pool.c | 18 ++++++++++++++++--
|
|
|
21ab4e |
2 files changed, 22 insertions(+), 8 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/api/src/glfs.c b/api/src/glfs.c
|
|
|
21ab4e |
index fea30e7..97ddfcb 100644
|
|
|
21ab4e |
--- a/api/src/glfs.c
|
|
|
21ab4e |
+++ b/api/src/glfs.c
|
|
|
21ab4e |
@@ -702,6 +702,12 @@ pub_glfs_new (const char *volname)
|
|
|
21ab4e |
return NULL;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ /*
|
|
|
21ab4e |
+ * Do this as soon as possible in case something else depends on
|
|
|
21ab4e |
+ * pool allocations.
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ mem_pools_init ();
|
|
|
21ab4e |
+
|
|
|
21ab4e |
fs = glfs_new_fs (volname);
|
|
|
21ab4e |
if (!fs)
|
|
|
21ab4e |
return NULL;
|
|
|
21ab4e |
@@ -983,12 +989,6 @@ pub_glfs_init (struct glfs *fs)
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
- /*
|
|
|
21ab4e |
- * Do this as soon as possible in case something else depends on
|
|
|
21ab4e |
- * pool allocations.
|
|
|
21ab4e |
- */
|
|
|
21ab4e |
- mem_pools_init ();
|
|
|
21ab4e |
-
|
|
|
21ab4e |
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = glfs_init_common (fs);
|
|
|
21ab4e |
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
|
|
|
21ab4e |
index 3295bdc..2d89084 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/mem-pool.c
|
|
|
21ab4e |
+++ b/libglusterfs/src/mem-pool.c
|
|
|
21ab4e |
@@ -556,10 +556,24 @@ void
|
|
|
21ab4e |
mem_pools_fini (void)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
pthread_mutex_lock (&init_mutex);
|
|
|
21ab4e |
- GF_ASSERT (init_count > 0);
|
|
|
21ab4e |
- if ((--init_count) == 0) {
|
|
|
21ab4e |
+ switch (init_count) {
|
|
|
21ab4e |
+ case 0:
|
|
|
21ab4e |
+ /*
|
|
|
21ab4e |
+ * If init_count is already zero (as e.g. if somebody called
|
|
|
21ab4e |
+ * this before mem_pools_init) then the sweeper was probably
|
|
|
21ab4e |
+ * never even started so we don't need to stop it. Even if
|
|
|
21ab4e |
+ * there's some crazy circumstance where there is a sweeper but
|
|
|
21ab4e |
+ * init_count is still zero, that just means we'll leave it
|
|
|
21ab4e |
+ * running. Not perfect, but far better than any known
|
|
|
21ab4e |
+ * alternative.
|
|
|
21ab4e |
+ */
|
|
|
21ab4e |
+ break;
|
|
|
21ab4e |
+ case 1:
|
|
|
21ab4e |
(void) pthread_cancel (sweeper_tid);
|
|
|
21ab4e |
(void) pthread_join (sweeper_tid, NULL);
|
|
|
21ab4e |
+ /* Fall through. */
|
|
|
21ab4e |
+ default:
|
|
|
21ab4e |
+ --init_count;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
pthread_mutex_unlock (&init_mutex);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|