Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs converting readdir in ffs ext2fs from malloc(9) to k...
details: https://anonhg.NetBSD.org/src/rev/3e1ff9f2895b
branches: trunk
changeset: 773084:3e1ff9f2895b
user: para <para%NetBSD.org@localhost>
date: Fri Jan 27 19:22:48 2012 +0000
description:
converting readdir in ffs ext2fs from malloc(9) to kmem(9)
while there allocate ufs mount structs from kmem(9) too
preceding kmem-vmem-pool-patch
releng@ acknowledged
diffstat:
sys/ufs/ext2fs/ext2fs_inode.c | 10 +++---
sys/ufs/ext2fs/ext2fs_lookup.c | 14 +++++-----
sys/ufs/ffs/ffs_inode.c | 10 +++---
sys/ufs/ffs/ffs_vfsops.c | 55 ++++++++++++++++++++++++-----------------
sys/ufs/ufs/ufs_extattr.c | 21 ++++++---------
sys/ufs/ufs/ufs_vfsops.c | 6 ++--
sys/ufs/ufs/ufs_vnops.c | 19 ++++++++------
sys/ufs/ufs/ufs_wapbl.c | 5 +--
8 files changed, 73 insertions(+), 67 deletions(-)
diffs (truncated from 562 to 300 lines):
diff -r 9d906ab1fc4a -r 3e1ff9f2895b sys/ufs/ext2fs/ext2fs_inode.c
--- a/sys/ufs/ext2fs/ext2fs_inode.c Fri Jan 27 18:52:47 2012 +0000
+++ b/sys/ufs/ext2fs/ext2fs_inode.c Fri Jan 27 19:22:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_inode.c,v 1.74 2011/06/16 09:21:03 hannken Exp $ */
+/* $NetBSD: ext2fs_inode.c,v 1.75 2012/01/27 19:22:48 para Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.74 2011/06/16 09:21:03 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.75 2012/01/27 19:22:48 para Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -70,7 +70,7 @@
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/trace.h>
#include <sys/resourcevar.h>
#include <sys/kauth.h>
@@ -499,7 +499,7 @@
bap = (int32_t *)bp->b_data; /* XXX ondisk32 */
if (lastbn >= 0) {
/* XXX ondisk32 */
- copy = malloc(fs->e2fs_bsize, M_TEMP, M_WAITOK);
+ copy = kmem_alloc(fs->e2fs_bsize, KM_SLEEP);
memcpy((void *)copy, (void *)bap, (u_int)fs->e2fs_bsize);
memset((void *)&bap[last + 1], 0,
(u_int)(NINDIR(fs) - (last + 1)) * sizeof (uint32_t));
@@ -548,7 +548,7 @@
}
if (copy != NULL) {
- free(copy, M_TEMP);
+ kmem_free(copy, fs->e2fs_bsize);
} else {
brelse(bp, BC_INVAL);
}
diff -r 9d906ab1fc4a -r 3e1ff9f2895b sys/ufs/ext2fs/ext2fs_lookup.c
--- a/sys/ufs/ext2fs/ext2fs_lookup.c Fri Jan 27 18:52:47 2012 +0000
+++ b/sys/ufs/ext2fs/ext2fs_lookup.c Fri Jan 27 19:22:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_lookup.c,v 1.66 2011/07/12 16:59:48 dholland Exp $ */
+/* $NetBSD: ext2fs_lookup.c,v 1.67 2012/01/27 19:22:48 para Exp $ */
/*
* Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.66 2011/07/12 16:59:48 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.67 2012/01/27 19:22:48 para Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,6 +57,7 @@
#include <sys/file.h>
#include <sys/mount.h>
#include <sys/vnode.h>
+#include <sys/kmem.h>
#include <sys/malloc.h>
#include <sys/dirent.h>
#include <sys/kauth.h>
@@ -167,15 +168,14 @@
aiov.iov_len = e2fs_count;
auio.uio_resid = e2fs_count;
UIO_SETUP_SYSSPACE(&auio);
- dirbuf = malloc(e2fs_count, M_TEMP, M_WAITOK);
- dstd = malloc(sizeof(struct dirent), M_TEMP, M_WAITOK | M_ZERO);
+ dirbuf = kmem_alloc(e2fs_count, KM_SLEEP);
+ dstd = kmem_zalloc(sizeof(struct dirent), KM_SLEEP);
if (ap->a_ncookies) {
nc = e2fs_count / _DIRENT_MINSIZE((struct dirent *)0);
ncookies = nc;
cookies = malloc(sizeof (off_t) * ncookies, M_TEMP, M_WAITOK);
*ap->a_cookies = cookies;
}
- memset(dirbuf, 0, e2fs_count);
aiov.iov_base = dirbuf;
error = VOP_READ(ap->a_vp, &auio, 0, ap->a_cred);
@@ -209,8 +209,8 @@
/* we need to correct uio_offset */
uio->uio_offset = off;
}
- free(dirbuf, M_TEMP);
- free(dstd, M_TEMP);
+ kmem_free(dirbuf, e2fs_count);
+ kmem_free(dstd, sizeof(*dstd));
*ap->a_eofflag = ext2fs_size(VTOI(ap->a_vp)) <= uio->uio_offset;
if (ap->a_ncookies) {
if (error) {
diff -r 9d906ab1fc4a -r 3e1ff9f2895b sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c Fri Jan 27 18:52:47 2012 +0000
+++ b/sys/ufs/ffs/ffs_inode.c Fri Jan 27 19:22:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_inode.c,v 1.108 2011/11/23 19:42:10 bouyer Exp $ */
+/* $NetBSD: ffs_inode.c,v 1.109 2012/01/27 19:22:49 para Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.108 2011/11/23 19:42:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.109 2012/01/27 19:22:49 para Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -75,7 +75,7 @@
#include <sys/fstrans.h>
#include <sys/kauth.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
@@ -621,7 +621,7 @@
else
bap2 = (int64_t *)bp->b_data;
if (lastbn >= 0) {
- copy = malloc(fs->fs_bsize, M_TEMP, M_WAITOK);
+ copy = kmem_alloc(fs->fs_bsize, KM_SLEEP);
memcpy((void *)copy, bp->b_data, (u_int)fs->fs_bsize);
for (i = last + 1; i < NINDIR(fs); i++)
BAP_ASSIGN(ip, i, 0);
@@ -676,7 +676,7 @@
}
if (copy != NULL) {
- free(copy, M_TEMP);
+ kmem_free(copy, fs->fs_bsize);
} else {
brelse(bp, BC_INVAL);
}
diff -r 9d906ab1fc4a -r 3e1ff9f2895b sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Fri Jan 27 18:52:47 2012 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Fri Jan 27 19:22:48 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.272 2012/01/03 15:44:00 pgoyette Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.273 2012/01/27 19:22:49 para Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.272 2012/01/03 15:44:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.273 2012/01/27 19:22:49 para Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -85,7 +85,7 @@
#include <sys/disklabel.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/pool.h>
#include <sys/lock.h>
#include <sys/sysctl.h>
@@ -648,7 +648,7 @@
brelse(bp, 0);
return (error);
}
- newfs = malloc(fs->fs_sbsize, M_UFSMNT, M_WAITOK);
+ newfs = kmem_alloc(fs->fs_sbsize, KM_SLEEP);
memcpy(newfs, bp->b_data, fs->fs_sbsize);
#ifdef FFS_EI
if (ump->um_flags & UFS_NEEDSWAP) {
@@ -662,7 +662,7 @@
newfs->fs_bsize > MAXBSIZE ||
newfs->fs_bsize < sizeof(struct fs)) {
brelse(bp, 0);
- free(newfs, M_UFSMNT);
+ kmem_free(newfs, fs->fs_sbsize);
return (EIO); /* XXX needs translation */
}
/* Store off old fs_sblockloc for fs_oldfscompat_read. */
@@ -679,7 +679,7 @@
newfs->fs_active = fs->fs_active;
memcpy(fs, newfs, (u_int)fs->fs_sbsize);
brelse(bp, 0);
- free(newfs, M_UFSMNT);
+ kmem_free(newfs, fs->fs_sbsize);
/* Recheck for apple UFS filesystem */
ump->um_flags &= ~UFS_ISAPPLEUFS;
@@ -865,6 +865,7 @@
int32_t *lp;
kauth_cred_t cred;
u_int32_t sbsize = 8192; /* keep gcc happy*/
+ u_int32_t allocsbsize;
int32_t fsbsize;
dev = devvp->v_rdev;
@@ -889,7 +890,7 @@
if (error)
return error;
- ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
+ ump = kmem_alloc(sizeof(*ump), KM_SLEEP);
memset(ump, 0, sizeof *ump);
mutex_init(&ump->um_lock, MUTEX_DEFAULT, IPL_NONE);
error = ffs_snapshot_init(ump);
@@ -986,7 +987,7 @@
break;
}
- fs = malloc((u_long)sbsize, M_UFSMNT, M_WAITOK);
+ fs = kmem_alloc((u_long)sbsize, KM_SLEEP);
memcpy(fs, bp->b_data, sbsize);
ump->um_fs = fs;
@@ -1023,7 +1024,7 @@
/* Force a re-read of the superblock */
brelse(bp, BC_INVAL);
bp = NULL;
- free(fs, M_UFSMNT);
+ kmem_free(fs, sbsize);
fs = NULL;
goto sbagain;
}
@@ -1150,7 +1151,8 @@
if (fs->fs_contigsumsize > 0)
bsize += fs->fs_ncg * sizeof(int32_t);
bsize += fs->fs_ncg * sizeof(*fs->fs_contigdirs);
- space = malloc((u_long)bsize, M_UFSMNT, M_WAITOK);
+ allocsbsize = bsize;
+ space = kmem_alloc((u_long)allocsbsize, KM_SLEEP);
fs->fs_csp = space;
for (i = 0; i < blks; i += fs->fs_frag) {
bsize = fs->fs_bsize;
@@ -1159,7 +1161,7 @@
error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), bsize,
cred, 0, &bp);
if (error) {
- free(fs->fs_csp, M_UFSMNT);
+ kmem_free(fs->fs_csp, allocsbsize);
goto out;
}
#ifdef FFS_EI
@@ -1243,7 +1245,7 @@
error = ffs_wapbl_start(mp);
if (error) {
- free(fs->fs_csp, M_UFSMNT);
+ kmem_free(fs->fs_csp, allocsbsize);
goto out;
}
}
@@ -1252,7 +1254,7 @@
#ifdef QUOTA2
error = ffs_quota2_mount(mp);
if (error) {
- free(fs->fs_csp, M_UFSMNT);
+ kmem_free(fs->fs_csp, allocsbsize);
goto out;
}
#else
@@ -1263,7 +1265,7 @@
(mp->mnt_flag & MNT_FORCE) ? "" : ", not mounting");
if ((mp->mnt_flag & MNT_FORCE) == 0) {
error = EINVAL;
- free(fs->fs_csp, M_UFSMNT);
+ kmem_free(fs->fs_csp, allocsbsize);
goto out;
}
}
@@ -1290,15 +1292,15 @@
fstrans_unmount(mp);
if (fs)
- free(fs, M_UFSMNT);
+ kmem_free(fs, fs->fs_sbsize);
devvp->v_specmountpoint = NULL;
if (bp)
brelse(bp, bset);
if (ump) {
if (ump->um_oldfscompat)
- free(ump->um_oldfscompat, M_UFSMNT);
+ kmem_free(ump->um_oldfscompat, 512 + 3*sizeof(int32_t));
mutex_destroy(&ump->um_lock);
- free(ump, M_UFSMNT);
+ kmem_free(ump, sizeof(*ump));
mp->mnt_data = NULL;
}
return (error);
@@ -1322,8 +1324,8 @@
Home |
Main Index |
Thread Index |
Old Index