From dcaa8a41662f2b0cf579a6e912564c9fc8275ac1 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Tue, 24 Aug 2010 18:37:54 -0700 Subject: [PATCH] tmpfs: Convert tmpfs node allocation zone into a per-mount pool. Each tmpfs mount tracked the number and max nodes separately, leading to an inaccurate measure of the limit of the tmpfs node malloc zone. We now create a kmalloc zone for each mount, as in HAMMER (hammer_vfsops.c). --- sys/vfs/tmpfs/tmpfs.h | 4 ++++ sys/vfs/tmpfs/tmpfs_vfsops.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/vfs/tmpfs/tmpfs.h b/sys/vfs/tmpfs/tmpfs.h index 343e931d83..39cf5f06ef 100644 --- a/sys/vfs/tmpfs/tmpfs.h +++ b/sys/vfs/tmpfs/tmpfs.h @@ -385,6 +385,10 @@ struct tmpfs_mount { /* All node lock to protect the node list and tmp_pages_used */ struct lock allnode_lock; + /* Per-mount malloc zone for tmpfs nodes */ + struct malloc_type *tm_node_zone; + struct objcache_malloc_args tm_node_zone_malloc_args; + /* Pools used to store file system meta data. These are not shared * across several instances of tmpfs for the reasons described in * tmpfs_pool.c. */ diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c index f9d8cdcd24..df262243e1 100644 --- a/sys/vfs/tmpfs/tmpfs_vfsops.c +++ b/sys/vfs/tmpfs/tmpfs_vfsops.c @@ -68,7 +68,6 @@ MALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures"); MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names"); MALLOC_DEFINE(M_TMPFS_DIRENT, "tmpfs dirent", "tmpfs dirent structures"); -MALLOC_DEFINE(M_TMPFS_NODE, "tmpfs node", "tmpfs node structures"); /* --------------------------------------------------------------------- */ @@ -126,8 +125,6 @@ tmpfs_node_fini(void *obj, void *args) struct objcache_malloc_args tmpfs_dirent_pool_malloc_args = { sizeof(struct tmpfs_dirent), M_TMPFS_DIRENT }; -struct objcache_malloc_args tmpfs_node_pool_malloc_args = - { sizeof(struct tmpfs_node), M_TMPFS_NODE }; static int tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) @@ -226,9 +223,14 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) tmp->tm_pages_max = pages; tmp->tm_pages_used = 0; - kmalloc_raise_limit(M_TMPFS_NODE, sizeof(struct tmpfs_node) * + kmalloc_create(&tmp->tm_node_zone, "tmpfs node"); + + kmalloc_raise_limit(tmp->tm_node_zone, sizeof(struct tmpfs_node) * tmp->tm_nodes_max); + tmp->tm_node_zone_malloc_args.objsize = sizeof(struct tmpfs_node); + tmp->tm_node_zone_malloc_args.mtype = tmp->tm_node_zone; + tmp->tm_dirent_pool = objcache_create( "tmpfs dirent cache", 0, 0, NULL, NULL, NULL, @@ -238,7 +240,7 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) 0, 0, tmpfs_node_ctor, tmpfs_node_dtor, NULL, tmpfs_node_init, tmpfs_node_fini, - &tmpfs_node_pool_malloc_args); + &tmp->tm_node_zone_malloc_args); /* Allocate the root node. */ error = tmpfs_alloc_node(tmp, VDIR, root_uid, root_gid, @@ -390,6 +392,8 @@ tmpfs_unmount(struct mount *mp, int mntflags) objcache_destroy(tmp->tm_dirent_pool); objcache_destroy(tmp->tm_node_pool); + kmalloc_destroy(&tmp->tm_node_zone); + lockuninit(&tmp->allnode_lock); KKASSERT(tmp->tm_pages_used == 0); KKASSERT(tmp->tm_nodes_inuse == 0); -- 2.41.0