Blob Blame History Raw
From d47236ca9b61e4c4ad8aa53713eb7b420d36c0ef Mon Sep 17 00:00:00 2001
From: "Kaleb S. KEITHLEY" <kkeithle@redhat.com>
Date: Thu, 29 Jun 2017 14:07:51 -0400
Subject: [PATCH 590/593] gfapi: add mem_pools_init and mem_pools_fini calls

These are both needed because GFAPI clients are a bit unique.  They can
be long-running, so they can potentially benefit from the memory
reclamation that mem_pools_init will enable.  On the other hand, they
might completely tear down their Gluster environment well before the
process exits, so they need mem_pools_fini as well.

Our main and auxiliary daemons do need mem_pools_init but don't need to
call it themselves because that's handled for them in glusterfsd.c right
after they daemonize.  They don't need mem_pools_fini, because the only
place they could *safely* call it is right before exit and then it won't
do them any good.  Transient processes (e.g. gf_attach) don't benefit
from either because, well, they're transient.  They'll be gone before
memory reclamation matters.

Upstream reference :
>Change-Id: I611cf77d8b408b3ecfc00664e8da294edde9e57a
>Signed-off-by: Jeff Darcy <jdarcy@fb.com>
>Reviewed-on: https://review.gluster.org/17666
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Tested-by: Jeff Darcy <jeff@pl.atyp.us>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>

Change-Id: I611cf77d8b408b3ecfc00664e8da294edde9e57a
BUG: 1477668
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/114350
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 api/src/glfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/api/src/glfs.c b/api/src/glfs.c
index 253b98d..fea30e7 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -983,6 +983,12 @@ pub_glfs_init (struct glfs *fs)
 		return ret;
 	}
 
+        /*
+         * Do this as soon as possible in case something else depends on
+         * pool allocations.
+         */
+        mem_pools_init ();
+
         __GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
 
 	ret = glfs_init_common (fs);
@@ -1232,6 +1238,12 @@ pub_glfs_fini (struct glfs *fs)
 free_fs:
         glfs_free_from_ctx (fs);
 
+        /*
+         * Do this as late as possible in case anything else has (or
+         * grows) a dependency on mem-pool allocations.
+         */
+        mem_pools_fini ();
+
 fail:
         if (!ret)
                 ret = err;
-- 
1.8.3.1