Module Name: src
Committed By: jdolecek
Date: Tue Apr 7 08:35:49 UTC 2020
Modified Files:
src/sys/miscfs/kernfs: kernfs_vfsops.c
Log Message:
switch to kmem_zalloc() instead of malloc() for struct kernfs_mount
To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/kernfs/kernfs_vfsops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/miscfs/kernfs/kernfs_vfsops.c
diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.100
--- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99 Mon Mar 16 21:20:11 2020
+++ src/sys/miscfs/kernfs/kernfs_vfsops.c Tue Apr 7 08:35:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $ */
+/* $NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $ */
/*
* Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/dirent.h>
-#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/kauth.h>
#include <sys/module.h>
@@ -65,8 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop
MODULE(MODULE_CLASS_VFS, kernfs, NULL);
-MALLOC_JUSTDEFINE(M_KERNFSMNT, "kernfs mount", "kernfs mount structures");
-
dev_t rrootdev = NODEV;
kmutex_t kfs_lock;
@@ -78,7 +75,6 @@ void
kernfs_init(void)
{
- malloc_type_attach(M_KERNFSMNT);
mutex_init(&kfs_lock, MUTEX_DEFAULT, IPL_NONE);
}
@@ -93,7 +89,6 @@ kernfs_done(void)
{
mutex_destroy(&kfs_lock);
- malloc_type_detach(M_KERNFSMNT);
}
void
@@ -141,7 +136,7 @@ kernfs_mount(struct mount *mp, const cha
if (mp->mnt_flag & MNT_UPDATE)
return (EOPNOTSUPP);
- fmp = malloc(sizeof(struct kernfs_mount), M_KERNFSMNT, M_WAITOK|M_ZERO);
+ fmp = kmem_zalloc(sizeof(struct kernfs_mount), KM_SLEEP);
TAILQ_INIT(&fmp->nodelist);
mp->mnt_stat.f_namemax = KERNFS_MAXNAMLEN;
@@ -151,7 +146,7 @@ kernfs_mount(struct mount *mp, const cha
if ((error = set_statvfs_info(path, UIO_USERSPACE, "kernfs",
UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, l)) != 0) {
- free(fmp, M_KERNFSMNT);
+ kmem_free(fmp, sizeof(struct kernfs_mount));
return error;
}
@@ -181,7 +176,7 @@ kernfs_unmount(struct mount *mp, int mnt
/*
* Finally, throw away the kernfs_mount structure
*/
- free(mp->mnt_data, M_KERNFSMNT);
+ kmem_free(mp->mnt_data, sizeof(struct kernfs_mount));
mp->mnt_data = NULL;
return (0);
}