diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-12-10 04:45:33 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-12-10 04:45:33 +0000 |
commit | 1eef7286fcf85dd357190316b332838378170946 (patch) | |
tree | 5d07152a5670a8b50e09c86d0ca76970e76c6fc0 /sys/ufs | |
parent | c7c6e636a8bfbf2c68e2ed3e6d20fa1c5237bfb0 (diff) |
Big cleanup inspired by NetBSD with some parts of the code from NetBSD.
- get rid of VOP_BALLOCN and VOP_SIZE
- move the generic getpages and putpages into miscfs/genfs
- create a genfs_node which must be added to the top of the private portion
of each vnode for filsystems that want to use genfs_{get,put}pages
- rename genfs_mmap to vop_generic_mmap
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_balloc.c | 31 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_extern.h | 4 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vnops.c | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 24 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_extern.h | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 14 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 9 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 28 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_extern.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 19 |
12 files changed, 64 insertions, 91 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_balloc.c b/sys/ufs/ext2fs/ext2fs_balloc.c index a6daf74d8c6..390f02dc13f 100644 --- a/sys/ufs/ext2fs/ext2fs_balloc.c +++ b/sys/ufs/ext2fs/ext2fs_balloc.c @@ -314,29 +314,17 @@ fail: } int -ext2fs_ballocn(v) - void *v; +ext2fs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags, + struct ucred *cred) { - struct vop_ballocn_args /* { - struct vnode *a_vp; - off_t a_offset; - off_t a_length; - struct ucred *a_cred; - int a_flags; - } */ *ap = v; - off_t off, len; - struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct m_ext2fs *fs = ip->i_e2fs; int error, delta, bshift, bsize; - UVMHIST_FUNC("ext2fs_ballocn"); UVMHIST_CALLED(ubchist); + UVMHIST_FUNC("ext2fs_gop_alloc"); UVMHIST_CALLED(ubchist); bshift = fs->e2fs_bshift; bsize = 1 << bshift; - off = ap->a_offset; - len = ap->a_length; - delta = off & (bsize - 1); off -= delta; len += delta; @@ -346,8 +334,8 @@ ext2fs_ballocn(v) UVMHIST_LOG(ubchist, "off 0x%x len 0x%x bsize 0x%x", off, len, bsize, 0); - error = ext2fs_buf_alloc(ip, lblkno(fs, off), bsize, ap->a_cred, - NULL, ap->a_flags); + error = ext2fs_buf_alloc(ip, lblkno(fs, off), bsize, cred, + NULL, flags); if (error) { UVMHIST_LOG(ubchist, "error %d", error, 0,0,0); return error; @@ -389,6 +377,7 @@ ext2fs_balloc_range(vp, off, len, cred, flags) { off_t oldeof, eof, pagestart; struct uvm_object *uobj; + struct genfs_node *gp = VTOG(vp); int i, delta, error, npages; int bshift = vp->v_mount->mnt_fs_bshift; int bsize = 1 << bshift; @@ -441,10 +430,10 @@ ext2fs_balloc_range(vp, off, len, cred, flags) * now allocate the range. */ - lockmgr(&vp->v_glock, LK_EXCLUSIVE, NULL, curproc); - error = VOP_BALLOCN(vp, off, len, cred, flags); - UVMHIST_LOG(ubchist, "ballocn %d", error,0,0,0); - lockmgr(&vp->v_glock, LK_RELEASE, NULL, curproc); + lockmgr(&gp->g_glock, LK_EXCLUSIVE, NULL, curproc); + error = GOP_ALLOC(vp, off, len, flags, cred); + UVMHIST_LOG(ubchist, "alloc %d", error,0,0,0); + lockmgr(&gp->g_glock, LK_RELEASE, NULL, curproc); /* * unbusy any pages we are holding. diff --git a/sys/ufs/ext2fs/ext2fs_extern.h b/sys/ufs/ext2fs/ext2fs_extern.h index af23fb6ef2d..5f5b2c3a47b 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.11 2001/11/27 05:27:12 art Exp $ */ +/* $OpenBSD: ext2fs_extern.h,v 1.12 2001/12/10 04:45:31 art Exp $ */ /* $NetBSD: ext2fs_extern.h,v 1.9 2000/11/27 08:39:53 chs Exp $ */ /*- @@ -74,7 +74,7 @@ int ext2fs_inode_free(struct inode *pip, ino_t ino, int mode); /* ext2fs_balloc.c */ int ext2fs_buf_alloc(struct inode *, daddr_t, int, struct ucred *, struct buf **, int); -int ext2fs_ballocn __P((void *)); +int ext2fs_gop_alloc __P((struct vnode *, off_t, off_t, int, struct ucred *)); int ext2fs_balloc_range __P((struct vnode *, off_t, off_t, struct ucred *, int)); diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 87eab5f5c2b..b77f4edec62 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.18 2001/12/10 02:19:34 art Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.19 2001/12/10 04:45:31 art Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.40 2000/11/27 08:39:53 chs Exp $ */ /* @@ -100,6 +100,11 @@ struct vfsops ext2fs_vfsops = { ufs_check_export }; +struct genfs_ops ext2fs_genfsops = { + genfs_size, + ext2fs_gop_alloc, +}; + struct pool ext2fs_inode_pool; extern u_long ext2gennumber; @@ -916,6 +921,7 @@ ext2fs_vget(mp, ino, vpp) /* * Finish inode initialization now that aliasing has been resolved. */ + genfs_node_init(vp, &ext2fs_genfsops); ip->i_devvp = ump->um_devvp; VREF(ip->i_devvp); /* diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index defbaedf0cb..6e82f66279a 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.19 2001/12/04 22:44:32 art Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.20 2001/12/10 04:45:31 art Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.30 2000/11/27 08:39:53 chs Exp $ */ /* @@ -1467,10 +1467,8 @@ struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = { { &vop_pathconf_desc, ufs_pathconf }, /* pathconf */ { &vop_advlock_desc, ext2fs_advlock }, /* advlock */ { &vop_bwrite_desc, vop_generic_bwrite }, /* bwrite */ - { &vop_ballocn_desc, ext2fs_ballocn }, { &vop_getpages_desc, genfs_getpages }, { &vop_putpages_desc, genfs_putpages }, - { &vop_size_desc, genfs_size }, { &vop_mmap_desc, ufs_mmap }, { NULL, NULL } }; diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index dfbf97c232c..aa452edeabb 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.20 2001/12/10 02:19:34 art Exp $ */ +/* $OpenBSD: ffs_balloc.c,v 1.21 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */ /* @@ -404,19 +404,9 @@ fail: } int -ffs_ballocn(v) - void *v; +ffs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags, + struct ucred *cred) { - struct vop_ballocn_args /* { - struct vnode *a_vp; - off_t a_offset; - off_t a_length; - struct ucred *a_cred; - int a_flags; - } */ *ap = v; - - off_t off, len; - struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct fs *fs = ip->i_fs; int error, delta, bshift, bsize; @@ -425,18 +415,14 @@ ffs_ballocn(v) bshift = fs->fs_bshift; bsize = 1 << bshift; - off = ap->a_offset; - len = ap->a_length; - delta = off & (bsize - 1); off -= delta; len += delta; while (len > 0) { - bsize = min(bsize, len); + bsize = MIN(bsize, len); - error = ffs_balloc(ip, off, bsize, ap->a_cred, ap->a_flags, - NULL); + error = ffs_balloc(ip, off, bsize, cred, flags, NULL); if (error) { goto out; } diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index 2875a332a57..7aac0f33de9 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.15 2001/11/27 05:27:12 art Exp $ */ +/* $OpenBSD: ffs_extern.h,v 1.16 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /*- @@ -87,7 +87,7 @@ void ffs_clusteracct __P((struct fs *, struct cg *, daddr_t, int)); /* ffs_balloc.c */ int ffs_balloc(struct inode *, off_t, int, struct ucred *, int, struct buf **); -int ffs_ballocn(void *); +int ffs_gop_alloc(struct vnode *, off_t, off_t, int, struct ucred *); /* ffs_inode.c */ int ffs_init __P((struct vfsconf *)); @@ -129,7 +129,7 @@ int ffs_read __P((void *)); int ffs_write __P((void *)); int ffs_fsync __P((void *)); int ffs_reclaim __P((void *)); -int ffs_size __P((void *)); +void ffs_gop_size __P((struct vnode *, off_t, off_t *)); /* * Soft dependency function prototypes. diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 64f0aef27a3..3bec117a700 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.27 2001/12/10 02:19:34 art Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.28 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -148,7 +148,8 @@ ffs_update(struct inode *ip, struct timespec *atime, int ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) { - struct vnode *ovp; + struct vnode *ovp = ITOV(oip); + struct genfs_node *gp = VTOG(ovp); daddr_t lastblock; daddr_t bn, lastiblock[NIADDR], indir_lbn[NIADDR]; daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR]; @@ -162,7 +163,6 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) if (length < 0) return (EINVAL); - ovp = ITOV(oip); if (ovp->v_type != VREG && ovp->v_type != VDIR && @@ -235,7 +235,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) simple_unlock(&uobj->vmobjlock); } - lockmgr(&ovp->v_glock, LK_EXCLUSIVE, NULL, p); + lockmgr(&gp->g_glock, LK_EXCLUSIVE, NULL, p); if (DOINGSOFTDEP(ovp)) { if (length > 0 || softdep_slowdown(ovp)) { @@ -250,7 +250,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) */ if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT, curproc)) != 0) { - lockmgr(&ovp->v_glock, LK_RELEASE, NULL, p); + lockmgr(&gp->g_glock, LK_RELEASE, NULL, p); return (error); } } else { @@ -259,7 +259,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) NOCRED); softdep_setup_freeblocks(oip, length); (void) vinvalbuf(ovp, 0, cred, curproc, 0, 0); - lockmgr(&ovp->v_glock, LK_RELEASE, NULL, p); + lockmgr(&gp->g_glock, LK_RELEASE, NULL, p); oip->i_flag |= IN_CHANGE | IN_UPDATE; return (UFS_UPDATE(oip, 0)); } @@ -396,7 +396,7 @@ done: oip->i_ffs_blocks -= blocksreleased; if (oip->i_ffs_blocks < 0) /* sanity */ oip->i_ffs_blocks = 0; - lockmgr(&ovp->v_glock, LK_RELEASE, NULL, p); + lockmgr(&gp->g_glock, LK_RELEASE, NULL, p); oip->i_flag |= IN_CHANGE; (void)ufs_quota_free_blocks(oip, blocksreleased, NOCRED); return (allerror); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 19c77726fa8..4aac12f8752 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.46 2001/11/27 05:27:12 art Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.47 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -96,6 +96,11 @@ struct inode_vtbl ffs_vtbl = { ffs_bufatoff }; +struct genfs_ops ffs_genfsops = { + ffs_gop_size, + ffs_gop_alloc, +}; + extern u_long nextgennumber; /* @@ -1182,6 +1187,8 @@ retry: /* * Finish inode initialization now that aliasing has been resolved. */ + + genfs_node_init(vp, &ffs_genfsops); ip->i_devvp = ump->um_devvp; VREF(ip->i_devvp); /* diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 6bf1ddc5642..3794d5e8049 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.23 2001/12/10 02:19:34 art Exp $ */ +/* $OpenBSD: ffs_vnops.c,v 1.24 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ffs_vnops.c,v 1.7 1996/05/11 18:27:24 mycroft Exp $ */ /* @@ -107,10 +107,8 @@ struct vnodeopv_entry_desc ffs_vnodeop_entries[] = { { &vop_advlock_desc, ufs_advlock }, /* advlock */ { &vop_reallocblks_desc, ffs_reallocblks }, /* reallocblks */ { &vop_bwrite_desc, vop_generic_bwrite }, - { &vop_ballocn_desc, ffs_ballocn }, { &vop_getpages_desc, genfs_getpages }, { &vop_putpages_desc, genfs_putpages }, - { &vop_size_desc, ffs_size }, { &vop_mmap_desc, ufs_mmap }, { NULL, NULL } }; @@ -158,7 +156,7 @@ struct vnodeopv_entry_desc ffs_specop_entries[] = { { &vop_advlock_desc, spec_advlock }, /* advlock */ { &vop_reallocblks_desc, spec_reallocblks }, /* reallocblks */ { &vop_bwrite_desc, vop_generic_bwrite }, - { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } + { NULL, NULL } }; struct vnodeopv_desc ffs_specop_opv_desc = { &ffs_specop_p, ffs_specop_entries }; @@ -204,7 +202,7 @@ struct vnodeopv_entry_desc ffs_fifoop_entries[] = { { &vop_advlock_desc, fifo_advlock }, /* advlock */ { &vop_reallocblks_desc, fifo_reallocblks }, /* reallocblks */ { &vop_bwrite_desc, vop_generic_bwrite }, - { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL } + { NULL, NULL } }; struct vnodeopv_desc ffs_fifoop_opv_desc = { &ffs_fifoop_p, ffs_fifoop_entries }; @@ -376,26 +374,18 @@ ffs_reclaim(v) * Return the last logical file offset that should be written for this file * if we're doing a write that ends at "size". */ -int -ffs_size(v) - void *v; +void +ffs_gop_size(struct vnode *vp, off_t size, off_t *eobp) { - struct vop_size_args /* { - struct vnode *a_vp; - off_t a_size; - off_t *a_eobp; - } */ *ap = v; - struct inode *ip = VTOI(ap->a_vp); + struct inode *ip = VTOI(vp); struct fs *fs = ip->i_fs; ufs_lbn_t olbn, nlbn; olbn = lblkno(fs, ip->i_ffs_size); - nlbn = lblkno(fs, ap->a_size); - + nlbn = lblkno(fs, size); if (nlbn < NDADDR && olbn <= nlbn) { - *ap->a_eobp = fragroundup(fs, ap->a_size); + *eobp = fragroundup(fs, size); } else { - *ap->a_eobp = blkroundup(fs, ap->a_size); + *eobp = blkroundup(fs, size); } - return 0; } diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 98c73de5579..eb3f0069790 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.17 2001/11/27 05:27:12 art Exp $ */ +/* $OpenBSD: inode.h,v 1.18 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -45,6 +45,7 @@ #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> #include <ufs/ext2fs/ext2fs_dinode.h> +#include <miscfs/genfs/genfs.h> typedef long ufs_lbn_t; @@ -66,6 +67,7 @@ struct ext2fs_inode_ext { * active, and is put back when the file is no longer being used. */ struct inode { + struct genfs_node i_gnode; 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. */ diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index a89656344c0..85df8cf99ec 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_extern.h,v 1.14 2001/12/04 22:44:32 art Exp $ */ +/* $OpenBSD: ufs_extern.h,v 1.15 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ufs_extern.h,v 1.5 1996/02/09 22:36:03 christos Exp $ */ /*- @@ -98,7 +98,7 @@ int ufs_whiteout __P((void *)); int ufsspec_close __P((void *)); int ufsspec_read __P((void *)); int ufsspec_write __P((void *)); -#define ufs_mmap genfs_mmap +#define ufs_mmap vop_generic_mmap #ifdef FIFO int ufsfifo_read __P((void *)); diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 8c328b83f39..61ec4eeede9 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.14 2001/12/10 02:19:34 art Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.15 2001/12/10 04:45:32 art Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -170,6 +170,7 @@ ufs_balloc_range(vp, off, len, cred, flags) { off_t oldeof, neweof, oldeob, neweob, oldpagestart, pagestart; struct uvm_object *uobj; + struct genfs_node *gp = VTOG(vp); int i, delta, error, npages1, npages2; int bshift = vp->v_mount->mnt_fs_bshift; int bsize = 1 << bshift; @@ -180,16 +181,10 @@ ufs_balloc_range(vp, off, len, cred, flags) vp, off, len, vp->v_size); oldeof = vp->v_size; - error = VOP_SIZE(vp, oldeof, &oldeob); - if (error) { - return error; - } + GOP_SIZE(vp, oldeof, &oldeob); neweof = MAX(vp->v_size, off + len); - error = VOP_SIZE(vp, neweof, &neweob); - if (error) { - return error; - } + GOP_SIZE(vp, neweof, &neweob); error = 0; uobj = &vp->v_uobj; @@ -267,9 +262,9 @@ ufs_balloc_range(vp, off, len, cred, flags) * now allocate the range. */ - lockmgr(&vp->v_glock, LK_EXCLUSIVE, NULL, curproc); - error = VOP_BALLOCN(vp, off, len, cred, flags); - lockmgr(&vp->v_glock, LK_RELEASE, NULL, curproc); + lockmgr(&gp->g_glock, LK_EXCLUSIVE, NULL, curproc); + error = GOP_ALLOC(vp, off, len, flags, cred); + lockmgr(&gp->g_glock, LK_RELEASE, NULL, curproc); /* * clear PG_RDONLY on any pages we are holding |