diff options
author | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-02-10 02:22:35 +0000 |
commit | 10f666af84d48e89e4e2960415c9b616fce4077f (patch) | |
tree | 88a944de263165091f0a18abeedbaaccec532407 /sys/gnu | |
parent | 0960d7e91af3428ffba89b42228d82d8afaa0389 (diff) | |
download | FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.zip FreeBSD-src-10f666af84d48e89e4e2960415c9b616fce4077f.tar.gz |
This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.
The system boots and can mount UFS filesystems.
Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
Mount_std mounts will not work until the getfsent
library routine is changed.
Reviewed by: various people
Submitted by: Jeffery Hsu <hsu@freebsd.org>
Diffstat (limited to 'sys/gnu')
-rw-r--r-- | sys/gnu/ext2fs/ext2_bmap.c | 21 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_extern.h | 2 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_ihash.c | 117 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode.c | 10 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode_cnv.c | 26 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_lookup.c | 29 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_mount.h | 34 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 13 | ||||
-rw-r--r-- | sys/gnu/ext2fs/fs.h | 4 | ||||
-rw-r--r-- | sys/gnu/ext2fs/inode.h | 100 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_bmap.c | 21 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_extern.h | 2 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_inode.c | 10 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_inode_cnv.c | 26 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_lookup.c | 29 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_mount.h | 34 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 13 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/fs.h | 4 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/inode.h | 100 |
19 files changed, 302 insertions, 293 deletions
diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c index e17b5b7..aef2b83 100644 --- a/sys/gnu/ext2fs/ext2_bmap.c +++ b/sys/gnu/ext2fs/ext2_bmap.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ufs_bmap.c 8.6 (Berkeley) 1/21/94 + * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD$ */ @@ -63,9 +63,9 @@ int ufs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; - daddr_t a_bn; + ufs_daddr_t a_bn; struct vnode **a_vpp; - daddr_t *a_bnp; + ufs_daddr_t *a_bnp; int *a_runp; int *a_runb; } */ *ap; @@ -100,8 +100,8 @@ ufs_bmap(ap) int ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct vnode *vp; - register daddr_t bn; - daddr_t *bnp; + ufs_daddr_t bn; + ufs_daddr_t *bnp; struct indir *ap; int *nump; int *runp; @@ -113,7 +113,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct mount *mp; struct vnode *devvp; struct indir a[NIADDR+1], *xap; - daddr_t daddr; + ufs_daddr_t daddr; long metalbn; int error, maxrun = 0, num; @@ -209,12 +209,13 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) } } - daddr = ((daddr_t *)bp->b_data)[xap->in_off]; + daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off]; if (num == 1 && daddr && runp) { for (bn = xap->in_off + 1; bn < MNINDIR(ump) && *runp < maxrun && - is_sequential(ump, ((daddr_t *)bp->b_data)[bn - 1], - ((daddr_t *)bp->b_data)[bn]); + is_sequential(ump, + ((ufs_daddr_t *)bp->b_data)[bn - 1], + ((ufs_daddr_t *)bp->b_data)[bn]); ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { @@ -245,7 +246,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) int ufs_getlbns(vp, bn, ap, nump) struct vnode *vp; - register daddr_t bn; + ufs_daddr_t bn; struct indir *ap; int *nump; { diff --git a/sys/gnu/ext2fs/ext2_extern.h b/sys/gnu/ext2fs/ext2_extern.h index f07b7b7..de6cd08f 100644 --- a/sys/gnu/ext2fs/ext2_extern.h +++ b/sys/gnu/ext2fs/ext2_extern.h @@ -56,7 +56,7 @@ int ext2_blkatoff __P((struct vop_blkatoff_args *)); void ext2_blkfree __P((struct inode *, daddr_t, long)); daddr_t ext2_blkpref __P((struct inode *, daddr_t, int, daddr_t *, daddr_t)); int ext2_bmap __P((struct vop_bmap_args *)); -int ext2_init __P((void)); +int ext2_init __P((struct vfsconf *)); int ext2_reallocblks __P((struct vop_reallocblks_args *)); int ext2_reclaim __P((struct vop_reclaim_args *)); void ext2_setblock __P((struct ext2_sb_info *, u_char *, daddr_t)); diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c index a51af00..ea83308 100644 --- a/sys/gnu/ext2fs/ext2_ihash.c +++ b/sys/gnu/ext2fs/ext2_ihash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1982, 1986, 1989, 1991, 1993 + * Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ufs_ihash.c 8.4 (Berkeley) 12/30/93 + * @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95 * $FreeBSD$ */ @@ -47,9 +47,10 @@ /* * Structures associated with inode cacheing. */ -struct inode **ihashtbl; +LIST_HEAD(ihashhead, inode) *ihashtbl; u_long ihash; /* size of hash table - 1 */ -#define INOHASH(device, inum) (((device) + (inum)) & ihash) +#define INOHASH(device, inum) (&ihashtbl[((device) + (inum)) & ihash]) +struct simplelock ufs_ihash_slock; /* * Initialize inode hash table. @@ -59,6 +60,7 @@ ufs_ihashinit() { ihashtbl = hashinit(desiredvnodes, M_UFSMNT, &ihash); + simple_lock_init(&ufs_ihash_slock); } /* @@ -66,19 +68,21 @@ ufs_ihashinit() * to it. If it is in core, return it, even if it is locked. */ struct vnode * -ufs_ihashlookup(device, inum) - dev_t device; +ufs_ihashlookup(dev, inum) + dev_t dev; ino_t inum; { - register struct inode *ip; + struct inode *ip; - for (ip = ihashtbl[INOHASH(device, inum)];; ip = ip->i_next) { - if (ip == NULL) - return (NULL); - if (inum == ip->i_number && device == ip->i_dev) - return (ITOV(ip)); - } - /* NOTREACHED */ + simple_lock(&ufs_ihash_slock); + for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) + if (inum == ip->i_number && dev == ip->i_dev) + break; + simple_unlock(&ufs_ihash_slock); + + if (ip) + return (ITOV(ip)); + return (NULLVP); } /* @@ -86,36 +90,28 @@ ufs_ihashlookup(device, inum) * to it. If it is in core, but locked, wait for it. */ struct vnode * -ufs_ihashget(device, inum) - dev_t device; +ufs_ihashget(dev, inum) + dev_t dev; ino_t inum; { - register struct inode *ip; + struct proc *p = curproc; /* XXX */ + struct inode *ip; struct vnode *vp; - for (;;) - for (ip = ihashtbl[INOHASH(device, inum)];; ip = ip->i_next) { - if (ip == NULL) - return (NULL); - if (inum == ip->i_number && device == ip->i_dev) { - if (ip->i_flag & IN_LOCKED) { - if( curproc->p_pid != ip->i_lockholder) { - ip->i_flag |= IN_WANTED; - (void) tsleep(ip, PINOD, "uihget", 0); - break; - } else if (ip->i_flag & IN_RECURSE) { - ip->i_lockcount++; - } else { - panic("ufs_ihashget: recursive lock not expected -- pid %d\n", ip->i_lockholder); - } - } - vp = ITOV(ip); - if (!vget(vp, 1)) - return (vp); - break; - } +loop: + simple_lock(&ufs_ihash_slock); + for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) { + if (inum == ip->i_number && dev == ip->i_dev) { + vp = ITOV(ip); + simple_lock(&vp->v_interlock); + simple_unlock(&ufs_ihash_slock); + if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) + goto loop; + return (vp); } - /* NOTREACHED */ + } + simple_unlock(&ufs_ihash_slock); + return (NULL); } /* @@ -125,26 +121,16 @@ void ufs_ihashins(ip) struct inode *ip; { - struct inode **ipp, *iq; + struct proc *p = curproc; /* XXX */ + struct ihashhead *ipp; - ipp = &ihashtbl[INOHASH(ip->i_dev, ip->i_number)]; - iq = *ipp; - if (iq) - iq->i_prev = &ip->i_next; - ip->i_next = iq; - ip->i_prev = ipp; - *ipp = ip; - if ((ip->i_flag & IN_LOCKED) && - ((ip->i_flag & IN_RECURSE) == 0 || - (!curproc || (curproc && (ip->i_lockholder != curproc->p_pid))))) - panic("ufs_ihashins: already locked"); - if (curproc) { - ip->i_lockcount += 1; - ip->i_lockholder = curproc->p_pid; - } else { - ip->i_lockholder = -1; - } - ip->i_flag |= IN_LOCKED; + /* lock the inode, then put it on the appropriate hash list */ + lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, p); + + simple_lock(&ufs_ihash_slock); + ipp = INOHASH(ip->i_dev, ip->i_number); + LIST_INSERT_HEAD(ipp, ip, i_hash); + simple_unlock(&ufs_ihash_slock); } /* @@ -152,16 +138,13 @@ ufs_ihashins(ip) */ void ufs_ihashrem(ip) - register struct inode *ip; + struct inode *ip; { - register struct inode *iq; - - iq = ip->i_next; - if (iq) - iq->i_prev = ip->i_prev; - *ip->i_prev = iq; + simple_lock(&ufs_ihash_slock); + LIST_REMOVE(ip, i_hash); #ifdef DIAGNOSTIC - ip->i_next = NULL; - ip->i_prev = NULL; + ip->i_hash.le_next = NULL; + ip->i_hash.le_prev = NULL; #endif + simple_unlock(&ufs_ihash_slock); } diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index d3b7038..788f5eb 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -77,9 +77,9 @@ static int ext2_indirtrunc __P((struct inode *, daddr_t, daddr_t, daddr_t, int, long *)); int -ext2_init() +ext2_init(struct vfsconf *vfsp) { - return (ufs_init()); + return (ufs_init(vfsp)); } /* @@ -118,16 +118,16 @@ ext2_update(ap) (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) return (0); if (ip->i_flag & IN_ACCESS) - ip->i_atime.tv_sec = ap->a_access->tv_sec; + ip->i_atime = ap->a_access->tv_sec; if (ip->i_flag & IN_UPDATE) { - ip->i_mtime.tv_sec = ap->a_modify->tv_sec; + ip->i_mtime = ap->a_modify->tv_sec; ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { #if !defined(__FreeBSD__) get_time(&time); #endif - ip->i_ctime.tv_sec = time.tv_sec; + ip->i_ctime = time.tv_sec; } ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; diff --git a/sys/gnu/ext2fs/ext2_inode_cnv.c b/sys/gnu/ext2fs/ext2_inode_cnv.c index fbc743b..a39e7b9 100644 --- a/sys/gnu/ext2fs/ext2_inode_cnv.c +++ b/sys/gnu/ext2fs/ext2_inode_cnv.c @@ -66,17 +66,17 @@ ext2_print_dinode( di ) di->di_uid, di->di_gid, di->di_size); printf( "Links: %3d Blockcount: %d\n", di->di_nlink, di->di_blocks); - printf( "ctime: 0x%x", di->di_ctime.tv_sec); + printf( "ctime: 0x%x", di->di_ctime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_ctime.tv_sec); + print_time(" -- %s\n", di->di_ctime); #endif - printf( "atime: 0x%x", di->di_atime.tv_sec); + printf( "atime: 0x%x", di->di_atime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_atime.tv_sec); + print_time(" -- %s\n", di->di_atime); #endif - printf( "mtime: 0x%x", di->di_mtime.tv_sec); + printf( "mtime: 0x%x", di->di_mtime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_mtime.tv_sec); + print_time(" -- %s\n", di->di_mtime); #endif printf( "BLOCKS: "); for(i=0; i < (di->di_blocks <= 24 ? ((di->di_blocks+1)/2): 12); i++) @@ -110,9 +110,9 @@ ext2_ei2di(ei, di) */ di->di_mode = ei->i_links_count ? ei->i_mode : 0; di->di_size = ei->i_size; - di->di_atime.tv_sec = ei->i_atime; - di->di_mtime.tv_sec = ei->i_mtime; - di->di_ctime.tv_sec = ei->i_ctime; + di->di_atime = ei->i_atime; + di->di_mtime = ei->i_mtime; + di->di_ctime = ei->i_ctime; di->di_flags = 0; di->di_flags |= (ei->i_flags & EXT2_APPEND_FL) ? APPEND : 0; di->di_flags |= (ei->i_flags & EXT2_IMMUTABLE_FL) ? IMMUTABLE : 0; @@ -143,11 +143,11 @@ ext2_di2ei(di, ei) Godmar thinks: if dtime is nonzero, ext2 says this inode has been deleted, this would correspond to a zero link count */ - ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime.tv_sec; + ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime; ei->i_size = di->di_size; - ei->i_atime = di->di_atime.tv_sec; - ei->i_mtime = di->di_mtime.tv_sec; - ei->i_ctime = di->di_ctime.tv_sec; + ei->i_atime = di->di_atime; + ei->i_mtime = di->di_mtime; + ei->i_ctime = di->di_ctime; ei->i_flags = di->di_flags; ei->i_flags = 0; ei->i_flags |= (di->di_flags & APPEND) ? EXT2_APPEND_FL: 0; diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c index baeaa52..eabd40e 100644 --- a/sys/gnu/ext2fs/ext2_lookup.c +++ b/sys/gnu/ext2fs/ext2_lookup.c @@ -274,6 +274,7 @@ ext2_lookup(ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; + struct proc *p = cnp->cn_proc; int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize; @@ -318,14 +319,14 @@ ext2_lookup(ap) VREF(vdp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); - error = vget(vdp, 1); + VOP_UNLOCK(pdp, 0, p); + error = vget(vdp, LK_EXCLUSIVE, p); if (!error && lockparent && (flags & ISLASTCN)) - error = VOP_LOCK(pdp); + error = vn_lock(pdp, LK_EXCLUSIVE, p); } else { - error = vget(vdp, 1); + error = vget(vdp, LK_EXCLUSIVE, p); if (!lockparent || error || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } /* * Check that the capability number did not change @@ -336,9 +337,9 @@ ext2_lookup(ap) return (0); vput(vdp); if (lockparent && pdp != vdp && (flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } - if (error = VOP_LOCK(pdp)) + if (error = vn_lock(pdp, LK_EXCLUSIVE, p)) return (error); vdp = pdp; dp = VTOI(pdp); @@ -548,7 +549,7 @@ searchloop: */ cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (EJUSTRETURN); } /* @@ -625,7 +626,7 @@ found: } *vpp = tdp; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -650,7 +651,7 @@ found: *vpp = tdp; cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -675,13 +676,13 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ if (error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) { - VOP_LOCK(pdp); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); return (error); } if (lockparent && (flags & ISLASTCN) && - (error = VOP_LOCK(pdp))) { + (error = vn_lock(pdp, LK_EXCLUSIVE, p))) { vput(tdp); return (error); } @@ -693,7 +694,7 @@ found: if (error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); *vpp = tdp; } diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h index d7b7b28..87041a6 100644 --- a/sys/gnu/ext2fs/ext2_mount.h +++ b/sys/gnu/ext2fs/ext2_mount.h @@ -30,13 +30,34 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ufsmount.h 8.2 (Berkeley) 1/12/94 + * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 * $FreeBSD$ */ #ifndef _UFS_UFS_UFSMOUNT_H_ #define _UFS_UFS_UFSMOUNT_H_ +/* + * Arguments to mount UFS-based filesystems + */ +struct ufs_args { + char *fspec; /* block special device to mount */ + struct export_args export; /* network export information */ +}; + +#ifdef MFS +/* + * Arguments to mount MFS + */ +struct mfs_args { + char *fspec; /* name to export for statfs */ + struct export_args export; /* if exported MFSes are supported */ + caddr_t base; /* base of file system in memory */ + u_long size; /* size of file system */ +}; +#endif /* MFS */ + +#ifdef KERNEL struct buf; struct inode; struct nameidata; @@ -51,6 +72,7 @@ struct ufsmount { struct mount *um_mountp; /* filesystem vfs structure */ dev_t um_dev; /* device mounted */ struct vnode *um_devvp; /* block device mounted vnode */ + union { /* pointer to superblock */ struct lfs *lfs; /* LFS */ struct fs *fs; /* FFS */ @@ -60,6 +82,7 @@ struct ufsmount { #define um_lfs ufsmount_u.lfs #define um_e2fs ufsmount_u.e2fs #define um_e2fsb ufsmount_u.e2fs->s_es + struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ u_long um_nindir; /* indirect ptrs per block */ @@ -69,7 +92,9 @@ struct ufsmount { time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ char um_qflags[MAXQUOTAS]; /* quota specific flags */ struct netexport um_export; /* export information */ + int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ }; + /* * Flags describing the state of quotas. */ @@ -83,8 +108,9 @@ struct ufsmount { * Macros to access file system parameters in the ufsmount structure. * Used by ufs_bmap. */ -#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) -#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) -#define MNINDIR(ump) ((ump)->um_nindir) +#define MNINDIR(ump) ((ump)->um_nindir) +#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) +#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) +#endif /* KERNEL */ #endif diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index d7c3e03..f01c059 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -221,10 +221,10 @@ ext2_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (vfs_busy(mp)) + if (vfs_busy(mp, LK_NOWAIT, 0, p)) return (EBUSY); error = ext2_flushfiles(mp, flags, p); - vfs_unbusy(mp); + vfs_unbusy(mp, p); } if (!error && (mp->mnt_flag & MNT_RELOAD)) error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p); @@ -515,7 +515,7 @@ loop: /* * Step 5: invalidate all cached file data. */ - if (vget(vp, 1)) + if (vget(vp, LK_EXCLUSIVE, p)) goto loop; if (vinvalbuf(vp, 0, cred, p, 0, 0)) panic("ext2_reload: dirty2"); @@ -727,17 +727,12 @@ ext2_flushfiles(mp, flags, p) int flags; struct proc *p; { -#if !defined(__FreeBSD__) - extern int doforce; -#endif register struct ufsmount *ump; int error; #if QUOTA int i; #endif - if (!doforce) - flags &= ~FORCECLOSE; ump = VFSTOUFS(mp); #if QUOTA if (mp->mnt_flag & MNT_QUOTA) { @@ -872,7 +867,7 @@ loop: (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && vp->v_dirtyblkhd.lh_first == NULL) continue; - if (vget(vp, 1)) + if (vget(vp, LK_EXCLUSIVE, p)) goto loop; if (error = VOP_FSYNC(vp, cred, waitfor, p)) allerror = error; diff --git a/sys/gnu/ext2fs/fs.h b/sys/gnu/ext2fs/fs.h index 28071d4..03f137c 100644 --- a/sys/gnu/ext2fs/fs.h +++ b/sys/gnu/ext2fs/fs.h @@ -152,6 +152,6 @@ extern u_char *fragtbl[]; * I think I'll try a VOP_LOCK/VOP_UNLOCK on the device vnode */ #define DEVVP(inode) (VFSTOUFS(ITOV(inode)->v_mount)->um_devvp) -#define lock_super(devvp) VOP_LOCK(devvp) -#define unlock_super(devvp) VOP_UNLOCK(devvp) +#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curproc) +#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curproc) diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h index dc19d34..438471f 100644 --- a/sys/gnu/ext2fs/inode.h +++ b/sys/gnu/ext2fs/inode.h @@ -35,42 +35,33 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)inode.h 8.4 (Berkeley) 1/21/94 + * @(#)inode.h 8.9 (Berkeley) 5/14/95 * $FreeBSD$ */ #ifndef _UFS_UFS_INODE_H_ #define _UFS_UFS_INODE_H_ +#include <ufs/ufs/dir.h> #include <ufs/ufs/dinode.h> /* - * Theoretically, directories can be more than 2Gb in length, however, in - * practice this seems unlikely. So, we define the type doff_t as a long - * to keep down the cost of doing lookup on a 32-bit machine. If you are - * porting to a 64-bit architecture, you should make doff_t the same as off_t. - */ -#define doff_t long - -/* - * The inode is used to describe each active (or recently active) - * file in the UFS filesystem. It is composed of two types of - * information. The first part is the information that is needed - * only while the file is active (such as the identity of the file - * and linkage to speed its lookup). The second part is the - * permanent meta-data associated with the file which is read - * in from the permanent dinode from long term storage when the - * file becomes active, and is put back when the file is no longer - * being used. + * The inode is used to describe each active (or recently active) file in the + * UFS filesystem. It is composed of two types of information. The first part + * is the information that is needed only while the file is active (such as + * the identity of the file and linkage to speed its lookup). The second part + * is the permanent meta-data associated with the file which is read in + * from the permanent dinode from long term storage when the file becomes + * active, and is put back when the file is no longer being used. */ struct inode { - struct inode *i_next; /* Hash chain forward. */ - struct inode **i_prev; /* Hash chain back. */ - struct vnode *i_vnode; /* Vnode associated with this inode. */ - struct vnode *i_devvp; /* Vnode for block I/O. */ - u_long i_flag; /* I* flags. */ - dev_t i_dev; /* Device associated with the inode. */ - ino_t i_number; /* The identity of the 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. */ + 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. */ + union { /* Associated filesystem. */ struct fs *fs; /* FFS */ struct lfs *lfs; /* LFS */ @@ -79,22 +70,21 @@ struct inode { #define i_fs inode_u.fs #define i_lfs inode_u.lfs #define i_e2fs inode_u.e2fs - struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ - u_quad_t i_modrev; /* Revision level for lease. */ - struct lockf *i_lockf; /* Head of byte-level lock list. */ - pid_t i_lockholder; /* DEBUG: holder of inode lock. */ - pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock. */ + struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + u_quad_t i_modrev; /* Revision level for NFS lease. */ + struct lockf *i_lockf;/* Head of byte-level lock list. */ + struct lock i_lock; /* Inode lock. */ /* * Side effects; used during directory lookup. */ - long i_count; /* Size of free slot in directory. */ - doff_t i_endoff; /* End of useful stuff in directory. */ - doff_t i_diroff; /* Offset in dir, where we found last entry. */ - doff_t i_offset; /* Offset of free space in directory. */ - ino_t i_ino; /* Inode number of found directory. */ - u_long i_reclen; /* Size of found directory entry. */ - int i_lockcount; /* Process lock count (recursion) */ - long i_spare[10]; /* Spares to round up to 128 bytes. */ + int32_t i_count; /* Size of free slot in directory. */ + doff_t i_endoff; /* End of useful stuff in directory. */ + doff_t i_diroff; /* Offset in dir, where we found last entry. */ + doff_t i_offset; /* Offset of free space in directory. */ + ino_t i_ino; /* Inode number of found directory. */ + u_int32_t i_reclen; /* Size of found directory entry. */ + int i_lockcount; /* Process lock count (recursion) */ + int i_spare[10]; /* XXX spare storage (for ext2fs) */ /* * The on-disk dinode itself. */ @@ -102,8 +92,10 @@ struct inode { }; #define i_atime i_din.di_atime +#define i_atimensec i_din.di_atimensec #define i_blocks i_din.di_blocks #define i_ctime i_din.di_ctime +#define i_ctimensec i_din.di_ctimensec #define i_db i_din.di_db #define i_flags i_din.di_flags #define i_gen i_din.di_gen @@ -111,6 +103,7 @@ struct inode { #define i_ib i_din.di_ib #define i_mode i_din.di_mode #define i_mtime i_din.di_mtime +#define i_mtimensec i_din.di_mtimensec #define i_nlink i_din.di_nlink #define i_rdev i_din.di_rdev #define i_shortlink i_din.di_shortlink @@ -120,15 +113,12 @@ struct inode { /* These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ #define IN_CHANGE 0x0002 /* Inode change time update request. */ -#define IN_EXLOCK 0x0004 /* File has exclusive lock. */ -#define IN_LOCKED 0x0008 /* Inode lock. */ -#define IN_LWAIT 0x0010 /* Process waiting on file lock. */ -#define IN_MODIFIED 0x0020 /* Inode has been modified. */ -#define IN_RENAME 0x0040 /* Inode is being renamed. */ -#define IN_SHLOCK 0x0080 /* File has shared lock. */ -#define IN_UPDATE 0x0100 /* Modification time update request. */ -#define IN_WANTED 0x0200 /* Inode is wanted by a process. */ -#define IN_RECURSE 0x0400 /* Recursion expected */ +#define IN_UPDATE 0x0004 /* Modification time update request. */ +#define IN_MODIFIED 0x0008 /* Inode has been modified. */ +#define IN_RENAME 0x0010 /* Inode is being renamed. */ +#define IN_SHLOCK 0x0020 /* File has shared lock. */ +#define IN_EXLOCK 0x0040 /* File has exclusive lock. */ +#define IN_RECURSE 0x0080 /* Recursion expected */ #ifdef KERNEL /* @@ -136,7 +126,7 @@ struct inode { * ufs_getlbns and used by truncate and bmap code. */ struct indir { - daddr_t in_lbn; /* Logical block number. */ + ufs_daddr_t in_lbn; /* Logical block number. */ int in_off; /* Offset in buffer. */ int in_exists; /* Flag if the block exists. */ }; @@ -155,25 +145,25 @@ struct indir { if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)->i_flag |= IN_MODIFIED; \ if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_atime.tv_sec \ + (ip)->i_atime \ = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_mtime.tv_sec \ + (ip)->i_mtime \ = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ (ip)->i_modrev++; \ } \ if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ctime.tv_sec = tv_sec; \ + (ip)->i_ctime = tv_sec; \ (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } /* This overlays the fid structure (see mount.h). */ struct ufid { - u_short ufid_len; /* Length of structure. */ - u_short ufid_pad; /* Force long alignment. */ - ino_t ufid_ino; /* File number (ino). */ - long ufid_gen; /* Generation number. */ + u_int16_t ufid_len; /* Length of structure. */ + u_int16_t ufid_pad; /* Force 32-bit alignment. */ + ino_t ufid_ino; /* File number (ino). */ + int32_t ufid_gen; /* Generation number. */ }; #endif /* KERNEL */ diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c index e17b5b7..aef2b83 100644 --- a/sys/gnu/fs/ext2fs/ext2_bmap.c +++ b/sys/gnu/fs/ext2fs/ext2_bmap.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ufs_bmap.c 8.6 (Berkeley) 1/21/94 + * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD$ */ @@ -63,9 +63,9 @@ int ufs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; - daddr_t a_bn; + ufs_daddr_t a_bn; struct vnode **a_vpp; - daddr_t *a_bnp; + ufs_daddr_t *a_bnp; int *a_runp; int *a_runb; } */ *ap; @@ -100,8 +100,8 @@ ufs_bmap(ap) int ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct vnode *vp; - register daddr_t bn; - daddr_t *bnp; + ufs_daddr_t bn; + ufs_daddr_t *bnp; struct indir *ap; int *nump; int *runp; @@ -113,7 +113,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) struct mount *mp; struct vnode *devvp; struct indir a[NIADDR+1], *xap; - daddr_t daddr; + ufs_daddr_t daddr; long metalbn; int error, maxrun = 0, num; @@ -209,12 +209,13 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) } } - daddr = ((daddr_t *)bp->b_data)[xap->in_off]; + daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off]; if (num == 1 && daddr && runp) { for (bn = xap->in_off + 1; bn < MNINDIR(ump) && *runp < maxrun && - is_sequential(ump, ((daddr_t *)bp->b_data)[bn - 1], - ((daddr_t *)bp->b_data)[bn]); + is_sequential(ump, + ((ufs_daddr_t *)bp->b_data)[bn - 1], + ((ufs_daddr_t *)bp->b_data)[bn]); ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { @@ -245,7 +246,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) int ufs_getlbns(vp, bn, ap, nump) struct vnode *vp; - register daddr_t bn; + ufs_daddr_t bn; struct indir *ap; int *nump; { diff --git a/sys/gnu/fs/ext2fs/ext2_extern.h b/sys/gnu/fs/ext2fs/ext2_extern.h index f07b7b7..de6cd08f 100644 --- a/sys/gnu/fs/ext2fs/ext2_extern.h +++ b/sys/gnu/fs/ext2fs/ext2_extern.h @@ -56,7 +56,7 @@ int ext2_blkatoff __P((struct vop_blkatoff_args *)); void ext2_blkfree __P((struct inode *, daddr_t, long)); daddr_t ext2_blkpref __P((struct inode *, daddr_t, int, daddr_t *, daddr_t)); int ext2_bmap __P((struct vop_bmap_args *)); -int ext2_init __P((void)); +int ext2_init __P((struct vfsconf *)); int ext2_reallocblks __P((struct vop_reallocblks_args *)); int ext2_reclaim __P((struct vop_reclaim_args *)); void ext2_setblock __P((struct ext2_sb_info *, u_char *, daddr_t)); diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index d3b7038..788f5eb 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -77,9 +77,9 @@ static int ext2_indirtrunc __P((struct inode *, daddr_t, daddr_t, daddr_t, int, long *)); int -ext2_init() +ext2_init(struct vfsconf *vfsp) { - return (ufs_init()); + return (ufs_init(vfsp)); } /* @@ -118,16 +118,16 @@ ext2_update(ap) (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0) return (0); if (ip->i_flag & IN_ACCESS) - ip->i_atime.tv_sec = ap->a_access->tv_sec; + ip->i_atime = ap->a_access->tv_sec; if (ip->i_flag & IN_UPDATE) { - ip->i_mtime.tv_sec = ap->a_modify->tv_sec; + ip->i_mtime = ap->a_modify->tv_sec; ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { #if !defined(__FreeBSD__) get_time(&time); #endif - ip->i_ctime.tv_sec = time.tv_sec; + ip->i_ctime = time.tv_sec; } ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); fs = ip->i_e2fs; diff --git a/sys/gnu/fs/ext2fs/ext2_inode_cnv.c b/sys/gnu/fs/ext2fs/ext2_inode_cnv.c index fbc743b..a39e7b9 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode_cnv.c +++ b/sys/gnu/fs/ext2fs/ext2_inode_cnv.c @@ -66,17 +66,17 @@ ext2_print_dinode( di ) di->di_uid, di->di_gid, di->di_size); printf( "Links: %3d Blockcount: %d\n", di->di_nlink, di->di_blocks); - printf( "ctime: 0x%x", di->di_ctime.tv_sec); + printf( "ctime: 0x%x", di->di_ctime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_ctime.tv_sec); + print_time(" -- %s\n", di->di_ctime); #endif - printf( "atime: 0x%x", di->di_atime.tv_sec); + printf( "atime: 0x%x", di->di_atime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_atime.tv_sec); + print_time(" -- %s\n", di->di_atime); #endif - printf( "mtime: 0x%x", di->di_mtime.tv_sec); + printf( "mtime: 0x%x", di->di_mtime); #if !defined(__FreeBSD__) - print_time(" -- %s\n", di->di_mtime.tv_sec); + print_time(" -- %s\n", di->di_mtime); #endif printf( "BLOCKS: "); for(i=0; i < (di->di_blocks <= 24 ? ((di->di_blocks+1)/2): 12); i++) @@ -110,9 +110,9 @@ ext2_ei2di(ei, di) */ di->di_mode = ei->i_links_count ? ei->i_mode : 0; di->di_size = ei->i_size; - di->di_atime.tv_sec = ei->i_atime; - di->di_mtime.tv_sec = ei->i_mtime; - di->di_ctime.tv_sec = ei->i_ctime; + di->di_atime = ei->i_atime; + di->di_mtime = ei->i_mtime; + di->di_ctime = ei->i_ctime; di->di_flags = 0; di->di_flags |= (ei->i_flags & EXT2_APPEND_FL) ? APPEND : 0; di->di_flags |= (ei->i_flags & EXT2_IMMUTABLE_FL) ? IMMUTABLE : 0; @@ -143,11 +143,11 @@ ext2_di2ei(di, ei) Godmar thinks: if dtime is nonzero, ext2 says this inode has been deleted, this would correspond to a zero link count */ - ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime.tv_sec; + ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime; ei->i_size = di->di_size; - ei->i_atime = di->di_atime.tv_sec; - ei->i_mtime = di->di_mtime.tv_sec; - ei->i_ctime = di->di_ctime.tv_sec; + ei->i_atime = di->di_atime; + ei->i_mtime = di->di_mtime; + ei->i_ctime = di->di_ctime; ei->i_flags = di->di_flags; ei->i_flags = 0; ei->i_flags |= (di->di_flags & APPEND) ? EXT2_APPEND_FL: 0; diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c index baeaa52..eabd40e 100644 --- a/sys/gnu/fs/ext2fs/ext2_lookup.c +++ b/sys/gnu/fs/ext2fs/ext2_lookup.c @@ -274,6 +274,7 @@ ext2_lookup(ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; + struct proc *p = cnp->cn_proc; int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize; @@ -318,14 +319,14 @@ ext2_lookup(ap) VREF(vdp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); - error = vget(vdp, 1); + VOP_UNLOCK(pdp, 0, p); + error = vget(vdp, LK_EXCLUSIVE, p); if (!error && lockparent && (flags & ISLASTCN)) - error = VOP_LOCK(pdp); + error = vn_lock(pdp, LK_EXCLUSIVE, p); } else { - error = vget(vdp, 1); + error = vget(vdp, LK_EXCLUSIVE, p); if (!lockparent || error || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } /* * Check that the capability number did not change @@ -336,9 +337,9 @@ ext2_lookup(ap) return (0); vput(vdp); if (lockparent && pdp != vdp && (flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } - if (error = VOP_LOCK(pdp)) + if (error = vn_lock(pdp, LK_EXCLUSIVE, p)) return (error); vdp = pdp; dp = VTOI(pdp); @@ -548,7 +549,7 @@ searchloop: */ cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (EJUSTRETURN); } /* @@ -625,7 +626,7 @@ found: } *vpp = tdp; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -650,7 +651,7 @@ found: *vpp = tdp; cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -675,13 +676,13 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ if (error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) { - VOP_LOCK(pdp); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); return (error); } if (lockparent && (flags & ISLASTCN) && - (error = VOP_LOCK(pdp))) { + (error = vn_lock(pdp, LK_EXCLUSIVE, p))) { vput(tdp); return (error); } @@ -693,7 +694,7 @@ found: if (error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); *vpp = tdp; } diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h index d7b7b28..87041a6 100644 --- a/sys/gnu/fs/ext2fs/ext2_mount.h +++ b/sys/gnu/fs/ext2fs/ext2_mount.h @@ -30,13 +30,34 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ufsmount.h 8.2 (Berkeley) 1/12/94 + * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 * $FreeBSD$ */ #ifndef _UFS_UFS_UFSMOUNT_H_ #define _UFS_UFS_UFSMOUNT_H_ +/* + * Arguments to mount UFS-based filesystems + */ +struct ufs_args { + char *fspec; /* block special device to mount */ + struct export_args export; /* network export information */ +}; + +#ifdef MFS +/* + * Arguments to mount MFS + */ +struct mfs_args { + char *fspec; /* name to export for statfs */ + struct export_args export; /* if exported MFSes are supported */ + caddr_t base; /* base of file system in memory */ + u_long size; /* size of file system */ +}; +#endif /* MFS */ + +#ifdef KERNEL struct buf; struct inode; struct nameidata; @@ -51,6 +72,7 @@ struct ufsmount { struct mount *um_mountp; /* filesystem vfs structure */ dev_t um_dev; /* device mounted */ struct vnode *um_devvp; /* block device mounted vnode */ + union { /* pointer to superblock */ struct lfs *lfs; /* LFS */ struct fs *fs; /* FFS */ @@ -60,6 +82,7 @@ struct ufsmount { #define um_lfs ufsmount_u.lfs #define um_e2fs ufsmount_u.e2fs #define um_e2fsb ufsmount_u.e2fs->s_es + struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ u_long um_nindir; /* indirect ptrs per block */ @@ -69,7 +92,9 @@ struct ufsmount { time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ char um_qflags[MAXQUOTAS]; /* quota specific flags */ struct netexport um_export; /* export information */ + int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ }; + /* * Flags describing the state of quotas. */ @@ -83,8 +108,9 @@ struct ufsmount { * Macros to access file system parameters in the ufsmount structure. * Used by ufs_bmap. */ -#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) -#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) -#define MNINDIR(ump) ((ump)->um_nindir) +#define MNINDIR(ump) ((ump)->um_nindir) +#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) +#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) +#endif /* KERNEL */ #endif diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index d7c3e03..f01c059 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -221,10 +221,10 @@ ext2_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (vfs_busy(mp)) + if (vfs_busy(mp, LK_NOWAIT, 0, p)) return (EBUSY); error = ext2_flushfiles(mp, flags, p); - vfs_unbusy(mp); + vfs_unbusy(mp, p); } if (!error && (mp->mnt_flag & MNT_RELOAD)) error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p); @@ -515,7 +515,7 @@ loop: /* * Step 5: invalidate all cached file data. */ - if (vget(vp, 1)) + if (vget(vp, LK_EXCLUSIVE, p)) goto loop; if (vinvalbuf(vp, 0, cred, p, 0, 0)) panic("ext2_reload: dirty2"); @@ -727,17 +727,12 @@ ext2_flushfiles(mp, flags, p) int flags; struct proc *p; { -#if !defined(__FreeBSD__) - extern int doforce; -#endif register struct ufsmount *ump; int error; #if QUOTA int i; #endif - if (!doforce) - flags &= ~FORCECLOSE; ump = VFSTOUFS(mp); #if QUOTA if (mp->mnt_flag & MNT_QUOTA) { @@ -872,7 +867,7 @@ loop: (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && vp->v_dirtyblkhd.lh_first == NULL) continue; - if (vget(vp, 1)) + if (vget(vp, LK_EXCLUSIVE, p)) goto loop; if (error = VOP_FSYNC(vp, cred, waitfor, p)) allerror = error; diff --git a/sys/gnu/fs/ext2fs/fs.h b/sys/gnu/fs/ext2fs/fs.h index 28071d4..03f137c 100644 --- a/sys/gnu/fs/ext2fs/fs.h +++ b/sys/gnu/fs/ext2fs/fs.h @@ -152,6 +152,6 @@ extern u_char *fragtbl[]; * I think I'll try a VOP_LOCK/VOP_UNLOCK on the device vnode */ #define DEVVP(inode) (VFSTOUFS(ITOV(inode)->v_mount)->um_devvp) -#define lock_super(devvp) VOP_LOCK(devvp) -#define unlock_super(devvp) VOP_UNLOCK(devvp) +#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curproc) +#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curproc) diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h index dc19d34..438471f 100644 --- a/sys/gnu/fs/ext2fs/inode.h +++ b/sys/gnu/fs/ext2fs/inode.h @@ -35,42 +35,33 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)inode.h 8.4 (Berkeley) 1/21/94 + * @(#)inode.h 8.9 (Berkeley) 5/14/95 * $FreeBSD$ */ #ifndef _UFS_UFS_INODE_H_ #define _UFS_UFS_INODE_H_ +#include <ufs/ufs/dir.h> #include <ufs/ufs/dinode.h> /* - * Theoretically, directories can be more than 2Gb in length, however, in - * practice this seems unlikely. So, we define the type doff_t as a long - * to keep down the cost of doing lookup on a 32-bit machine. If you are - * porting to a 64-bit architecture, you should make doff_t the same as off_t. - */ -#define doff_t long - -/* - * The inode is used to describe each active (or recently active) - * file in the UFS filesystem. It is composed of two types of - * information. The first part is the information that is needed - * only while the file is active (such as the identity of the file - * and linkage to speed its lookup). The second part is the - * permanent meta-data associated with the file which is read - * in from the permanent dinode from long term storage when the - * file becomes active, and is put back when the file is no longer - * being used. + * The inode is used to describe each active (or recently active) file in the + * UFS filesystem. It is composed of two types of information. The first part + * is the information that is needed only while the file is active (such as + * the identity of the file and linkage to speed its lookup). The second part + * is the permanent meta-data associated with the file which is read in + * from the permanent dinode from long term storage when the file becomes + * active, and is put back when the file is no longer being used. */ struct inode { - struct inode *i_next; /* Hash chain forward. */ - struct inode **i_prev; /* Hash chain back. */ - struct vnode *i_vnode; /* Vnode associated with this inode. */ - struct vnode *i_devvp; /* Vnode for block I/O. */ - u_long i_flag; /* I* flags. */ - dev_t i_dev; /* Device associated with the inode. */ - ino_t i_number; /* The identity of the 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. */ + 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. */ + union { /* Associated filesystem. */ struct fs *fs; /* FFS */ struct lfs *lfs; /* LFS */ @@ -79,22 +70,21 @@ struct inode { #define i_fs inode_u.fs #define i_lfs inode_u.lfs #define i_e2fs inode_u.e2fs - struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ - u_quad_t i_modrev; /* Revision level for lease. */ - struct lockf *i_lockf; /* Head of byte-level lock list. */ - pid_t i_lockholder; /* DEBUG: holder of inode lock. */ - pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock. */ + struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ + u_quad_t i_modrev; /* Revision level for NFS lease. */ + struct lockf *i_lockf;/* Head of byte-level lock list. */ + struct lock i_lock; /* Inode lock. */ /* * Side effects; used during directory lookup. */ - long i_count; /* Size of free slot in directory. */ - doff_t i_endoff; /* End of useful stuff in directory. */ - doff_t i_diroff; /* Offset in dir, where we found last entry. */ - doff_t i_offset; /* Offset of free space in directory. */ - ino_t i_ino; /* Inode number of found directory. */ - u_long i_reclen; /* Size of found directory entry. */ - int i_lockcount; /* Process lock count (recursion) */ - long i_spare[10]; /* Spares to round up to 128 bytes. */ + int32_t i_count; /* Size of free slot in directory. */ + doff_t i_endoff; /* End of useful stuff in directory. */ + doff_t i_diroff; /* Offset in dir, where we found last entry. */ + doff_t i_offset; /* Offset of free space in directory. */ + ino_t i_ino; /* Inode number of found directory. */ + u_int32_t i_reclen; /* Size of found directory entry. */ + int i_lockcount; /* Process lock count (recursion) */ + int i_spare[10]; /* XXX spare storage (for ext2fs) */ /* * The on-disk dinode itself. */ @@ -102,8 +92,10 @@ struct inode { }; #define i_atime i_din.di_atime +#define i_atimensec i_din.di_atimensec #define i_blocks i_din.di_blocks #define i_ctime i_din.di_ctime +#define i_ctimensec i_din.di_ctimensec #define i_db i_din.di_db #define i_flags i_din.di_flags #define i_gen i_din.di_gen @@ -111,6 +103,7 @@ struct inode { #define i_ib i_din.di_ib #define i_mode i_din.di_mode #define i_mtime i_din.di_mtime +#define i_mtimensec i_din.di_mtimensec #define i_nlink i_din.di_nlink #define i_rdev i_din.di_rdev #define i_shortlink i_din.di_shortlink @@ -120,15 +113,12 @@ struct inode { /* These flags are kept in i_flag. */ #define IN_ACCESS 0x0001 /* Access time update request. */ #define IN_CHANGE 0x0002 /* Inode change time update request. */ -#define IN_EXLOCK 0x0004 /* File has exclusive lock. */ -#define IN_LOCKED 0x0008 /* Inode lock. */ -#define IN_LWAIT 0x0010 /* Process waiting on file lock. */ -#define IN_MODIFIED 0x0020 /* Inode has been modified. */ -#define IN_RENAME 0x0040 /* Inode is being renamed. */ -#define IN_SHLOCK 0x0080 /* File has shared lock. */ -#define IN_UPDATE 0x0100 /* Modification time update request. */ -#define IN_WANTED 0x0200 /* Inode is wanted by a process. */ -#define IN_RECURSE 0x0400 /* Recursion expected */ +#define IN_UPDATE 0x0004 /* Modification time update request. */ +#define IN_MODIFIED 0x0008 /* Inode has been modified. */ +#define IN_RENAME 0x0010 /* Inode is being renamed. */ +#define IN_SHLOCK 0x0020 /* File has shared lock. */ +#define IN_EXLOCK 0x0040 /* File has exclusive lock. */ +#define IN_RECURSE 0x0080 /* Recursion expected */ #ifdef KERNEL /* @@ -136,7 +126,7 @@ struct inode { * ufs_getlbns and used by truncate and bmap code. */ struct indir { - daddr_t in_lbn; /* Logical block number. */ + ufs_daddr_t in_lbn; /* Logical block number. */ int in_off; /* Offset in buffer. */ int in_exists; /* Flag if the block exists. */ }; @@ -155,25 +145,25 @@ struct indir { if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)->i_flag |= IN_MODIFIED; \ if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_atime.tv_sec \ + (ip)->i_atime \ = ((t1) == &time ? tv_sec : (t1)->tv_sec); \ if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_mtime.tv_sec \ + (ip)->i_mtime \ = ((t2) == &time ? tv_sec : (t2)->tv_sec); \ (ip)->i_modrev++; \ } \ if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ctime.tv_sec = tv_sec; \ + (ip)->i_ctime = tv_sec; \ (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } /* This overlays the fid structure (see mount.h). */ struct ufid { - u_short ufid_len; /* Length of structure. */ - u_short ufid_pad; /* Force long alignment. */ - ino_t ufid_ino; /* File number (ino). */ - long ufid_gen; /* Generation number. */ + u_int16_t ufid_len; /* Length of structure. */ + u_int16_t ufid_pad; /* Force 32-bit alignment. */ + ino_t ufid_ino; /* File number (ino). */ + int32_t ufid_gen; /* Generation number. */ }; #endif /* KERNEL */ |