From e38aaba8f021e6def58a61effa27cb8f5d2016d9 Mon Sep 17 00:00:00 2001 From: Pedro Martelletto Date: Sat, 17 Dec 2005 13:56:03 +0000 Subject: Remove the 'on disk' inode (dinode) from the 'in memory' inode in UFS. Instead of having the dinode inside the inode structure itself, we now have just a pointer to it, and use a separate pool to allocate dinodes as needed. Inspiration from FreeBSD, various testing for a while, thanks. --- sys/ufs/ffs/ffs_extern.h | 5 +-- sys/ufs/ffs/ffs_inode.c | 10 +++--- sys/ufs/ffs/ffs_softdep.c | 12 ++++--- sys/ufs/ffs/ffs_vfsops.c | 27 ++++++++++----- sys/ufs/ffs/ffs_vnops.c | 14 +++++--- sys/ufs/ufs/inode.h | 83 ++++++++++++++++++++++++----------------------- sys/ufs/ufs/ufs_inode.c | 6 ++-- 7 files changed, 90 insertions(+), 67 deletions(-) (limited to 'sys/ufs') diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 3b453035304..2645dfff7e7 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_extern.h,v 1.25 2005/11/09 15:35:53 pedro Exp $ */ +/* $OpenBSD: ffs_extern.h,v 1.26 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /* @@ -194,4 +194,5 @@ extern int (**ffs_fifoop_p)(void *); #define FFS_FIFOOPS NULL #endif -extern struct pool ffs_ino_pool; +extern struct pool ffs_ino_pool; /* memory pool for inodes */ +extern struct pool ffs_dinode1_pool; /* memory pool for UFS1 dinodes */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 695209c2780..b0adb471c54 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.40 2005/11/09 15:35:53 pedro Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.41 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -118,8 +118,8 @@ ffs_update(struct inode *ip, struct timespec *atime, * fix until fsck has been changed to do the update. */ if (fs->fs_inodefmt < FS_44INODEFMT) { - ip->i_din1.di_ouid = ip->i_ffs_uid; /* XXX */ - ip->i_din1.di_ogid = ip->i_ffs_gid; /* XXX */ + ip->i_din1->di_ouid = ip->i_ffs_uid; + ip->i_din1->di_ogid = ip->i_ffs_gid; } error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), @@ -135,7 +135,7 @@ ffs_update(struct inode *ip, struct timespec *atime, panic("ffs_update: bad link cnt"); *((struct ufs1_dinode *)bp->b_data + - ino_to_fsbo(fs, ip->i_number)) = ip->i_din1; + ino_to_fsbo(fs, ip->i_number)) = *ip->i_din1; if (waitfor && !DOINGASYNC(vp)) { return (bwrite(bp)); } else { @@ -180,7 +180,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) if (ovp->v_type == VLNK && (oip->i_ffs_size < ovp->v_mount->mnt_maxsymlinklen || (ovp->v_mount->mnt_maxsymlinklen == 0 && - oip->i_din1.di_blocks == 0))) { + oip->i_din1->di_blocks == 0))) { #ifdef DIAGNOSTIC if (length != 0) panic("ffs_truncate: partial truncate of symlink"); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 519b3c85948..747ed4fe0b8 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_softdep.c,v 1.65 2005/12/14 22:04:56 pedro Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.66 2005/12/17 13:56:01 pedro Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. * @@ -1630,7 +1630,7 @@ newfreefrag(ip, blkno, size) panic("newfreefrag: frag size"); freefrag = pool_get(&freefrag_pool, PR_WAITOK); freefrag->ff_list.wk_type = D_FREEFRAG; - freefrag->ff_state = ip->i_ffs_uid & ~ONWORKLIST; /* XXX - used below */ + freefrag->ff_state = ip->i_ffs_uid & ~ONWORKLIST; /* used below */ freefrag->ff_inum = ip->i_number; freefrag->ff_mnt = ITOV(ip)->v_mount; freefrag->ff_devvp = ip->i_devvp; @@ -1648,13 +1648,15 @@ handle_workitem_freefrag(freefrag) struct freefrag *freefrag; { struct inode tip; + struct ufs1_dinode dtip1; tip.i_vnode = NULL; + tip.i_din1 = &dtip1; tip.i_fs = VFSTOUFS(freefrag->ff_mnt)->um_fs; tip.i_ump = VFSTOUFS(freefrag->ff_mnt); tip.i_dev = freefrag->ff_devvp->v_rdev; tip.i_number = freefrag->ff_inum; - tip.i_ffs_uid = freefrag->ff_state & ~ONWORKLIST; /* XXX - set above */ + tip.i_ffs_uid = freefrag->ff_state & ~ONWORKLIST; /* set above */ ffs_blkfree(&tip, freefrag->ff_blkno, freefrag->ff_fragsize); pool_put(&freefrag_pool, freefrag); } @@ -1949,7 +1951,7 @@ softdep_setup_freeblocks(ip, length) (int)fs->fs_bsize, NOCRED, &bp)) != 0) softdep_error("softdep_setup_freeblocks", error); *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ip->i_number)) = - ip->i_din1; + *ip->i_din1; /* * Find and eliminate any inode dependencies. */ @@ -2367,6 +2369,7 @@ handle_workitem_freeblocks(freeblks) struct freeblks *freeblks; { struct inode tip; + struct ufs1_dinode dtip1; daddr_t bn; struct fs *fs; int i, level, bsize; @@ -2374,6 +2377,7 @@ handle_workitem_freeblocks(freeblks) int error, allerror = 0; ufs_lbn_t baselbns[NIADDR], tmpval; + tip.i_din1 = &dtip1; tip.i_fs = fs = VFSTOUFS(freeblks->fb_mnt)->um_fs; tip.i_number = freeblks->fb_previousinum; tip.i_ump = VFSTOUFS(freeblks->fb_mnt); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index fe54fa0b9e7..bf105f0f649 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.76 2005/11/30 17:01:17 pedro Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.77 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -100,6 +100,7 @@ extern u_long nextgennumber; */ struct pool ffs_ino_pool; +struct pool ffs_dinode1_pool; int ffs_mountroot(void) @@ -488,7 +489,7 @@ ffs_reload_vnode(struct vnode *vp, void *args) vput(vp); return (error); } - ip->i_din1 = *((struct ufs1_dinode *)bp->b_data + + *ip->i_din1 = *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fra->fs, ip->i_number)); ip->i_effnlink = ip->i_ffs_nlink; brelse(bp); @@ -1087,6 +1088,7 @@ ffs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) { register struct fs *fs; register struct inode *ip; + struct ufs1_dinode *dp1; struct ufsmount *ump; struct buf *bp; struct vnode *vp; @@ -1157,12 +1159,17 @@ retry: *vpp = NULL; return (error); } - ip->i_din1 = *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ino)); + + ip->i_din1 = pool_get(&ffs_dinode1_pool, PR_WAITOK); + dp1 = (struct ufs1_dinode *) bp->b_data + ino_to_fsbo(fs, ino); + *ip->i_din1 = *dp1; + + brelse(bp); + if (DOINGSOFTDEP(vp)) softdep_load_inodeblock(ip); else ip->i_effnlink = ip->i_ffs_nlink; - brelse(bp); /* * Initialize the vnode from the inode, check for aliases. @@ -1189,10 +1196,10 @@ retry: * Ensure that uid and gid are correct. This is a temporary * fix until fsck has been changed to do the update. */ - if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ - ip->i_ffs_uid = ip->i_din1.di_ouid; /* XXX */ - ip->i_ffs_gid = ip->i_din1.di_ogid; /* XXX */ - } /* XXX */ + if (fs->fs_inodefmt < FS_44INODEFMT) { + ip->i_ffs_uid = ip->i_din1->di_ouid; + ip->i_ffs_gid = ip->i_din1->di_ogid; + } *vpp = vp; return (0); @@ -1312,8 +1319,12 @@ ffs_init(struct vfsconf *vfsp) return (0); done = 1; + pool_init(&ffs_ino_pool, sizeof(struct inode), 0, 0, 0, "ffsino", &pool_allocator_nointr); + pool_init(&ffs_dinode1_pool, sizeof(struct ufs1_dinode), 0, 0, 0, + "dino1pl", &pool_allocator_nointr); + softdep_initialize(); return (ufs_init(vfsp)); diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index f8ce4ed842f..49e80fb49ec 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vnops.c,v 1.35 2005/11/08 02:29:51 pedro Exp $ */ +/* $OpenBSD: ffs_vnops.c,v 1.36 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */ /* @@ -288,14 +288,20 @@ ffs_reclaim(void *v) struct vnode *a_vp; struct proc *a_p; } */ *ap = v; - register struct vnode *vp = ap->a_vp; + struct vnode *vp = ap->a_vp; + struct inode *ip = VTOI(vp); int error; if ((error = ufs_reclaim(vp, ap->a_p)) != 0) return (error); - /* XXX - same for for both mfs and ffs */ - pool_put(&ffs_ino_pool, vp->v_data); + + if (ip->i_din1 != NULL) + pool_put(&ffs_dinode1_pool, ip->i_din1); + + pool_put(&ffs_ino_pool, ip); + vp->v_data = NULL; + return (0); } diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index fead61b28ce..793fddd86d9 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.29 2005/12/11 20:46:28 pedro Exp $ */ +/* $OpenBSD: inode.h,v 1.30 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -113,11 +113,13 @@ struct inode { * The on-disk dinode itself. */ union { - struct ufs1_dinode ffs1_din; + struct ufs1_dinode *ffs1_din; + struct ufs2_dinode *ffs2_din; struct ext2fs_dinode *e2fs_din; } dinode_u; -#define i_din1 dinode_u.ffs1_din +#define i_din1 dinode_u.ffs1_din +#define i_din2 dinode_u.ffs2_din #define i_e2din dinode_u.e2fs_din struct inode_vtbl *i_vtbl; @@ -160,50 +162,49 @@ struct inode_vtbl { ((ip)->i_vtbl->iv_bufatoff)((ip), (offset), (res), (bpp)) -#define i_ffs_atime i_din1.di_atime -#define i_ffs_atimensec i_din1.di_atimensec -#define i_ffs_blocks i_din1.di_blocks -#define i_ffs_ctime i_din1.di_ctime -#define i_ffs_ctimensec i_din1.di_ctimensec -#define i_ffs_db i_din1.di_db -#define i_ffs_flags i_din1.di_flags -#define i_ffs_gen i_din1.di_gen -#define i_ffs_gid i_din1.di_gid -#define i_ffs_ib i_din1.di_ib -#define i_ffs_mode i_din1.di_mode -#define i_ffs_mtime i_din1.di_mtime -#define i_ffs_mtimensec i_din1.di_mtimensec -#define i_ffs_nlink i_din1.di_nlink -#define i_ffs_rdev i_din1.di_rdev -#define i_ffs_shortlink i_din1.di_shortlink -#define i_ffs_size i_din1.di_size -#define i_ffs_uid i_din1.di_uid -#define i_size i_din1.di_size +#define i_ffs_atime i_din1->di_atime +#define i_ffs_atimensec i_din1->di_atimensec +#define i_ffs_blocks i_din1->di_blocks +#define i_ffs_ctime i_din1->di_ctime +#define i_ffs_ctimensec i_din1->di_ctimensec +#define i_ffs_db i_din1->di_db +#define i_ffs_flags i_din1->di_flags +#define i_ffs_gen i_din1->di_gen +#define i_ffs_gid i_din1->di_gid +#define i_ffs_ib i_din1->di_ib +#define i_ffs_mode i_din1->di_mode +#define i_ffs_mtime i_din1->di_mtime +#define i_ffs_mtimensec i_din1->di_mtimensec +#define i_ffs_nlink i_din1->di_nlink +#define i_ffs_rdev i_din1->di_rdev +#define i_ffs_shortlink i_din1->di_shortlink +#define i_ffs_size i_din1->di_size +#define i_ffs_uid i_din1->di_uid +#define i_size i_din1->di_size #ifndef _KERNEL /* * These are here purely for backwards compatibility for userland. * They allow direct references to FFS structures using the old names. */ - -#define i_atime i_din1.di_atime -#define i_atimensec i_din1.di_atimensec -#define i_blocks i_din1.di_blocks -#define i_ctime i_din1.di_ctime -#define i_ctimensec i_din1.di_ctimensec -#define i_db i_din1.di_db -#define i_flags i_din1.di_flags -#define i_gen i_din1.di_gen -#define i_gid i_din1.di_gid -#define i_ib i_din1.di_ib -#define i_mode i_din1.di_mode -#define i_mtime i_din1.di_mtime -#define i_mtimensec i_din1.di_mtimensec -#define i_nlink i_din1.di_nlink -#define i_rdev i_din1.di_rdev -#define i_shortlink i_din1.di_shortlink -#define i_size i_din1.di_size -#define i_uid i_din1.di_uid +#define i_atime i_din1->di_atime +#define i_atimensec i_din1->di_atimensec +#define i_blocks i_din1->di_blocks +#define i_ctime i_din1->di_ctime +#define i_ctimensec i_din1->di_ctimensec +#define i_db i_din1->di_db +#define i_flags i_din1->di_flags +#define i_gen i_din1->di_gen +#define i_gid i_din1->di_gid +#define i_ib i_din1->di_ib +#define i_mode i_din1->di_mode +#define i_mtime i_din1->di_mtime +#define i_mtimensec i_din1->di_mtimensec +#define i_nlink i_din1->di_nlink +#define i_rdev i_din1->di_rdev +#define i_shortlink i_din1->di_shortlink +#define i_size i_din1->di_size +#define i_uid i_din1->di_uid #endif /* _KERNEL */ #define i_e2fs_mode i_e2din->e2di_mode diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index cb4481a3423..a5567576cfb 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_inode.c,v 1.31 2005/11/10 22:01:14 pedro Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.32 2005/12/17 13:56:01 pedro Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -80,7 +80,7 @@ ufs_inactive(void *v) /* * Ignore inodes related to stale file handles. */ - if (ip->i_ffs_mode == 0) + if (ip->i_din1 == NULL || ip->i_ffs_mode == 0) goto out; if (ip->i_ffs_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { @@ -122,7 +122,7 @@ out: * If we are done with the inode, reclaim it * so that it can be reused immediately. */ - if (ip->i_ffs_mode == 0) + if (ip->i_din1 == NULL || ip->i_ffs_mode == 0) vrecycle(vp, NULL, p); return (error); -- cgit v1.2.3