From 7da876cb7a6c1bad0050ced651ea548c4bd16124 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 20 Jan 2004 03:44:07 +0000 Subject: some pieces of ufs2. help testing otto sturm --- sys/ufs/ext2fs/ext2fs_alloc.c | 4 +++- sys/ufs/ext2fs/ext2fs_subr.c | 7 ++++++- sys/ufs/ext2fs/ext2fs_vfsops.c | 5 +++-- sys/ufs/ext2fs/ext2fs_vnops.c | 3 +-- sys/ufs/ffs/ffs_alloc.c | 3 ++- sys/ufs/ffs/ffs_softdep.c | 8 ++++---- sys/ufs/ffs/ffs_subr.c | 7 ++++++- sys/ufs/ffs/ffs_vfsops.c | 13 +++++++++---- sys/ufs/ffs/fs.h | 11 ++++++++++- sys/ufs/ufs/dinode.h | 35 ++++++++++++++++++++++++++++++++++- sys/ufs/ufs/inode.h | 22 +++++++++++++++++----- sys/ufs/ufs/ufs_inode.c | 3 +-- sys/ufs/ufs/ufs_quota.c | 10 +++++----- sys/ufs/ufs/ufsmount.h | 11 ++++++++++- 14 files changed, 111 insertions(+), 31 deletions(-) (limited to 'sys/ufs') diff --git a/sys/ufs/ext2fs/ext2fs_alloc.c b/sys/ufs/ext2fs/ext2fs_alloc.c index 60bb193f8d6..20fb531ad79 100644 --- a/sys/ufs/ext2fs/ext2fs_alloc.c +++ b/sys/ufs/ext2fs/ext2fs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_alloc.c,v 1.13 2003/08/25 23:26:55 tedu Exp $ */ +/* $OpenBSD: ext2fs_alloc.c,v 1.14 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ext2fs_alloc.c,v 1.10 2001/07/05 08:38:27 toshii Exp $ */ /* @@ -45,6 +45,8 @@ #include #include +#include +#include #include #include diff --git a/sys/ufs/ext2fs/ext2fs_subr.c b/sys/ufs/ext2fs/ext2fs_subr.c index 09609235ce0..1640db5c853 100644 --- a/sys/ufs/ext2fs/ext2fs_subr.c +++ b/sys/ufs/ext2fs/ext2fs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_subr.c,v 1.10 2003/06/02 23:28:22 millert Exp $ */ +/* $OpenBSD: ext2fs_subr.c,v 1.11 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ext2fs_subr.c,v 1.1 1997/06/11 09:34:03 bouyer Exp $ */ /* @@ -37,9 +37,14 @@ #include #include #include +#include #include + #include #include +#include +#include + #include #include diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 5914318ebf7..0fbf8af4fbd 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.30 2003/08/25 23:26:55 tedu Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.31 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -536,6 +536,7 @@ ext2fs_mountfs(devvp, mp, p) bp = NULL; m_fs = ump->um_e2fs; m_fs->e2fs_ronly = ronly; + ump->um_fstype = UM_EXT2FS; if (ronly == 0) { if (m_fs->e2fs.e2fs_state == E2FS_ISCLEAN) m_fs->e2fs.e2fs_state = 0; @@ -853,6 +854,7 @@ ext2fs_vget(mp, ino, vpp) lockinit(&ip->i_lock, PINOD, "inode", 0, 0); vp->v_data = ip; ip->i_vnode = vp; + ip->i_ump = ump; ip->i_e2fs = fs = ump->um_e2fs; ip->i_dev = dev; ip->i_number = ino; @@ -914,7 +916,6 @@ ext2fs_vget(mp, ino, vpp) /* * Finish inode initialization now that aliasing has been resolved. */ - ip->i_devvp = ump->um_devvp; VREF(ip->i_devvp); /* * Set up a generation number for this inode if it does not diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 54014263925..9c88ed3d3b5 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vnops.c,v 1.31 2003/09/23 16:51:13 millert Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.32 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -1350,7 +1350,6 @@ ext2fs_reclaim(v) cache_purge(vp); if (ip->i_devvp) { vrele(ip->i_devvp); - ip->i_devvp = 0; } FREE(vp->v_data, M_EXT2FSNODE); diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 928f024a095..c41fbb14235 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.45 2003/10/17 15:08:11 mpech Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.46 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -48,6 +48,7 @@ #include #include #include +#include #include #include diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 6530167435a..e21c2b96790 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.48 2003/11/19 03:29:31 mickey Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.49 2004/01/20 03:44:06 tedu Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. * @@ -1600,7 +1600,7 @@ handle_workitem_freefrag(freefrag) tip.i_vnode = NULL; tip.i_fs = VFSTOUFS(freefrag->ff_mnt)->um_fs; - tip.i_devvp = freefrag->ff_devvp; + 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 */ @@ -2233,7 +2233,7 @@ handle_workitem_freeblocks(freeblks) tip.i_fs = fs = VFSTOUFS(freeblks->fb_mnt)->um_fs; tip.i_number = freeblks->fb_previousinum; - tip.i_devvp = freeblks->fb_devvp; + tip.i_ump = VFSTOUFS(freeblks->fb_mnt); tip.i_dev = freeblks->fb_devvp->v_rdev; tip.i_ffs_size = freeblks->fb_oldsize; tip.i_ffs_uid = freeblks->fb_uid; @@ -3026,7 +3026,7 @@ handle_workitem_freefile(freefile) if (error) panic("handle_workitem_freefile: inodedep survived"); #endif - tip.i_devvp = freefile->fx_devvp; + tip.i_ump = VFSTOUFS(freefile->fx_mnt); tip.i_dev = freefile->fx_devvp->v_rdev; tip.i_fs = fs; tip.i_vnode = &vp; diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index a9b24987a32..0627d63ce69 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.14 2003/06/26 07:58:47 tedu Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.15 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -38,10 +38,15 @@ #ifdef _KERNEL #include #include +#include #include + #include #include #include +#include +#include + #include /* diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 58cf64d7c6b..1ff8d709a56 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.62 2004/01/07 20:47:47 tedu Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.63 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -666,8 +666,10 @@ ffs_mountfs(devvp, mp, p) if (error) goto out; fs = (struct fs *)bp->b_data; - if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || + if (fs->fs_magic != FS_UFS1_MAGIC || fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) { + if (fs->fs_magic == FS_UFS2_MAGIC) + printf("no UFS2 support\n"); error = EFTYPE; /* Inappropriate format */ goto out; } @@ -706,9 +708,12 @@ ffs_mountfs(devvp, mp, p) goto out; } ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK); - bzero((caddr_t)ump, sizeof *ump); + bzero(ump, sizeof *ump); ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT, M_WAITOK); + if (fs->fs_magic == FS_UFS1_MAGIC) { + ump->um_fstype = UM_UFS1; + } bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize); if (fs->fs_sbsize < SBSIZE) bp->b_flags |= B_INVAL; @@ -1162,6 +1167,7 @@ retry: ip = pool_get(&ffs_ino_pool, PR_WAITOK); bzero((caddr_t)ip, sizeof(struct inode)); lockinit(&ip->i_lock, PINOD, "inode", 0, 0); + ip->i_ump = ump; vp->v_data = ip; ip->i_vnode = vp; ip->i_fs = fs = ump->um_fs; @@ -1226,7 +1232,6 @@ retry: /* * Finish inode initialization now that aliasing has been resolved. */ - ip->i_devvp = ump->um_devvp; VREF(ip->i_devvp); /* * Set up a generation number for this inode if it does not diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index 231c9719039..ad6b7977529 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fs.h,v 1.15 2003/08/26 16:10:57 mickey Exp $ */ +/* $OpenBSD: fs.h,v 1.16 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */ /* @@ -62,6 +62,13 @@ #define SBOFF ((off_t)(BBOFF + BBSIZE)) #define BBLOCK ((daddr_t)(0)) #define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE)) +#define SBLOCK_FLOPPY 0 +#define SBLOCK_UFS1 8192 +#define SBLOCK_UFS2 65536 +#define SBLOCK_PIGGY 262144 +#define SBLOCKSIZE 8192 +#define SBLOCKSEARCH \ + { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } /* * Addresses stored in inodes are capable of addressing fragments @@ -264,6 +271,8 @@ struct fs { * Filesystem identification */ #define FS_MAGIC 0x011954 /* the fast filesystem magic number */ +#define FS_UFS1_MAGIC 0x011954 /* the fast filesystem magic number */ +#define FS_UFS2_MAGIC 0x19540119 /* UFS fast filesystem magic number */ #define FS_OKAY 0x7c269d38 /* superblock checksum */ #define FS_42INODEFMT -1 /* 4.2BSD inode format */ #define FS_44INODEFMT 2 /* 4.4BSD inode format */ diff --git a/sys/ufs/ufs/dinode.h b/sys/ufs/ufs/dinode.h index 577945c1b8f..df721d2602c 100644 --- a/sys/ufs/ufs/dinode.h +++ b/sys/ufs/ufs/dinode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dinode.h,v 1.8 2003/08/25 23:26:55 tedu Exp $ */ +/* $OpenBSD: dinode.h,v 1.9 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: dinode.h,v 1.7 1995/06/15 23:22:48 cgd Exp $ */ /* @@ -65,9 +65,15 @@ typedef int32_t ufs_daddr_t; typedef int32_t ufs1_daddr_t; +typedef int64_t ufs2_daddr_t; +typedef int64_t ufs_lbn_t; +typedef int64_t ufs_time_t; + +#define NXADDR 2 /* External addresses in inode */ #define NDADDR 12 /* Direct addresses in inode. */ #define NIADDR 3 /* Indirect addresses in inode. */ + struct ufs1_dinode { u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ int16_t di_nlink; /* 2: File link count. */ @@ -92,6 +98,33 @@ struct ufs1_dinode { int32_t di_spare[2]; /* 120: Reserved; currently unused */ }; +struct ufs2_dinode { + u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + u_int32_t di_uid; /* 4: File owner. */ + u_int32_t di_gid; /* 8: File group. */ + u_int32_t di_blksize; /* 12: Inode blocksize. */ + u_int64_t di_size; /* 16: File byte count. */ + u_int64_t di_blocks; /* 24: Bytes actually held. */ + ufs_time_t di_atime; /* 32: Last access time. */ + ufs_time_t di_mtime; /* 40: Last modified time. */ + ufs_time_t di_ctime; /* 48: Last inode change time. */ + ufs_time_t di_birthtime; /* 56: Inode creation time. */ + int32_t di_mtimensec; /* 64: Last modified time. */ + int32_t di_atimensec; /* 68: Last access time. */ + int32_t di_ctimensec; /* 72: Last inode change time. */ + int32_t di_birthnsec; /* 76: Inode creation time. */ + int32_t di_gen; /* 80: Generation number. */ + u_int32_t di_kernflags; /* 84: Kernel flags. */ + u_int32_t di_flags; /* 88: Status flags (chflags). */ + int32_t di_extsize; /* 92: External attributes block. */ + ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */ + ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */ + ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ + int64_t di_spare[3]; /* 232: Reserved; currently unused */ +}; + + /* * The di_db fields may be overlaid with other information for * file types that do not have associated disk storage. Block diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index fe24891b277..7374786db6d 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.24 2003/12/28 17:20:16 tedu Exp $ */ +/* $OpenBSD: inode.h,v 1.25 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -42,8 +42,6 @@ #include #include -typedef long ufs_lbn_t; - /* * Per-filesystem inode extensions. */ @@ -64,7 +62,7 @@ struct ext2fs_inode_ext { struct inode { LIST_ENTRY(inode) i_hash; /* Hash chain */ struct vnode *i_vnode;/* Vnode associated with this inode. */ - struct vnode *i_devvp;/* Vnode for block I/O. */ + struct ufsmount *i_ump; u_int32_t i_flag; /* flags, see below */ dev_t i_dev; /* Device associated with the inode. */ ino_t i_number; /* The identity of the inode. */ @@ -230,13 +228,27 @@ struct inode_vtbl { #define IN_SHLOCK 0x0020 /* File has shared lock. */ #define IN_EXLOCK 0x0040 /* File has exclusive lock. */ +#define i_devvp i_ump->um_devvp + #ifdef _KERNEL + /* * The DIP macro is used to access fields in the dinode that are * not cached in the inode itself. */ #define DIP(ip, field) \ - ((ip)->i_din1.d##field) + (((ip)->i_ump->um_fstype == UM_UFS1) ? \ + (ip)->i_din1->d##field : (ip)->i_din2->d##field) + +#if 0 +#define MAXSYMLINKLEN(ip) \ + ((ip)->i_ump->um_fstype == UM_UFS1) ? \ + ((NDADDR + NIADDR) * sizeof(ufs1_daddr_t)) : \ + ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t)) +#define SHORTLINK(ip) \ + (((ip)->i_ump->um_fstype == UM_UFS1) ? \ + (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db) +#endif /* * Structure used to pass around logical block paths generated by diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 6dc9cb11614..68ffe1fcafa 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.20 2003/12/28 17:20:16 tedu Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.21 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -147,7 +147,6 @@ ufs_reclaim(vp, p) cache_purge(vp); if (ip->i_devvp) { vrele(ip->i_devvp); - ip->i_devvp = 0; } #ifdef UFS_DIRHASH if (ip->i_dirhash != NULL) diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 16c48e41361..63c9610a9fe 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_quota.c,v 1.15 2003/08/15 20:32:21 tedu Exp $ */ +/* $OpenBSD: ufs_quota.c,v 1.16 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ufs_quota.c,v 1.8 1996/02/09 22:36:09 christos Exp $ */ /* @@ -154,7 +154,7 @@ getinoquota(ip) struct vnode *vp = ITOV(ip); int error; - ump = VFSTOUFS(vp->v_mount); + ump = ip->i_ump; /* * Set up the user quota based on file uid. * EINVAL means that quotas are not enabled. @@ -286,7 +286,7 @@ chkdqchg(ip, change, cred, type) if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) { if (dq->dq_curblocks < dq->dq_bsoftlimit) { dq->dq_btime = time.tv_sec + - VFSTOUFS(ITOV(ip)->v_mount)->um_btime[type]; + ip->i_ump->um_btime[type]; if (ip->i_ffs_uid == cred->cr_uid) uprintf("\n%s: warning, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, @@ -409,7 +409,7 @@ chkiqchg(ip, change, cred, type) if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) { if (dq->dq_curinodes < dq->dq_isoftlimit) { dq->dq_itime = time.tv_sec + - VFSTOUFS(ITOV(ip)->v_mount)->um_itime[type]; + ip->i_ump->um_itime[type]; if (ip->i_ffs_uid == cred->cr_uid) uprintf("\n%s: warning, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, @@ -440,7 +440,7 @@ void chkdquot(ip) struct inode *ip; { - struct ufsmount *ump = VFSTOUFS(ITOV(ip)->v_mount); + struct ufsmount *ump = ip->i_ump; int i; struct vnode *vp = ITOV(ip); diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 67431c793a3..d932e7a972e 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufsmount.h,v 1.9 2003/06/02 23:28:24 millert Exp $ */ +/* $OpenBSD: ufsmount.h,v 1.10 2004/01/20 03:44:06 tedu Exp $ */ /* $NetBSD: ufsmount.h,v 1.4 1994/12/21 20:00:23 mycroft Exp $ */ /* @@ -46,6 +46,7 @@ struct ufsmount { struct mount *um_mountp; /* filesystem vfs structure */ dev_t um_dev; /* device mounted */ struct vnode *um_devvp; /* block device mounted vnode */ + u_long um_fstype; /* type of file system */ union { /* pointer to superblock */ struct fs *fs; /* FFS */ @@ -70,6 +71,14 @@ struct ufsmount { struct ufs_extattr_per_mount um_extattr; /* extended attrs */ }; +/* + * Filesystem types + */ +#define UM_UFS1 1 +#define UM_UFS2 2 +#define UM_EXT2FS 3 +#define UM_LFS 4 + /* * Flags describing the state of quotas. */ -- cgit v1.2.3