diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-06-23 02:07:58 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-06-23 02:07:58 +0000 |
commit | 883624e9986baee8db2f3d68ff2471c6ca9beb00 (patch) | |
tree | 14f1b386656e0a15b52019132dc8f139762c1778 /sys | |
parent | 1c7daffba6f64b26bd7e1427cf933c1365bec83f (diff) |
Privatize several vnode operations that are not used by the generic code.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_alloc.c | 45 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_balloc.c | 15 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_extern.h | 17 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_inode.c | 71 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_lookup.c | 23 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_readwrite.c | 12 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_subr.c | 29 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vnops.c | 61 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 70 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 37 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_extern.h | 17 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 90 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 23 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 29 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 13 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 30 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vnops.c | 9 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 41 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 10 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 22 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_readwrite.c | 14 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 48 |
22 files changed, 291 insertions, 435 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_alloc.c b/sys/ufs/ext2fs/ext2fs_alloc.c index 77d761a4c3f..a92a896e68d 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.5 2000/04/26 23:24:40 jasoni Exp $ */ +/* $OpenBSD: ext2fs_alloc.c,v 1.6 2001/06/23 02:07:50 csapuntz Exp $ */ /* $NetBSD: ext2fs_alloc.c,v 1.1 1997/06/11 09:33:41 bouyer Exp $ */ /* @@ -141,25 +141,17 @@ nospace: * available inode is located. */ int -ext2fs_valloc(v) - void *v; +ext2fs_inode_alloc(struct inode *pip, int mode, struct ucred *cred, + struct vnode **vpp) { - struct vop_valloc_args /* { - struct vnode *a_pvp; - int a_mode; - struct ucred *a_cred; - struct vnode **a_vpp; - } */ *ap = v; - register struct vnode *pvp = ap->a_pvp; - register struct inode *pip; - register struct m_ext2fs *fs; - register struct inode *ip; - mode_t mode = ap->a_mode; + struct vnode *pvp; + struct m_ext2fs *fs; + struct inode *ip; ino_t ino, ipref; int cg, error; - *ap->a_vpp = NULL; - pip = VTOI(pvp); + *vpp = NULL; + pvp = ITOV(pip); fs = pip->i_e2fs; if (fs->e2fs.e2fs_ficount == 0) goto noinodes; @@ -172,12 +164,12 @@ ext2fs_valloc(v) ino = (ino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg); if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, ap->a_vpp); + error = VFS_VGET(pvp->v_mount, ino, vpp); if (error) { - VOP_VFREE(pvp, ino, mode); + ext2fs_inode_free(pip, ino, mode); return (error); } - ip = VTOI(*ap->a_vpp); + ip = VTOI(*vpp); if (ip->i_e2fs_mode && ip->i_e2fs_nlink != 0) { printf("mode = 0%o, nlinks %d, inum = %d, fs = %s\n", ip->i_e2fs_mode, ip->i_e2fs_nlink, ip->i_number, fs->e2fs_fsmnt); @@ -194,7 +186,7 @@ ext2fs_valloc(v) ip->i_e2fs_gen = ext2gennumber; return (0); noinodes: - ext2fs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); + ext2fs_fserr(fs, cred->cr_uid, "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt); return (ENOSPC); } @@ -542,22 +534,13 @@ ext2fs_blkfree(ip, bno) * The specified inode is placed back in the free map. */ int -ext2fs_vfree(v) - void *v; +ext2fs_inode_free(struct inode *pip, ino_t ino, int mode) { - struct vop_vfree_args /* { - struct vnode *a_pvp; - ino_t a_ino; - int a_mode; - } */ *ap = v; register struct m_ext2fs *fs; register char *ibp; - register struct inode *pip; - ino_t ino = ap->a_ino; struct buf *bp; int error, cg; - pip = VTOI(ap->a_pvp); fs = pip->i_e2fs; if ((u_int)ino >= fs->e2fs.e2fs_icount || (u_int)ino < EXT2_FIRSTINO) panic("ifree: range: dev = 0x%x, ino = %d, fs = %s", @@ -581,7 +564,7 @@ ext2fs_vfree(v) clrbit(ibp, ino); fs->e2fs.e2fs_ficount++; fs->e2fs_gd[cg].ext2bgd_nifree++; - if ((ap->a_mode & IFMT) == IFDIR) { + if ((mode & IFMT) == IFDIR) { fs->e2fs_gd[cg].ext2bgd_ndirs--; } fs->e2fs_fmod = 1; diff --git a/sys/ufs/ext2fs/ext2fs_balloc.c b/sys/ufs/ext2fs/ext2fs_balloc.c index f45e8a6781e..f105424b2a9 100644 --- a/sys/ufs/ext2fs/ext2fs_balloc.c +++ b/sys/ufs/ext2fs/ext2fs_balloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_balloc.c,v 1.4 1999/01/11 05:12:36 millert Exp $ */ +/* $OpenBSD: ext2fs_balloc.c,v 1.5 2001/06/23 02:07:50 csapuntz Exp $ */ /* $NetBSD: ext2fs_balloc.c,v 1.1 1997/06/11 09:33:44 bouyer Exp $ */ /* @@ -60,16 +60,11 @@ * the inode and the logical block number in a file. */ int -ext2fs_balloc(ip, bn, size, cred, bpp, flags) - register struct inode *ip; - register daddr_t bn; - int size; - struct ucred *cred; - struct buf **bpp; - int flags; +ext2fs_buf_alloc(struct inode *ip, daddr_t bn, int size, struct ucred *cred, + struct buf **bpp, int flags) { - register struct m_ext2fs *fs; - register daddr_t nb; + struct m_ext2fs *fs; + daddr_t nb; struct buf *bp, *nbp; struct vnode *vp = ITOV(ip); struct indir indirs[NIADDR + 2]; diff --git a/sys/ufs/ext2fs/ext2fs_extern.h b/sys/ufs/ext2fs/ext2fs_extern.h index 9f79e9d8a3b..97bc9128b7d 100644 --- a/sys/ufs/ext2fs/ext2fs_extern.h +++ b/sys/ufs/ext2fs/ext2fs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_extern.h,v 1.8 2001/02/20 01:50:12 assar Exp $ */ +/* $OpenBSD: ext2fs_extern.h,v 1.9 2001/06/23 02:07:51 csapuntz Exp $ */ /* $NetBSD: ext2fs_extern.h,v 1.1 1997/06/11 09:33:55 bouyer Exp $ */ /*- @@ -65,22 +65,24 @@ int ext2fs_alloc __P((struct inode *, daddr_t, daddr_t , struct ucred *, int ext2fs_realloccg __P((struct inode *, daddr_t, daddr_t, int, int , struct ucred *, struct buf **)); int ext2fs_reallocblks __P((void *)); -int ext2fs_valloc __P((void *)); +int ext2fs_inode_alloc(struct inode *pip, int mode, struct ucred *, + struct vnode **); daddr_t ext2fs_blkpref __P((struct inode *, daddr_t, int, daddr_t *)); void ext2fs_blkfree __P((struct inode *, daddr_t)); -int ext2fs_vfree __P((void *)); +int ext2fs_inode_free(struct inode *pip, ino_t ino, int mode); /* ext2fs_balloc.c */ -int ext2fs_balloc __P((struct inode *, daddr_t, int, struct ucred *, - struct buf **, int)); +int ext2fs_buf_alloc(struct inode *, daddr_t, int, struct ucred *, + struct buf **, int); /* ext2fs_bmap.c */ int ext2fs_bmap __P((void *)); /* ext2fs_inode.c */ int ext2fs_init __P((struct vfsconf *)); -int ext2fs_update __P((void *)); -int ext2fs_truncate __P((void *)); +int ext2fs_update(struct inode *ip, struct timespec *atime, + struct timespec *mtime, int waitfor); +int ext2fs_truncate(struct inode *, off_t, int, struct ucred *); int ext2fs_inactive __P((void *)); /* ext2fs_lookup.c */ @@ -95,6 +97,7 @@ int ext2fs_dirempty __P((struct inode *, ino_t, struct ucred *)); int ext2fs_checkpath __P((struct inode *, struct inode *, struct ucred *)); /* ext2fs_subr.c */ +int ext2fs_bufatoff(struct inode *, off_t, char **, struct buf **); int ext2fs_blkatoff __P((void *)); void ext2fs_fragacct __P((struct m_ext2fs *, int, int32_t[], int)); #ifdef DIAGNOSTIC diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index 4c15a917c50..700dc49d4a7 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_inode.c,v 1.10 2001/05/24 07:13:43 jasoni Exp $ */ +/* $OpenBSD: ext2fs_inode.c,v 1.11 2001/06/23 02:07:51 csapuntz Exp $ */ /* $NetBSD: ext2fs_inode.c,v 1.1 1997/06/11 09:33:56 bouyer Exp $ */ /* @@ -92,15 +92,14 @@ ext2fs_inactive(v) goto out; if (ip->i_e2fs_nlink == 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - error = VOP_TRUNCATE(vp, (off_t)0, 0, NOCRED, NULL); + error = ext2fs_truncate(ip, (off_t)0, 0, NOCRED); TIMEVAL_TO_TIMESPEC(&time, &ts); ip->i_e2fs_dtime = ts.tv_sec; ip->i_flag |= IN_CHANGE | IN_UPDATE; - VOP_VFREE(vp, ip->i_number, ip->i_e2fs_mode); + ext2fs_inode_free(ip, ip->i_number, ip->i_e2fs_mode); } if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - VOP_UPDATE(vp, &ts, &ts, 0); + ext2fs_update(ip, NULL, NULL, 0); } out: VOP_UNLOCK(vp, 0, ap->a_p); @@ -124,28 +123,20 @@ out: * complete. */ int -ext2fs_update(v) - void *v; +ext2fs_update(struct inode *ip, struct timespec *atime, struct timespec *mtime, + int waitfor) { - struct vop_update_args /* { - struct vnode *a_vp; - struct timespec *a_access; - struct timespec *a_modify; - int a_waitfor; - } */ *ap = v; - register struct m_ext2fs *fs; + struct m_ext2fs *fs; struct buf *bp; - struct inode *ip; int error; struct timespec ts; - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) + if (ITOV(ip)->v_mount->mnt_flag & MNT_RDONLY) return (0); - ip = VTOI(ap->a_vp); TIMEVAL_TO_TIMESPEC(&time, &ts); EXT2FS_ITIMES(ip, - ap->a_access ? ap->a_access : &ts, - ap->a_modify ? ap->a_modify : &ts); + atime ? atime : &ts, + mtime ? mtime : &ts); if ((ip->i_flag & IN_MODIFIED) == 0) return (0); ip->i_flag &= ~IN_MODIFIED; @@ -160,7 +151,7 @@ ext2fs_update(v) bcopy(&ip->i_din.e2fs_din, ((struct ext2fs_dinode *)bp->b_data + ino_to_fsbo(fs, ip->i_number)), sizeof(struct ext2fs_dinode)); - if (ap->a_waitfor) + if (waitfor) return (bwrite(bp)); else { bdwrite(bp); @@ -176,27 +167,16 @@ ext2fs_update(v) * disk blocks. */ int -ext2fs_truncate(v) - void *v; +ext2fs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) { - struct vop_truncate_args /* { - struct vnode *a_vp; - off_t a_length; - int a_flags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap = v; - register struct vnode *ovp = ap->a_vp; - register daddr_t lastblock; - register struct inode *oip; + struct vnode *ovp = ITOV(oip); + daddr_t lastblock; daddr_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; - off_t length = ap->a_length; register struct m_ext2fs *fs; struct buf *bp; int offset, size, level; long count, nblocks, vflags, blocksreleased = 0; - struct timespec ts; register int i; int aflags, error, allerror; off_t osize; @@ -204,8 +184,6 @@ ext2fs_truncate(v) if (length < 0) return (EINVAL); - oip = VTOI(ovp); - TIMEVAL_TO_TIMESPEC(&time, &ts); if (ovp->v_type == VLNK && (oip->i_e2fs_size < ovp->v_mount->mnt_maxsymlinklen || (ovp->v_mount->mnt_maxsymlinklen == 0 && @@ -218,11 +196,11 @@ ext2fs_truncate(v) (u_int)oip->i_e2fs_size); oip->i_e2fs_size = 0; oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 1)); + return (ext2fs_update(oip, NULL, NULL, 1)); } if (oip->i_e2fs_size == length) { oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 0)); + return (ext2fs_update(oip, NULL, NULL, 0)); } fs = oip->i_e2fs; osize = oip->i_e2fs_size; @@ -239,10 +217,10 @@ ext2fs_truncate(v) offset = blkoff(fs, length - 1); lbn = lblkno(fs, length - 1); aflags = B_CLRBUF; - if (ap->a_flags & IO_SYNC) + if (flags & IO_SYNC) aflags |= B_SYNC; - error = ext2fs_balloc(oip, lbn, offset + 1, ap->a_cred, &bp, - aflags); + error = ext2fs_buf_alloc(oip, lbn, offset + 1, cred, &bp, + aflags); if (error) return (error); oip->i_e2fs_size = length; @@ -258,7 +236,7 @@ ext2fs_truncate(v) else bawrite(bp); oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 1)); + return (ext2fs_update(oip, NULL, NULL, 1)); } /* * Shorten the size of the file. If the file is not being @@ -273,9 +251,10 @@ ext2fs_truncate(v) } else { lbn = lblkno(fs, length); aflags = B_CLRBUF; - if (ap->a_flags & IO_SYNC) + if (flags & IO_SYNC) aflags |= B_SYNC; - error = ext2fs_balloc(oip, lbn, offset, ap->a_cred, &bp, aflags); + error = ext2fs_buf_alloc(oip, lbn, offset, cred, &bp, + aflags); if (error) return (error); oip->i_e2fs_size = length; @@ -320,7 +299,7 @@ ext2fs_truncate(v) for (i = NDADDR - 1; i > lastblock; i--) oip->i_e2fs_blocks[i] = 0; oip->i_flag |= IN_CHANGE | IN_UPDATE; - if ((error = VOP_UPDATE(ovp, &ts, &ts, 1)) != 0) + if ((error = ext2fs_update(oip, NULL, NULL, 1)) != 0) allerror = error; /* * Having written the new inode to disk, save its new configuration @@ -332,7 +311,7 @@ ext2fs_truncate(v) bcopy((caddr_t)oldblks, (caddr_t)&oip->i_e2fs_blocks[0], sizeof oldblks); oip->i_e2fs_size = osize; vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA; - allerror = vinvalbuf(ovp, vflags, ap->a_cred, ap->a_p, 0, 0); + allerror = vinvalbuf(ovp, vflags, cred, curproc, 0, 0); /* * Indirect blocks first. diff --git a/sys/ufs/ext2fs/ext2fs_lookup.c b/sys/ufs/ext2fs/ext2fs_lookup.c index 19b216fe646..2b96297783e 100644 --- a/sys/ufs/ext2fs/ext2fs_lookup.c +++ b/sys/ufs/ext2fs/ext2fs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_lookup.c,v 1.9 2001/04/06 02:26:12 csapuntz Exp $ */ +/* $OpenBSD: ext2fs_lookup.c,v 1.10 2001/06/23 02:07:51 csapuntz Exp $ */ /* $NetBSD: ext2fs_lookup.c,v 1.1 1997/06/11 09:33:59 bouyer Exp $ */ /* @@ -398,7 +398,8 @@ ext2fs_lookup(v) } else { dp->i_offset = dp->i_diroff; if ((entryoffsetinblock = dp->i_offset & bmask) && - (error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp))) + (error = ext2fs_bufatoff(dp, (off_t)dp->i_offset, + NULL, &bp))) return (error); numdirpasses = 2; } @@ -414,7 +415,8 @@ searchloop: if ((dp->i_offset & bmask) == 0) { if (bp != NULL) brelse(bp); - error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp); + error = ext2fs_bufatoff(dp, (off_t)dp->i_offset, + NULL, &bp); if (error != 0) return (error); entryoffsetinblock = 0; @@ -850,7 +852,8 @@ ext2fs_direnter(ip, dvp, cnp) /* * Get the block containing the space for the new directory entry. */ - if ((error = VOP_BLKATOFF(dvp, (off_t)dp->i_offset, &dirbuf, &bp)) != 0) + if ((error = ext2fs_bufatoff(dp, (off_t)dp->i_offset, &dirbuf, &bp)) + != 0) return (error); /* * Find space for the new entry. In the simple case, the entry at @@ -903,8 +906,8 @@ ext2fs_direnter(ip, dvp, cnp) error = VOP_BWRITE(bp); dp->i_flag |= IN_CHANGE | IN_UPDATE; if (!error && dp->i_endoff && dp->i_endoff < dp->i_e2fs_size) - error = VOP_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, - cnp->cn_cred, cnp->cn_proc); + error = ext2fs_truncate(dp, (off_t)dp->i_endoff, IO_SYNC, + cnp->cn_cred); return (error); } @@ -935,7 +938,8 @@ ext2fs_dirremove(dvp, cnp) /* * First entry in block: set d_ino to zero. */ - error = VOP_BLKATOFF(dvp, (off_t)dp->i_offset, (char **)&ep, &bp); + error = ext2fs_bufatoff(dp, (off_t)dp->i_offset, (char **)&ep, + &bp); if (error != 0) return (error); ep->e2d_ino = 0; @@ -946,7 +950,7 @@ ext2fs_dirremove(dvp, cnp) /* * Collapse new free space into previous entry. */ - error = VOP_BLKATOFF(dvp, (off_t)(dp->i_offset - dp->i_count), + error = ext2fs_bufatoff(dp, (off_t)(dp->i_offset - dp->i_count), (char **)&ep, &bp); if (error != 0) return (error); @@ -968,10 +972,9 @@ ext2fs_dirrewrite(dp, ip, cnp) { struct buf *bp; struct ext2fs_direct *ep; - struct vnode *vdp = ITOV(dp); int error; - error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, (char **)&ep, &bp); + error = ext2fs_bufatoff(dp, (off_t)dp->i_offset, (char **)&ep, &bp); if (error != 0) return (error); ep->e2d_ino = h2fs32(ip->i_number); diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index 8985d4c1918..df692010097 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_readwrite.c,v 1.6 2001/02/23 14:42:39 csapuntz Exp $ */ +/* $OpenBSD: ext2fs_readwrite.c,v 1.7 2001/06/23 02:07:51 csapuntz Exp $ */ /* $NetBSD: ext2fs_readwrite.c,v 1.1 1997/06/11 09:34:01 bouyer Exp $ */ /*- @@ -188,7 +188,6 @@ ext2fs_write(v) daddr_t lbn; off_t osize; int blkoffset, error, flags, ioflag, resid, size, xfersize; - struct timespec ts; ioflag = ap->a_ioflag; uio = ap->a_uio; @@ -250,7 +249,7 @@ ext2fs_write(v) else flags &= ~B_CLRBUF; - error = ext2fs_balloc(ip, + error = ext2fs_buf_alloc(ip, lbn, blkoffset + xfersize, ap->a_cred, &bp, flags); if (error) break; @@ -296,14 +295,13 @@ ext2fs_write(v) ip->i_e2fs_mode &= ~(ISUID | ISGID); if (error) { if (ioflag & IO_UNIT) { - (void)VOP_TRUNCATE(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_procp); + (void)ext2fs_truncate(ip, osize, + ioflag & IO_SYNC, ap->a_cred); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } } else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - error = VOP_UPDATE(vp, &ts, &ts, 1); + error = ext2fs_update(ip, NULL, NULL, 1); } return (error); } diff --git a/sys/ufs/ext2fs/ext2fs_subr.c b/sys/ufs/ext2fs/ext2fs_subr.c index 886079ab2e3..f5094aeff8f 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.3 1997/06/12 21:09:35 downsj Exp $ */ +/* $OpenBSD: ext2fs_subr.c,v 1.4 2001/06/23 02:07:52 csapuntz Exp $ */ /* $NetBSD: ext2fs_subr.c,v 1.1 1997/06/11 09:34:03 bouyer Exp $ */ /* @@ -55,33 +55,26 @@ * remaining space in the directory. */ int -ext2fs_blkatoff(v) - void *v; +ext2fs_bufatoff(struct inode *ip, off_t offset, char **res, struct buf **bpp) { - struct vop_blkatoff_args /* { - struct vnode *a_vp; - off_t a_offset; - char **a_res; - struct buf **a_bpp; - } */ *ap = v; - struct inode *ip; - register struct m_ext2fs *fs; + struct vnode *vp; + struct m_ext2fs *fs; struct buf *bp; daddr_t lbn; int error; - ip = VTOI(ap->a_vp); + vp = ITOV(ip); fs = ip->i_e2fs; - lbn = lblkno(fs, ap->a_offset); + lbn = lblkno(fs, offset); - *ap->a_bpp = NULL; - if ((error = bread(ap->a_vp, lbn, fs->e2fs_bsize, NOCRED, &bp)) != 0) { + *bpp = NULL; + if ((error = bread(vp, lbn, fs->e2fs_bsize, NOCRED, &bp)) != 0) { brelse(bp); return (error); } - if (ap->a_res) - *ap->a_res = (char *)bp->b_data + blkoff(fs, ap->a_offset); - *ap->a_bpp = bp; + if (res) + *res = (char *)bp->b_data + blkoff(fs, offset); + *bpp = bp; return (0); } #endif diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 00c1b404429..e991c350749 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.12 2001/06/05 21:37:50 provos Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.13 2001/06/23 02:07:52 csapuntz Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -348,11 +348,10 @@ ext2fs_setattr(v) default: break; } - error = VOP_TRUNCATE(vp, vap->va_size, 0, cred, p); + error = ext2fs_truncate(ip, vap->va_size, 0, cred); if (error) return (error); } - ip = VTOI(vp); if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); @@ -366,7 +365,7 @@ ext2fs_setattr(v) ip->i_flag |= IN_ACCESS; if (vap->va_mtime.tv_sec != VNOVAL) ip->i_flag |= IN_CHANGE | IN_UPDATE; - error = VOP_UPDATE(vp, &vap->va_atime, &vap->va_mtime, 1); + error = ext2fs_update(ip, &vap->va_atime, &vap->va_mtime, 1); if (error) return (error); } @@ -543,7 +542,7 @@ ext2fs_link(v) } ip->i_e2fs_nlink++; ip->i_flag |= IN_CHANGE; - error = VOP_UPDATE(vp, NULL, NULL, 1); + error = ext2fs_update(ip, NULL, NULL, 1); if (!error) error = ext2fs_direnter(ip, dvp, cnp); if (error) { @@ -724,7 +723,7 @@ abortit: */ ip->i_e2fs_nlink++; ip->i_flag |= IN_CHANGE; - if ((error = VOP_UPDATE(fvp, NULL, NULL, 1)) != 0) { + if ((error = ext2fs_update(ip, NULL, NULL, 1)) != 0) { VOP_UNLOCK(fvp, 0, p); goto bad; } @@ -782,7 +781,7 @@ abortit: } dp->i_e2fs_nlink++; dp->i_flag |= IN_CHANGE; - if ((error = VOP_UPDATE(tdvp, NULL, NULL, 1)) != 0) + if ((error = ext2fs_update(dp, NULL, NULL, 1)) != 0) goto bad; } error = ext2fs_direnter(ip, tdvp, tcnp); @@ -790,7 +789,7 @@ abortit: if (doingdirectory && newparent) { dp->i_e2fs_nlink--; dp->i_flag |= IN_CHANGE; - (void)VOP_UPDATE(tdvp, NULL, NULL, 1); + (void)ext2fs_update(dp, NULL, NULL, 1); } goto bad; } @@ -863,8 +862,8 @@ abortit: if (doingdirectory) { if (--xp->i_e2fs_nlink != 0) panic("rename: linked directory"); - error = VOP_TRUNCATE(tvp, (off_t)0, IO_SYNC, - tcnp->cn_cred, tcnp->cn_proc); + error = ext2fs_truncate(xp, (off_t)0, IO_SYNC, + tcnp->cn_cred); } xp->i_flag |= IN_CHANGE; vput(tvp); @@ -1005,7 +1004,7 @@ ext2fs_mkdir(v) * but not have it entered in the parent directory. The entry is * made later after writing "." and ".." entries. */ - if ((error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp)) != 0) + if ((error = ext2fs_inode_alloc(dp, dmode, cnp->cn_cred, &tvp)) != 0) goto out; ip = VTOI(tvp); ip->i_e2fs_uid = cnp->cn_cred->cr_uid; @@ -1014,7 +1013,7 @@ ext2fs_mkdir(v) ip->i_e2fs_mode = dmode; tvp->v_type = VDIR; /* Rest init'd in getnewvnode(). */ ip->i_e2fs_nlink = 2; - error = VOP_UPDATE(tvp, NULL, NULL, 1); + error = ext2fs_update(ip, NULL, NULL, 1); /* * Bump link count in parent directory @@ -1024,7 +1023,7 @@ ext2fs_mkdir(v) */ dp->i_e2fs_nlink++; dp->i_flag |= IN_CHANGE; - if ((error = VOP_UPDATE(dvp, NULL, NULL, 1)) != 0) + if ((error = ext2fs_update(dp, NULL, NULL, 1)) != 0) goto bad; /* Initialize directory with "." and ".." from static template. */ @@ -1155,8 +1154,7 @@ ext2fs_rmdir(v) * worry about them later. */ ip->i_e2fs_nlink -= 2; - error = VOP_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, - cnp->cn_proc); + error = ext2fs_truncate(ip, (off_t)0, IO_SYNC, cnp->cn_cred); cache_purge(ITOV(ip)); out: if (dvp) @@ -1325,7 +1323,6 @@ ext2fs_makeinode(mode, dvp, vpp, cnp) struct componentname *cnp; { register struct inode *ip, *pdir; - struct timespec ts; struct vnode *tvp; int error; @@ -1338,7 +1335,8 @@ ext2fs_makeinode(mode, dvp, vpp, cnp) if ((mode & IFMT) == 0) mode |= IFREG; - if ((error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) != 0) { + if ((error = ext2fs_inode_alloc(pdir, mode, cnp->cn_cred, &tvp)) + != 0) { free(cnp->cn_pnbuf, M_NAMEI); vput(dvp); return (error); @@ -1358,8 +1356,7 @@ ext2fs_makeinode(mode, dvp, vpp, cnp) /* * Make sure inode goes to disk before directory entry. */ - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(tvp, &ts, &ts, 1)) != 0) + if ((error = ext2fs_update(ip, NULL, NULL, 1)) != 0) goto bad; error = ext2fs_direnter(ip, dvp, cnp); if (error != 0) @@ -1398,11 +1395,10 @@ ext2fs_fsync(v) struct proc *a_p; } */ *ap = v; register struct vnode *vp = ap->a_vp; - struct timespec ts; vflushbuf(vp, ap->a_waitfor == MNT_WAIT); - TIMEVAL_TO_TIMESPEC(&time, &ts); - return (VOP_UPDATE(ap->a_vp, &ts, &ts, ap->a_waitfor == MNT_WAIT)); + return (ext2fs_update(VTOI(ap->a_vp), NULL, NULL, + ap->a_waitfor == MNT_WAIT)); } /* @@ -1458,9 +1454,7 @@ struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = { { &vop_ioctl_desc, ufs_ioctl }, /* ioctl */ { &vop_select_desc, ufs_select }, /* select */ { &vop_kqfilter_desc, vop_generic_kqfilter }, /* kqfilter */ - { &vop_mmap_desc, ufs_mmap }, /* mmap */ { &vop_fsync_desc, ext2fs_fsync }, /* fsync */ - { &vop_seek_desc, ufs_seek }, /* seek */ { &vop_remove_desc, ext2fs_remove }, /* remove */ { &vop_link_desc, ext2fs_link }, /* link */ { &vop_rename_desc, ext2fs_rename }, /* rename */ @@ -1480,11 +1474,6 @@ struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, ufs_pathconf }, /* pathconf */ { &vop_advlock_desc, ext2fs_advlock }, /* advlock */ - { &vop_blkatoff_desc, ext2fs_blkatoff },/* blkatoff */ - { &vop_valloc_desc, ext2fs_valloc }, /* valloc */ - { &vop_vfree_desc, ext2fs_vfree }, /* vfree */ - { &vop_truncate_desc, ext2fs_truncate },/* truncate */ - { &vop_update_desc, ext2fs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, /* bwrite */ { (struct vnodeop_desc*)NULL, (int(*) __P((void*)))NULL } }; @@ -1508,9 +1497,7 @@ struct vnodeopv_entry_desc ext2fs_specop_entries[] = { { &vop_ioctl_desc, spec_ioctl }, /* ioctl */ { &vop_select_desc, spec_select }, /* poll */ { &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */ - { &vop_mmap_desc, spec_mmap }, /* mmap */ { &vop_fsync_desc, ext2fs_fsync }, /* fsync */ - { &vop_seek_desc, spec_seek }, /* seek */ { &vop_remove_desc, spec_remove }, /* remove */ { &vop_link_desc, spec_link }, /* link */ { &vop_rename_desc, spec_rename }, /* rename */ @@ -1530,11 +1517,6 @@ struct vnodeopv_entry_desc ext2fs_specop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, spec_pathconf }, /* pathconf */ { &vop_advlock_desc, spec_advlock }, /* advlock */ - { &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, spec_valloc }, /* valloc */ - { &vop_vfree_desc, ext2fs_vfree }, /* vfree */ - { &vop_truncate_desc, spec_truncate }, /* truncate */ - { &vop_update_desc, ext2fs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, /* bwrite */ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; @@ -1559,9 +1541,7 @@ struct vnodeopv_entry_desc ext2fs_fifoop_entries[] = { { &vop_ioctl_desc, fifo_ioctl }, /* ioctl */ { &vop_select_desc, fifo_select }, /* select */ { &vop_kqfilter_desc, fifo_kqfilter }, /* kqfilter */ - { &vop_mmap_desc, fifo_mmap }, /* mmap */ { &vop_fsync_desc, ext2fs_fsync }, /* fsync */ - { &vop_seek_desc, fifo_seek }, /* seek */ { &vop_remove_desc, fifo_remove }, /* remove */ { &vop_link_desc, fifo_link }, /* link */ { &vop_rename_desc, fifo_rename }, /* rename */ @@ -1581,11 +1561,6 @@ struct vnodeopv_entry_desc ext2fs_fifoop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */ { &vop_advlock_desc, fifo_advlock }, /* advlock */ - { &vop_blkatoff_desc, fifo_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, fifo_valloc }, /* valloc */ - { &vop_vfree_desc, ext2fs_vfree }, /* vfree */ - { &vop_truncate_desc, fifo_truncate }, /* truncate */ - { &vop_update_desc, ext2fs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, /* bwrite */ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index c473c617942..f5593ee5743 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.28 2001/04/19 16:22:16 gluk Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.29 2001/06/23 02:07:53 csapuntz Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -73,7 +73,6 @@ static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); #ifdef DIAGNOSTIC static int ffs_checkblk __P((struct inode *, daddr_t, long)); #endif -int ffs_freefile __P((struct vop_vfree_args *)); /* * Allocate a block in the file system. @@ -346,7 +345,6 @@ ffs_reallocblks(v) daddr_t start_lbn, end_lbn, soff, newblk, blkno; struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp; int i, len, start_lvl, end_lvl, pref, ssize; - struct timespec ts; if (doreallocblks == 0) return (ENOSPC); @@ -492,8 +490,7 @@ ffs_reallocblks(v) } else { ip->i_flag |= IN_CHANGE | IN_UPDATE; if (!doasyncfree) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - VOP_UPDATE(vp, &ts, &ts, 1); + UFS_UPDATE(ip, MNT_WAIT); } } if (ssize < len) { @@ -555,25 +552,16 @@ fail: * available inode is located. */ int -ffs_valloc(v) - void *v; +ffs_inode_alloc(struct inode *pip, int mode, struct ucred *cred, + struct vnode **vpp) { - struct vop_valloc_args /* { - struct vnode *a_pvp; - int a_mode; - struct ucred *a_cred; - struct vnode **a_vpp; - } */ *ap = v; - register struct vnode *pvp = ap->a_pvp; - register struct inode *pip; - register struct fs *fs; - register struct inode *ip; - mode_t mode = ap->a_mode; + struct vnode *pvp = ITOV(pip); + struct fs *fs; + struct inode *ip; ino_t ino, ipref; int cg, error; - *ap->a_vpp = NULL; - pip = VTOI(pvp); + *vpp = NULL; fs = pip->i_fs; if (fs->fs_cstotal.cs_nifree == 0) goto noinodes; @@ -600,12 +588,12 @@ ffs_valloc(v) ino = (ino_t)ffs_hashalloc(pip, cg, (long)ipref, mode, ffs_nodealloccg); if (ino == 0) goto noinodes; - error = VFS_VGET(pvp->v_mount, ino, ap->a_vpp); + error = VFS_VGET(pvp->v_mount, ino, vpp); if (error) { - VOP_VFREE(pvp, ino, mode); + ffs_inode_free(pip, ino, mode); return (error); } - ip = VTOI(*ap->a_vpp); + ip = VTOI(*vpp); if (ip->i_ffs_mode) { printf("mode = 0%o, inum = %d, fs = %s\n", ip->i_ffs_mode, ip->i_number, fs->fs_fsmnt); @@ -628,7 +616,7 @@ ffs_valloc(v) ip->i_ffs_gen = 1; /* shouldn't happen */ return (0); noinodes: - ffs_fserr(fs, ap->a_cred->cr_uid, "out of inodes"); + ffs_fserr(fs, cred->cr_uid, "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); return (ENOSPC); } @@ -1495,25 +1483,17 @@ ffs_blkfree(ip, bno, size) bdwrite(bp); } -/* - * Free an inode. - */ int -ffs_vfree(v) - void *v; +ffs_inode_free(struct inode *pip, ino_t ino, int mode) { - struct vop_vfree_args /* { - struct vnode *a_pvp; - ino_t a_ino; - int a_mode; - } */ *ap = v; + struct vnode *pvp = ITOV(pip); - if (DOINGSOFTDEP(ap->a_pvp)) { - softdep_freefile(ap->a_pvp, ap->a_ino, ap->a_mode); + if (DOINGSOFTDEP(pvp)) { + softdep_freefile(pvp, ino, mode); return (0); } - return (ffs_freefile(ap)); + return (ffs_freefile(pip, ino, mode)); } /* @@ -1521,21 +1501,13 @@ ffs_vfree(v) * The specified inode is placed back in the free map. */ int -ffs_freefile(ap) - struct vop_vfree_args /* { - struct vnode *a_pvp; - ino_t a_ino; - int a_mode; - } */ *ap; +ffs_freefile(struct inode *pip, ino_t ino, int mode) { - register struct fs *fs; - register struct cg *cgp; - register struct inode *pip; - ino_t ino = ap->a_ino; + struct fs *fs; + struct cg *cgp; struct buf *bp; int error, cg; - pip = VTOI(ap->a_pvp); fs = pip->i_fs; if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) panic("ffs_freefile: range: dev = 0x%x, ino = %d, fs = %s", @@ -1566,7 +1538,7 @@ ffs_freefile(ap) cgp->cg_cs.cs_nifree++; fs->fs_cstotal.cs_nifree++; fs->fs_cs(fs, cg).cs_nifree++; - if ((ap->a_mode & IFMT) == IFDIR) { + if ((mode & IFMT) == IFDIR) { cgp->cg_cs.cs_ndir--; fs->fs_cstotal.cs_ndir--; fs->fs_cs(fs, cg).cs_ndir--; diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 4fc440ceedb..0c1d2782a46 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_balloc.c,v 1.12 2001/03/20 19:33:06 art Exp $ */ +/* $OpenBSD: ffs_balloc.c,v 1.13 2001/06/23 02:07:53 csapuntz Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */ /* @@ -63,22 +63,10 @@ * the inode and the logical block number in a file. */ int -ffs_balloc(v) - void *v; +ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, + int flags, struct buf **bpp) { - struct vop_balloc_args /* { - struct vnode *a_vp; - off_t a_startpoint; - int a_size; - struct ucred *a_cred; - int a_flags; - struct buf **a_bpp; - } */ *ap = v; - struct inode *ip; daddr_t lbn; - int size; - struct ucred *cred; - int flags; struct fs *fs; daddr_t nb; struct buf *bp, *nbp; @@ -89,18 +77,15 @@ ffs_balloc(v) daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR+1]; int unwindidx = -1; - vp = ap->a_vp; - ip = VTOI(vp); + vp = ITOV(ip); fs = ip->i_fs; - lbn = lblkno(fs, ap->a_startoffset); - size = blkoff(fs, ap->a_startoffset) + ap->a_size; + lbn = lblkno(fs, startoffset); + size = blkoff(fs, startoffset) + size; if (size > fs->fs_bsize) panic("ffs_balloc: blk too big"); - *ap->a_bpp = NULL; + *bpp = NULL; if (lbn < 0) return (EFBIG); - cred = ap->a_cred; - flags = ap->a_flags; /* * If the next write will extend the file into a new block, @@ -146,7 +131,7 @@ ffs_balloc(v) brelse(bp); return (error); } - *ap->a_bpp = bp; + *bpp = bp; return (0); } if (nb != 0) { @@ -193,7 +178,7 @@ ffs_balloc(v) } ip->i_ffs_db[lbn] = dbtofsb(fs, bp->b_blkno); ip->i_flag |= IN_CHANGE | IN_UPDATE; - *ap->a_bpp = bp; + *bpp = bp; return (0); } /* @@ -333,7 +318,7 @@ ffs_balloc(v) } else { bdwrite(bp); } - *ap->a_bpp = nbp; + *bpp = nbp; return (0); } brelse(bp); @@ -347,7 +332,7 @@ ffs_balloc(v) nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } - *ap->a_bpp = nbp; + *bpp = nbp; return (0); fail: diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 38466edc2c6..40f61d068b4 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.12 2001/03/22 00:11:36 art Exp $ */ +/* $OpenBSD: ffs_extern.h,v 1.13 2001/06/23 02:07:53 csapuntz Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /*- @@ -77,27 +77,28 @@ int ffs_alloc __P((struct inode *, daddr_t, daddr_t , int, struct ucred *, int ffs_realloccg __P((struct inode *, daddr_t, daddr_t, int, int , struct ucred *, struct buf **)); int ffs_reallocblks __P((void *)); -int ffs_valloc __P((void *)); +int ffs_inode_alloc(struct inode *, int, struct ucred *, struct vnode **); +int ffs_inode_free(struct inode *, ino_t, int); +int ffs_freefile(struct inode *, ino_t, int); + daddr_t ffs_blkpref __P((struct inode *, daddr_t, int, daddr_t *)); void ffs_blkfree __P((struct inode *, daddr_t, long)); -int ffs_vfree __P((void *)); void ffs_clusteracct __P((struct fs *, struct cg *, daddr_t, int)); /* ffs_balloc.c */ -int ffs_balloc __P((void *)); +int ffs_balloc(struct inode *, off_t, int, struct ucred *, int, struct buf **); /* ffs_inode.c */ int ffs_init __P((struct vfsconf *)); -int ffs_update __P((void *)); -int ffs_truncate __P((void *)); +int ffs_update(struct inode *, struct timespec *, struct timespec *, int); +int ffs_truncate(struct inode *, off_t, int, struct ucred *); /* ffs_subr.c */ -int ffs_blkatoff __P((void *)); +int ffs_bufatoff(struct inode *, off_t, char **, struct buf **); void ffs_fragacct __P((struct fs *, int, int32_t[], int)); #ifdef DIAGNOSTIC void ffs_checkoverlap __P((struct buf *, struct inode *)); #endif -int ffs_freefile __P((struct vop_vfree_args *)); int ffs_isfreeblock __P((struct fs *, unsigned char *, daddr_t)); int ffs_isblock __P((struct fs *, unsigned char *, daddr_t)); void ffs_clrblock __P((struct fs *, u_char *, daddr_t)); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 26811ff1245..284af8362e5 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.19 2001/03/20 19:50:30 art Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.20 2001/06/23 02:07:54 csapuntz Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -74,40 +74,36 @@ static int ffs_indirtrunc __P((struct inode *, daddr_t, daddr_t, daddr_t, int, * of the inode to complete. */ int -ffs_update(v) - void *v; +ffs_update(struct inode *ip, struct timespec *atime, + struct timespec *mtime, int waitfor) { - struct vop_update_args /* { - struct vnode *a_vp; - struct timespec *a_access; - struct timespec *a_modify; - int a_waitfor; - } */ *ap = v; - register struct fs *fs; + struct vnode *vp; + struct fs *fs; struct buf *bp; - struct inode *ip; int error; + struct timespec ts; - ip = VTOI(ap->a_vp); - if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) { + TIMEVAL_TO_TIMESPEC(&time, &ts); + vp = ITOV(ip); + if (vp->v_mount->mnt_flag & MNT_RDONLY) { ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); return (0); - } else if ((ap->a_vp->v_mount->mnt_flag & MNT_NOATIME) && + } else if ((vp->v_mount->mnt_flag & MNT_NOATIME) && !(ip->i_flag & (IN_CHANGE | IN_UPDATE))) { ip->i_flag &= ~IN_ACCESS; } if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - ap->a_waitfor != MNT_WAIT) + waitfor != MNT_WAIT) return (0); if (ip->i_flag & IN_ACCESS) { - ip->i_ffs_atime = ap->a_access->tv_sec; - ip->i_ffs_atimensec = ap->a_access->tv_nsec; + ip->i_ffs_atime = atime ? atime->tv_sec : ts.tv_sec; + ip->i_ffs_atimensec = atime ? atime->tv_nsec : ts.tv_nsec; } if (ip->i_flag & IN_UPDATE) { - ip->i_ffs_mtime = ap->a_modify->tv_sec; - ip->i_ffs_mtimensec = ap->a_modify->tv_nsec; + ip->i_ffs_mtime = mtime ? mtime->tv_sec : ts.tv_sec; + ip->i_ffs_mtimensec = mtime ? mtime->tv_nsec : ts.tv_nsec; ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { @@ -131,14 +127,14 @@ ffs_update(v) return (error); } - if (DOINGSOFTDEP(ap->a_vp)) - softdep_update_inodeblock(ip, bp, ap->a_waitfor); + if (DOINGSOFTDEP(vp)) + softdep_update_inodeblock(ip, bp, waitfor); else if (ip->i_effnlink != ip->i_ffs_nlink) panic("ffs_update: bad link cnt"); *((struct dinode *)bp->b_data + ino_to_fsbo(fs, ip->i_number)) = ip->i_din.ffs_din; - if (ap->a_waitfor && !DOINGASYNC(ap->a_vp)) { + if (waitfor && !DOINGASYNC(vp)) { return (bwrite(bp)); } else { bdwrite(bp); @@ -154,37 +150,25 @@ ffs_update(v) * disk blocks. */ int -ffs_truncate(v) - void *v; +ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) { - struct vop_truncate_args /* { - struct vnode *a_vp; - off_t a_length; - int a_flags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap = v; - register struct vnode *ovp = ap->a_vp; - register daddr_t lastblock; - register struct inode *oip; + struct vnode *ovp; + daddr_t lastblock; daddr_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR]; daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; - off_t length = ap->a_length; - register struct fs *fs; + struct fs *fs; struct buf *bp; int offset, size, level; long count, nblocks, vflags, blocksreleased = 0; - struct timespec ts; register int i; int aflags, error, allerror; off_t osize; if (length < 0) return (EINVAL); - oip = VTOI(ovp); + ovp = ITOV(oip); if (oip->i_ffs_size == length) return (0); - TIMEVAL_TO_TIMESPEC(&time, &ts); if (ovp->v_type == VLNK && (oip->i_ffs_size < ovp->v_mount->mnt_maxsymlinklen || (ovp->v_mount->mnt_maxsymlinklen == 0 && @@ -196,7 +180,7 @@ ffs_truncate(v) bzero((char *)&oip->i_ffs_shortlink, (u_int)oip->i_ffs_size); oip->i_ffs_size = 0; oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 1)); + return (UFS_UPDATE(oip, MNT_WAIT)); } #ifdef QUOTA if ((error = getinoquota(oip)) != 0) @@ -221,17 +205,17 @@ ffs_truncate(v) * rarely, we solve the problem by syncing the file * so that it will have no data structures left. */ - if ((error = VOP_FSYNC(ovp, ap->a_cred, MNT_WAIT, - ap->a_p)) != 0) + if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT, + curproc)) != 0) return (error); } else { #ifdef QUOTA (void) chkdq(oip, -oip->i_ffs_blocks, NOCRED, 0); #endif softdep_setup_freeblocks(oip, length); - (void) vinvalbuf(ovp, 0, ap->a_cred, ap->a_p, 0, 0); + (void) vinvalbuf(ovp, 0, cred, curproc, 0, 0); oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 0)); + return (UFS_UPDATE(oip, 0)); } } @@ -246,10 +230,10 @@ ffs_truncate(v) if (length > fs->fs_maxfilesize) return (EFBIG); aflags = B_CLRBUF; - if (ap->a_flags & IO_SYNC) + if (flags & IO_SYNC) aflags |= B_SYNC; - error = VOP_BALLOC(ovp, length - 1, 1, - ap->a_cred, aflags, &bp); + error = UFS_BUF_ALLOC(oip, length - 1, 1, + cred, aflags, &bp); if (error) return (error); oip->i_ffs_size = length; @@ -265,7 +249,7 @@ ffs_truncate(v) else bawrite(bp); oip->i_flag |= IN_CHANGE | IN_UPDATE; - return (VOP_UPDATE(ovp, &ts, &ts, 1)); + return (UFS_UPDATE(oip, MNT_WAIT)); } #if defined(UVM) uvm_vnp_setsize(ovp, length); @@ -287,10 +271,10 @@ ffs_truncate(v) } else { lbn = lblkno(fs, length); aflags = B_CLRBUF; - if (ap->a_flags & IO_SYNC) + if (flags & IO_SYNC) aflags |= B_SYNC; - error = VOP_BALLOC(ovp, length - 1, 1, - ap->a_cred, aflags, &bp); + error = UFS_BUF_ALLOC(oip, length - 1, 1, + cred, aflags, &bp); if (error) return (error); oip->i_ffs_size = length; @@ -335,7 +319,7 @@ ffs_truncate(v) for (i = NDADDR - 1; i > lastblock; i--) oip->i_ffs_db[i] = 0; oip->i_flag |= IN_CHANGE | IN_UPDATE; - if ((error = VOP_UPDATE(ovp, &ts, &ts, 1)) != 0) + if ((error = UFS_UPDATE(oip, MNT_WAIT)) != 0) allerror = error; /* * Having written the new inode to disk, save its new configuration @@ -347,7 +331,7 @@ ffs_truncate(v) bcopy((caddr_t)oldblks, (caddr_t)&oip->i_ffs_db[0], sizeof oldblks); oip->i_ffs_size = osize; vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA; - allerror = vinvalbuf(ovp, vflags, ap->a_cred, ap->a_p, 0, 0); + allerror = vinvalbuf(ovp, vflags, cred, curproc, 0, 0); /* * Indirect blocks first. diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 1dea5971c61..1f1a648007d 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.22 2001/04/06 18:59:16 gluk Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.23 2001/06/23 02:07:54 csapuntz Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. * @@ -2832,7 +2832,7 @@ handle_workitem_remove(dirrem) panic("handle_workitem_remove: bad dir delta"); inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink; FREE_LOCK(&lk); - if ((error = VOP_TRUNCATE(vp, (off_t)0, 0, p->p_ucred, p)) != 0) + if ((error = UFS_TRUNCATE(ip, (off_t)0, 0, p->p_ucred)) != 0) softdep_error("handle_workitem_remove: truncate", error); /* * Rename a directory to a new parent. Since, we are both deleting @@ -2904,15 +2904,10 @@ handle_workitem_freefile(freefile) tip.i_fs = fs; tip.i_vnode = &vp; vp.v_data = &tip; - { - struct vop_vfree_args vargs; - vargs.a_pvp = &vp; - vargs.a_ino = freefile->fx_oldinum; - vargs.a_mode = freefile->fx_mode; - - if ((error = ffs_freefile(&vargs)) != 0) - softdep_error("handle_workitem_freefile", error); + if ((error = ffs_freefile(&tip, freefile->fx_oldinum, + freefile->fx_mode)) != 0) { + softdep_error("handle_workitem_freefile", error); } WORKITEM_FREE(freefile, D_FREEFILE); } @@ -3895,7 +3890,6 @@ softdep_fsync(vp) int error, flushparent; ino_t parentino; ufs_lbn_t lbn; - struct timespec ts; ip = VTOI(vp); fs = ip->i_fs; @@ -3960,8 +3954,7 @@ softdep_fsync(vp) if (error != 0) return (error); if (flushparent) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(pvp, &ts, &ts, MNT_WAIT))) { + if ((error = UFS_UPDATE(VTOI(pvp), MNT_WAIT))) { vput(pvp); return (error); } @@ -4398,7 +4391,6 @@ flush_pagedep_deps(pvp, mp, diraddhdp) struct inodedep *inodedep; struct ufsmount *ump; struct diradd *dap; - struct timespec ts; struct vnode *vp; int gotit, error = 0; struct buf *bp; @@ -4411,9 +4403,8 @@ flush_pagedep_deps(pvp, mp, diraddhdp) * has a MKDIR_PARENT dependency. */ if (dap->da_state & MKDIR_PARENT) { - TIMEVAL_TO_TIMESPEC(&time, &ts); FREE_LOCK(&lk); - if ((error = VOP_UPDATE(pvp, &ts, &ts, MNT_WAIT))) + if ((error = UFS_UPDATE(VTOI(pvp), MNT_WAIT))) break; ACQUIRE_LOCK(&lk); /* diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 1400d5b0cb3..3f10074d09d 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.7 2001/03/20 19:54:08 art Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.8 2001/06/23 02:07:55 csapuntz Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -53,34 +53,27 @@ * remaining space in the directory. */ int -ffs_blkatoff(v) - void *v; +ffs_bufatoff(struct inode *ip, off_t offset, char **res, struct buf **bpp) { - struct vop_blkatoff_args /* { - struct vnode *a_vp; - off_t a_offset; - char **a_res; - struct buf **a_bpp; - } */ *ap = v; - struct inode *ip; - register struct fs *fs; + struct fs *fs; + struct vnode *vp; struct buf *bp; daddr_t lbn; int bsize, error; - ip = VTOI(ap->a_vp); + vp = ITOV(ip); fs = ip->i_fs; - lbn = lblkno(fs, ap->a_offset); + lbn = lblkno(fs, offset); bsize = blksize(fs, ip, lbn); - *ap->a_bpp = NULL; - if ((error = bread(ap->a_vp, lbn, bsize, NOCRED, &bp)) != 0) { + *bpp = NULL; + if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) { brelse(bp); return (error); } - if (ap->a_res) - *ap->a_res = (char *)bp->b_data + blkoff(fs, ap->a_offset); - *ap->a_bpp = bp; + if (res) + *res = (char *)bp->b_data + blkoff(fs, offset); + *bpp = bp; return (0); } #endif diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 6df1ee27efa..c16953ed2a3 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.42 2001/05/15 23:44:41 ho Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.43 2001/06/23 02:07:55 csapuntz Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -85,6 +85,15 @@ struct vfsops ffs_vfsops = { ufs_check_export }; +struct inode_vtbl ffs_vtbl = { + ffs_truncate, + ffs_update, + ffs_inode_alloc, + ffs_inode_free, + ffs_balloc, + ffs_bufatoff +}; + extern u_long nextgennumber; /* @@ -1088,6 +1097,8 @@ retry: ip->i_fs = fs = ump->um_fs; ip->i_dev = dev; ip->i_number = ino; + ip->i_vtbl = &ffs_vtbl; + #ifdef QUOTA { int i; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 432a2fc0539..a41c5d3d0be 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.16 2001/03/22 00:11:36 art Exp $ */ +/* $OpenBSD: ffs_vnops.c,v 1.17 2001/06/23 02:07:55 csapuntz Exp $ */ /* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */ /* @@ -89,9 +89,7 @@ struct vnodeopv_entry_desc ffs_vnodeop_entries[] = { { &vop_select_desc, ufs_select }, /* select */ { &vop_kqfilter_desc, ufs_kqfilter }, /* kqfilter */ { &vop_revoke_desc, ufs_revoke }, /* revoke */ - { &vop_mmap_desc, ufs_mmap }, /* mmap */ { &vop_fsync_desc, ffs_fsync }, /* fsync */ - { &vop_seek_desc, ufs_seek }, /* seek */ { &vop_remove_desc, ufs_remove }, /* remove */ { &vop_link_desc, ufs_link }, /* link */ { &vop_rename_desc, ufs_rename }, /* rename */ @@ -111,13 +109,7 @@ struct vnodeopv_entry_desc ffs_vnodeop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, ufs_pathconf }, /* pathconf */ { &vop_advlock_desc, ufs_advlock }, /* advlock */ - { &vop_blkatoff_desc, ffs_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, ffs_valloc }, /* valloc */ - { &vop_balloc_desc, ffs_balloc }, /* balloc */ { &vop_reallocblks_desc, ffs_reallocblks }, /* reallocblks */ - { &vop_vfree_desc, ffs_vfree }, /* vfree */ - { &vop_truncate_desc, ffs_truncate }, /* truncate */ - { &vop_update_desc, ffs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, { (struct vnodeop_desc*)NULL, (int(*) __P((void*)))NULL } }; @@ -142,9 +134,7 @@ struct vnodeopv_entry_desc ffs_specop_entries[] = { { &vop_select_desc, spec_select }, /* select */ { &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */ { &vop_revoke_desc, spec_revoke }, /* revoke */ - { &vop_mmap_desc, spec_mmap }, /* mmap */ { &vop_fsync_desc, ffs_fsync }, /* fsync */ - { &vop_seek_desc, spec_seek }, /* seek */ { &vop_remove_desc, spec_remove }, /* remove */ { &vop_link_desc, spec_link }, /* link */ { &vop_rename_desc, spec_rename }, /* rename */ @@ -164,13 +154,7 @@ struct vnodeopv_entry_desc ffs_specop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, spec_pathconf }, /* pathconf */ { &vop_advlock_desc, spec_advlock }, /* advlock */ - { &vop_vfree_desc, ffs_vfree }, /* vfree */ - { &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, spec_valloc }, /* valloc */ { &vop_reallocblks_desc, spec_reallocblks }, /* reallocblks */ - { &vop_vfree_desc, ffs_vfree }, /* vfree */ - { &vop_truncate_desc, spec_truncate }, /* truncate */ - { &vop_update_desc, ffs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; @@ -196,9 +180,7 @@ struct vnodeopv_entry_desc ffs_fifoop_entries[] = { { &vop_select_desc, fifo_select }, /* select */ { &vop_kqfilter_desc, fifo_kqfilter }, /* kqfilter */ { &vop_revoke_desc, fifo_revoke }, /* revoke */ - { &vop_mmap_desc, fifo_mmap }, /* mmap */ { &vop_fsync_desc, ffs_fsync }, /* fsync */ - { &vop_seek_desc, fifo_seek }, /* seek */ { &vop_remove_desc, fifo_remove }, /* remove */ { &vop_link_desc, fifo_link }, /* link */ { &vop_rename_desc, fifo_rename }, /* rename */ @@ -218,13 +200,7 @@ struct vnodeopv_entry_desc ffs_fifoop_entries[] = { { &vop_islocked_desc, ufs_islocked }, /* islocked */ { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */ { &vop_advlock_desc, fifo_advlock }, /* advlock */ - { &vop_vfree_desc, ffs_vfree }, /* vfree */ - { &vop_blkatoff_desc, fifo_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, fifo_valloc }, /* valloc */ { &vop_reallocblks_desc, fifo_reallocblks }, /* reallocblks */ - { &vop_vfree_desc, ffs_vfree }, /* vfree */ - { &vop_truncate_desc, fifo_truncate }, /* truncate */ - { &vop_update_desc, ffs_update }, /* update */ { &vop_bwrite_desc, vop_generic_bwrite }, { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; @@ -256,7 +232,6 @@ ffs_fsync(v) } */ *ap = v; struct vnode *vp = ap->a_vp; struct buf *bp, *nbp; - struct timespec ts; int s, error, passes, skipmeta; if (vp->v_type == VBLK && @@ -338,8 +313,7 @@ loop: } } splx(s); - TIMEVAL_TO_TIMESPEC(&time, &ts); - return (VOP_UPDATE(vp, &ts, &ts, ap->a_waitfor == MNT_WAIT)); + return (UFS_UPDATE(VTOI(vp), ap->a_waitfor == MNT_WAIT)); } /* diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c index 06b686cc11c..a0a666222e1 100644 --- a/sys/ufs/mfs/mfs_vnops.c +++ b/sys/ufs/mfs/mfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfs_vnops.c,v 1.15 2001/04/12 17:16:52 csapuntz Exp $ */ +/* $OpenBSD: mfs_vnops.c,v 1.16 2001/06/23 02:07:56 csapuntz Exp $ */ /* $NetBSD: mfs_vnops.c,v 1.8 1996/03/17 02:16:32 christos Exp $ */ /* @@ -72,9 +72,7 @@ struct vnodeopv_entry_desc mfs_vnodeop_entries[] = { { &vop_ioctl_desc, mfs_ioctl }, /* ioctl */ { &vop_select_desc, mfs_select }, /* select */ { &vop_revoke_desc, mfs_revoke }, /* revoke */ - { &vop_mmap_desc, mfs_mmap }, /* mmap */ { &vop_fsync_desc, spec_fsync }, /* fsync */ - { &vop_seek_desc, mfs_seek }, /* seek */ { &vop_remove_desc, mfs_remove }, /* remove */ { &vop_link_desc, mfs_link }, /* link */ { &vop_rename_desc, mfs_rename }, /* rename */ @@ -94,11 +92,6 @@ struct vnodeopv_entry_desc mfs_vnodeop_entries[] = { { &vop_islocked_desc, mfs_islocked }, /* islocked */ { &vop_pathconf_desc, mfs_pathconf }, /* pathconf */ { &vop_advlock_desc, mfs_advlock }, /* advlock */ - { &vop_blkatoff_desc, mfs_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, mfs_valloc }, /* valloc */ - { &vop_vfree_desc, mfs_vfree }, /* vfree */ - { &vop_truncate_desc, mfs_truncate }, /* truncate */ - { &vop_update_desc, mfs_update }, /* update */ { &vop_bwrite_desc, mfs_bwrite }, /* bwrite */ { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } }; diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 6c8c402394d..2963f50748d 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.14 2001/02/24 10:37:09 deraadt Exp $ */ +/* $OpenBSD: inode.h,v 1.15 2001/06/23 02:07:56 csapuntz Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -56,6 +56,20 @@ struct ext2fs_inode_ext { ufs_daddr_t ext2fs_last_blk; /* last block allocated on disk */ }; +struct inode_vtbl { + int (* iv_truncate)(struct inode *, off_t, int, + struct ucred *); + int (* iv_update)(struct inode *, struct timespec *, struct timespec *, + int waitfor); + int (* iv_inode_alloc)(struct inode *, int mode, + struct ucred *, struct vnode **); + int (* iv_inode_free)(struct inode *, ino_t ino, int mode); + int (* iv_buf_alloc)(struct inode *, off_t, int, struct ucred *, + int, struct buf **); + int (* iv_bufatoff)(struct inode *, off_t offset, char **res, + struct buf **bpp); +} *vtbl; + /* * 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 @@ -115,8 +129,33 @@ struct inode { struct dinode ffs_din; /* 128 bytes of the on-disk dinode. */ struct ext2fs_dinode e2fs_din; /* 128 bytes of the on-disk dinode. */ } i_din; + + struct inode_vtbl *i_vtbl; }; +#define UFS_TRUNCATE(ip, off, flags, cred) \ + ((ip)->i_vtbl->iv_truncate)((ip), (off), (flags), (cred)) + +#define UFS_UPDATE(ip, sync) \ + ((ip)->i_vtbl->iv_update)((ip), NULL, NULL, (sync)) + +#define UFS_UPDATE2(ip, atime, mtime, sync) \ + ((ip)->i_vtbl->iv_update)((ip), (atime), (mtime), (sync)) + +#define UFS_INODE_ALLOC(pip, mode, cred, vpp) \ + ((pip)->i_vtbl->iv_inode_alloc)((pip), (mode), (cred), (vpp)) + +#define UFS_INODE_FREE(pip, ino, mode) \ + ((pip)->i_vtbl->iv_inode_free)((pip), (ino), (mode)) + +#define UFS_BUF_ALLOC(ip, startoffset, size, cred, flags, bpp) \ + ((ip)->i_vtbl->iv_buf_alloc)((ip), (startoffset), (size), (cred), \ + (flags), (bpp)) + +#define UFS_BUFATOFF(ip, offset, res, bpp) \ + ((ip)->i_vtbl->iv_bufatoff)((ip), (offset), (res), (bpp)) + + #define i_ffs_atime i_din.ffs_din.di_atime #define i_ffs_atimensec i_din.ffs_din.di_atimensec #define i_ffs_blocks i_din.ffs_din.di_blocks diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 6210ce2b489..f485475538f 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.7 1997/11/06 05:59:26 csapuntz Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.8 2001/06/23 02:07:57 csapuntz Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -87,7 +87,6 @@ ufs_inactive(v) struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct proc *p = ap->a_p; - struct timespec ts; int mode, error = 0; extern int prtactive; @@ -104,16 +103,15 @@ ufs_inactive(v) if (!getinoquota(ip)) (void)chkiq(ip, -1, NOCRED, 0); #endif - error = VOP_TRUNCATE(vp, (off_t)0, 0, NOCRED, p); + error = UFS_TRUNCATE(ip, (off_t)0, 0, NOCRED); ip->i_ffs_rdev = 0; mode = ip->i_ffs_mode; ip->i_ffs_mode = 0; ip->i_flag |= IN_CHANGE | IN_UPDATE; - VOP_VFREE(vp, ip->i_number, mode); + UFS_INODE_FREE(ip, ip->i_number, mode); } if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - VOP_UPDATE(vp, &ts, &ts, 0); + UFS_UPDATE(ip, 0); } out: VOP_UNLOCK(vp, 0, p); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index a5dd0595ad9..a9b0805d37a 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_lookup.c,v 1.15 2001/02/27 09:52:56 art Exp $ */ +/* $OpenBSD: ufs_lookup.c,v 1.16 2001/06/23 02:07:57 csapuntz Exp $ */ /* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */ /* @@ -245,7 +245,7 @@ ufs_lookup(v) } else { dp->i_offset = dp->i_diroff; if ((entryoffsetinblock = dp->i_offset & bmask) && - (error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp))) + (error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, NULL, &bp))) return (error); numdirpasses = 2; nchstats.ncs_2passes++; @@ -262,7 +262,7 @@ searchloop: if ((dp->i_offset & bmask) == 0) { if (bp != NULL) brelse(bp); - error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, + error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, NULL, &bp); if (error) return (error); @@ -737,7 +737,6 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) struct direct *ep, *nep; int error, ret, blkoff, loc, spacefree, flags; char *dirbuf; - struct timespec ts; error = 0; cr = cnp->cn_cred; @@ -757,7 +756,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) flags = B_CLRBUF; if (!DOINGSOFTDEP(dvp)) flags |= B_SYNC; - if ((error = VOP_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ, + if ((error = UFS_BUF_ALLOC(dp, (off_t)dp->i_offset, DIRBLKSIZ, cr, flags, &bp)) != 0) { if (DOINGSOFTDEP(dvp) && newdirbp != NULL) bdwrite(newdirbp); @@ -793,8 +792,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) } else { error = VOP_BWRITE(bp); } - TIMEVAL_TO_TIMESPEC(&time, &ts); - ret = VOP_UPDATE(dvp, &ts, &ts, !DOINGSOFTDEP(dvp)); + ret = UFS_UPDATE(dp, !DOINGSOFTDEP(dvp)); if (error == 0) return (ret); return (error); @@ -821,7 +819,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) /* * Get the block containing the space for the new directory entry. */ - if ((error = VOP_BLKATOFF(dvp, (off_t)dp->i_offset, &dirbuf, &bp)) + if ((error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, &dirbuf, &bp)) != 0) { if (DOINGSOFTDEP(dvp) && newdirbp != NULL) bdwrite(newdirbp); @@ -895,7 +893,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) if (tvp != NULL) VOP_UNLOCK(tvp, 0, p); - error = VOP_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC, cr, p); + error = UFS_TRUNCATE(dp, (off_t)dp->i_endoff, IO_SYNC, cr); if (tvp != NULL) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p); @@ -933,7 +931,7 @@ ufs_dirremove(dvp, ip, flags, isrmdir) /* * Whiteout entry: set d_ino to WINO. */ - error = VOP_BLKATOFF(dvp, (off_t)dp->i_offset, (char **)&ep, + error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, (char **)&ep, &bp); if (error) return (error); @@ -942,7 +940,7 @@ ufs_dirremove(dvp, ip, flags, isrmdir) goto out; } - if ((error = VOP_BLKATOFF(dvp, + if ((error = UFS_BUFATOFF(dp, (off_t)(dp->i_offset - dp->i_count), (char **)&ep, &bp)) != 0) return (error); @@ -1005,7 +1003,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype, isrmdir) struct vnode *vdp = ITOV(dp); int error; - error = VOP_BLKATOFF(vdp, (off_t)dp->i_offset, (char **)&ep, &bp); + error = UFS_BUFATOFF(dp, (off_t)dp->i_offset, (char **)&ep, &bp); if (error) return (error); ep->d_ino = newinum; diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 04bd52787bf..3b90471dca6 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_readwrite.c,v 1.17 2001/02/23 14:42:39 csapuntz Exp $ */ +/* $OpenBSD: ufs_readwrite.c,v 1.18 2001/06/23 02:07:57 csapuntz Exp $ */ /* $NetBSD: ufs_readwrite.c,v 1.9 1996/05/11 18:27:57 mycroft Exp $ */ /*- @@ -192,7 +192,6 @@ WRITE(v) daddr_t lbn; off_t osize; int blkoffset, error, extended, flags, ioflag, resid, size, xfersize; - struct timespec ts; extended = 0; ioflag = ap->a_ioflag; @@ -253,8 +252,8 @@ WRITE(v) else flags &= ~B_CLRBUF; - if ((error = VOP_BALLOC(vp, uio->uio_offset, xfersize, - ap->a_cred, flags, &bp)) != 0) + if ((error = UFS_BUF_ALLOC(ip, uio->uio_offset, xfersize, + ap->a_cred, flags, &bp)) != 0) break; if (uio->uio_offset + xfersize > ip->i_ffs_size) { ip->i_ffs_size = uio->uio_offset + xfersize; @@ -309,14 +308,13 @@ WRITE(v) VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); if (error) { if (ioflag & IO_UNIT) { - (void)VOP_TRUNCATE(vp, osize, - ioflag & IO_SYNC, ap->a_cred, uio->uio_procp); + (void)UFS_TRUNCATE(ip, osize, + ioflag & IO_SYNC, ap->a_cred); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } } else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) { - TIMEVAL_TO_TIMESPEC(&time, &ts); - error = VOP_UPDATE(vp, &ts, &ts, 1); + error = UFS_UPDATE(ip, MNT_WAIT); } return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 39384e09efe..80b4b8e380b 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.32 2001/06/04 15:11:47 provos Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.33 2001/06/23 02:07:57 csapuntz Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -421,10 +421,9 @@ ufs_setattr(v) default: break; } - if ((error = VOP_TRUNCATE(vp, vap->va_size, 0, cred, p)) != 0) + if ((error = UFS_TRUNCATE(ip, vap->va_size, 0, cred)) != 0) return (error); } - ip = VTOI(vp); if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); @@ -437,7 +436,7 @@ ufs_setattr(v) ip->i_flag |= IN_ACCESS; if (vap->va_mtime.tv_sec != VNOVAL) ip->i_flag |= IN_CHANGE | IN_UPDATE; - error = VOP_UPDATE(vp, &vap->va_atime, &vap->va_mtime, 0); + error = UFS_UPDATE2(ip, &vap->va_atime, &vap->va_mtime, 0); if (error) return (error); } @@ -726,7 +725,6 @@ ufs_link(v) struct proc *p = cnp->cn_proc; struct inode *ip; struct direct newdir; - struct timespec ts; int error; #ifdef DIAGNOSTIC @@ -763,8 +761,7 @@ ufs_link(v) ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(vp)) softdep_change_linkcnt(ip); - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(vp, &ts, &ts, !DOINGSOFTDEP(vp))) == 0) { + if ((error = UFS_UPDATE(ip, !DOINGSOFTDEP(vp))) == 0) { ufs_makedirentry(ip, cnp, &newdir); error = ufs_direnter(dvp, vp, &newdir, cnp, NULL); } @@ -893,7 +890,6 @@ ufs_rename(v) struct proc *p = fcnp->cn_proc; struct inode *ip, *xp, *dp; struct direct newdir; - struct timespec ts; int doingdirectory = 0, oldparent = 0, newparent = 0; int error = 0; @@ -1037,8 +1033,7 @@ abortit: ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(fvp)) softdep_change_linkcnt(ip); - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(fvp, &ts, &ts, !DOINGSOFTDEP(fvp))) != 0) { + if ((error = UFS_UPDATE(ip, !DOINGSOFTDEP(fvp))) != 0) { VOP_UNLOCK(fvp, 0, p); goto bad; } @@ -1102,8 +1097,8 @@ abortit: dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp); - if ((error = VOP_UPDATE(tdvp, &ts, &ts, - !DOINGSOFTDEP(tdvp))) != 0) { + if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(tdvp))) + != 0) { dp->i_effnlink--; dp->i_ffs_nlink--; dp->i_flag |= IN_CHANGE; @@ -1120,7 +1115,7 @@ abortit: dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp); - (void)VOP_UPDATE(tdvp, &ts, &ts, 1); + (void)UFS_UPDATE(dp, 1); } goto bad; } @@ -1200,8 +1195,8 @@ abortit: xp->i_ffs_nlink--; xp->i_flag |= IN_CHANGE; - if ((error = VOP_TRUNCATE(tvp, (off_t)0, IO_SYNC, - tcnp->cn_cred, tcnp->cn_proc)) != 0) + if ((error = UFS_TRUNCATE(VTOI(tvp), (off_t)0, IO_SYNC, + tcnp->cn_cred)) != 0) goto bad; } VN_KNOTE(tdvp, NOTE_WRITE); @@ -1307,7 +1302,6 @@ ufs_mkdir(v) struct buf *bp; struct direct newdir; struct dirtemplate dirtemplate, *dtp; - struct timespec ts; int error, dmode, blkoff; #ifdef DIAGNOSTIC @@ -1326,7 +1320,7 @@ ufs_mkdir(v) * but not have it entered in the parent directory. The entry is * made later after writing "." and ".." entries. */ - if ((error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp)) != 0) + if ((error = UFS_INODE_ALLOC(dp, dmode, cnp->cn_cred, &tvp)) != 0) goto out; ip = VTOI(tvp); ip->i_ffs_uid = cnp->cn_cred->cr_uid; @@ -1335,7 +1329,7 @@ ufs_mkdir(v) if ((error = getinoquota(ip)) || (error = chkiq(ip, 1, cnp->cn_cred, 0))) { free(cnp->cn_pnbuf, M_NAMEI); - VOP_VFREE(tvp, ip->i_number, dmode); + UFS_INODE_FREE(ip, ip->i_number, dmode); vput(tvp); vput(dvp); return (error); @@ -1362,8 +1356,7 @@ ufs_mkdir(v) dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(dvp)) softdep_change_linkcnt(dp); - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(dvp, &ts, &ts, !DOINGSOFTDEP(dvp))) != 0) + if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(dvp))) != 0) goto bad; /* @@ -1377,7 +1370,7 @@ ufs_mkdir(v) dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; - if ((error = VOP_BALLOC(tvp, (off_t)0, DIRBLKSIZ, cnp->cn_cred, + if ((error = UFS_BUF_ALLOC(ip, (off_t)0, DIRBLKSIZ, cnp->cn_cred, B_CLRBUF, &bp)) != 0) goto bad; ip->i_ffs_size = DIRBLKSIZ; @@ -1402,7 +1395,7 @@ ufs_mkdir(v) blkoff += DIRBLKSIZ; } } - if ((error = VOP_UPDATE(tvp, &ts, &ts, !DOINGSOFTDEP(tvp))) != 0) { + if ((error = UFS_UPDATE(ip, !DOINGSOFTDEP(tvp))) != 0) { (void)VOP_BWRITE(bp); goto bad; } @@ -1541,8 +1534,7 @@ ufs_rmdir(v) ip->i_ffs_nlink--; ip->i_flag |= IN_CHANGE; ioflag = DOINGASYNC(vp) ? 0 : IO_SYNC; - error = VOP_TRUNCATE(vp, (off_t)0, ioflag, cnp->cn_cred, - cnp->cn_proc); + error = UFS_TRUNCATE(ip, (off_t)0, ioflag, cnp->cn_cred); } cache_purge(vp); out: @@ -2129,7 +2121,6 @@ ufs_makeinode(mode, dvp, vpp, cnp) { struct inode *ip, *pdir; struct direct newdir; - struct timespec ts; struct vnode *tvp; int error; @@ -2142,7 +2133,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) if ((mode & IFMT) == 0) mode |= IFREG; - if ((error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) != 0) { + if ((error = UFS_INODE_ALLOC(pdir, mode, cnp->cn_cred, &tvp)) != 0) { free(cnp->cn_pnbuf, M_NAMEI); vput(dvp); return (error); @@ -2154,7 +2145,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) if ((error = getinoquota(ip)) || (error = chkiq(ip, 1, cnp->cn_cred, 0))) { free(cnp->cn_pnbuf, M_NAMEI); - VOP_VFREE(tvp, ip->i_number, mode); + UFS_INODE_FREE(ip, ip->i_number, mode); vput(tvp); vput(dvp); return (error); @@ -2178,8 +2169,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) /* * Make sure inode goes to disk before directory entry. */ - TIMEVAL_TO_TIMESPEC(&time, &ts); - if ((error = VOP_UPDATE(tvp, &ts, &ts, !DOINGSOFTDEP(tvp))) != 0) + if ((error = UFS_UPDATE(ip, !DOINGSOFTDEP(tvp))) != 0) goto bad; ufs_makedirentry(ip, cnp, &newdir); |