From 8e771504ede4fe826607300e9e4c0c7444652cc4 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Tue, 24 Aug 2010 18:51:35 -0700 Subject: [PATCH] tmpfs: Convert dirent malloc zone to a per-mount zone. --- sys/vfs/tmpfs/tmpfs.h | 5 ++++- sys/vfs/tmpfs/tmpfs_vfsops.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/vfs/tmpfs/tmpfs.h b/sys/vfs/tmpfs/tmpfs.h index 39cf5f06ef..8528db8a4e 100644 --- a/sys/vfs/tmpfs/tmpfs.h +++ b/sys/vfs/tmpfs/tmpfs.h @@ -385,9 +385,12 @@ 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 */ + /* Per-mount malloc zones for tmpfs nodes and dirents */ struct malloc_type *tm_node_zone; + struct malloc_type *tm_dirent_zone; + struct objcache_malloc_args tm_node_zone_malloc_args; + struct objcache_malloc_args tm_dirent_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 diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c index df262243e1..9edc68eb3e 100644 --- a/sys/vfs/tmpfs/tmpfs_vfsops.c +++ b/sys/vfs/tmpfs/tmpfs_vfsops.c @@ -67,7 +67,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"); /* --------------------------------------------------------------------- */ @@ -123,9 +122,6 @@ tmpfs_node_fini(void *obj, void *args) objcache_malloc_free(obj, args); } -struct objcache_malloc_args tmpfs_dirent_pool_malloc_args = - { sizeof(struct tmpfs_dirent), M_TMPFS_DIRENT }; - static int tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) { @@ -224,6 +220,7 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) tmp->tm_pages_used = 0; kmalloc_create(&tmp->tm_node_zone, "tmpfs node"); + kmalloc_create(&tmp->tm_dirent_zone, "tmpfs dirent"); kmalloc_raise_limit(tmp->tm_node_zone, sizeof(struct tmpfs_node) * tmp->tm_nodes_max); @@ -231,11 +228,14 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) 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_zone_malloc_args.objsize = sizeof(struct tmpfs_dirent); + tmp->tm_dirent_zone_malloc_args.mtype = tmp->tm_dirent_zone; + tmp->tm_dirent_pool = objcache_create( "tmpfs dirent cache", 0, 0, NULL, NULL, NULL, objcache_malloc_alloc, objcache_malloc_free, - &tmpfs_dirent_pool_malloc_args); + &tmp->tm_dirent_zone_malloc_args); tmp->tm_node_pool = objcache_create( "tmpfs node cache", 0, 0, tmpfs_node_ctor, tmpfs_node_dtor, NULL, @@ -392,8 +392,11 @@ tmpfs_unmount(struct mount *mp, int mntflags) objcache_destroy(tmp->tm_dirent_pool); objcache_destroy(tmp->tm_node_pool); + kmalloc_destroy(&tmp->tm_dirent_zone); kmalloc_destroy(&tmp->tm_node_zone); + tmp->tm_node_zone = tmp->tm_dirent_zone = NULL; + lockuninit(&tmp->allnode_lock); KKASSERT(tmp->tm_pages_used == 0); KKASSERT(tmp->tm_nodes_inuse == 0); -- 2.41.0