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.

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>
This commit is contained in:
Kaleb S. KEITHLEY 2017-06-29 14:07:51 -04:00 committed by Jeff Darcy
parent a14475fa83
commit 7039243e18

View File

@ -1026,6 +1026,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);
@ -1278,6 +1284,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;