diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-10-04 08:11:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-10-04 08:11:03 +0000 |
commit | bffcbc4a301ed3d8680cb02d51b34a354edd5db7 (patch) | |
tree | 7fc7a621395b957699d41b7eb5947e4410f67c14 | |
parent | 7e174fc2f0c87344167c4296f0a42c2b2cd0b478 (diff) |
Use the fact the vnodes are locked when operations are inflight.
Remove the v_inflight member and alter the ffs and ext2fs sync code to
track inflight by checking if the node is locked or not (which it already
did before but for a different reason).
OK mpi@
-rw-r--r-- | sys/kern/vfs_vops.c | 118 | ||||
-rw-r--r-- | sys/sys/vnode.h | 3 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vfsops.c | 8 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 7 |
4 files changed, 25 insertions, 111 deletions
diff --git a/sys/kern/vfs_vops.c b/sys/kern/vfs_vops.c index 877daef51b2..caf2dc327bf 100644 --- a/sys/kern/vfs_vops.c +++ b/sys/kern/vfs_vops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vops.c,v 1.30 2021/04/28 09:53:53 claudio Exp $ */ +/* $OpenBSD: vfs_vops.c,v 1.31 2021/10/04 08:11:02 claudio Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson <thib@openbsd.org> * @@ -74,7 +74,6 @@ int VOP_LOOKUP(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) { - int r; struct vop_lookup_args a; a.a_dvp = dvp; a.a_vpp = vpp; @@ -83,17 +82,13 @@ VOP_LOOKUP(struct vnode *dvp, struct vnode **vpp, if (dvp->v_op->vop_lookup == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_lookup)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_lookup)(&a)); } int VOP_CREATE(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct vattr *vap) { - int r; struct vop_create_args a; a.a_dvp = dvp; a.a_vpp = vpp; @@ -105,17 +100,13 @@ VOP_CREATE(struct vnode *dvp, struct vnode **vpp, if (dvp->v_op->vop_create == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_create)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_create)(&a)); } int VOP_MKNOD(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct vattr *vap) { - int r; struct vop_mknod_args a; a.a_dvp = dvp; a.a_vpp = vpp; @@ -127,16 +118,12 @@ VOP_MKNOD(struct vnode *dvp, struct vnode **vpp, if (dvp->v_op->vop_mknod == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_mknod)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_mknod)(&a)); } int VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct proc *p) { - int r; struct vop_open_args a; a.a_vp = vp; a.a_mode = mode; @@ -148,16 +135,12 @@ VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct proc *p) if (vp->v_op->vop_open == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_open)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_open)(&a)); } int VOP_CLOSE(struct vnode *vp, int fflag, struct ucred *cred, struct proc *p) { - int r; struct vop_close_args a; a.a_vp = vp; a.a_fflag = fflag; @@ -170,10 +153,7 @@ VOP_CLOSE(struct vnode *vp, int fflag, struct ucred *cred, struct proc *p) if (vp->v_op->vop_close == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_close)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_close)(&a)); } int @@ -215,7 +195,6 @@ int VOP_SETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred, struct proc *p) { - int r; struct vop_setattr_args a; a.a_vp = vp; a.a_vap = vap; @@ -228,10 +207,7 @@ VOP_SETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred, if (vp->v_op->vop_setattr == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_setattr)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_setattr)(&a)); } int @@ -255,7 +231,6 @@ int VOP_WRITE(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) { - int r; struct vop_write_args a; a.a_vp = vp; a.a_uio = uio; @@ -267,17 +242,13 @@ VOP_WRITE(struct vnode *vp, struct uio *uio, int ioflag, if (vp->v_op->vop_write == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_write)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_write)(&a)); } int VOP_IOCTL(struct vnode *vp, u_long command, void *data, int fflag, struct ucred *cred, struct proc *p) { - int r; struct vop_ioctl_args a; a.a_vp = vp; a.a_command = command; @@ -290,10 +261,7 @@ VOP_IOCTL(struct vnode *vp, u_long command, void *data, int fflag, if (vp->v_op->vop_ioctl == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_ioctl)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_ioctl)(&a)); } int @@ -356,9 +324,7 @@ VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, if (vp->v_op->vop_fsync == NULL) return (EOPNOTSUPP); - vp->v_inflight++; r = (vp->v_op->vop_fsync)(&a); - vp->v_inflight--; s = splbio(); if (r == 0 && vp->v_bioflag & VBIOERROR) r = EIO; @@ -369,7 +335,6 @@ VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, int VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { - int r; struct vop_remove_args a; a.a_dvp = dvp; a.a_vp = vp; @@ -381,16 +346,12 @@ VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (dvp->v_op->vop_remove == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_remove)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_remove)(&a)); } int VOP_LINK(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { - int r; struct vop_link_args a; a.a_dvp = dvp; a.a_vp = vp; @@ -401,12 +362,7 @@ VOP_LINK(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (dvp->v_op->vop_link == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - vp->v_inflight++; - r = (dvp->v_op->vop_link)(&a); - dvp->v_inflight--; - vp->v_inflight--; - return r; + return ((dvp->v_op->vop_link)(&a)); } int @@ -414,7 +370,6 @@ VOP_RENAME(struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp, struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp) { - int r; struct vop_rename_args a; a.a_fdvp = fdvp; a.a_fvp = fvp; @@ -428,19 +383,13 @@ VOP_RENAME(struct vnode *fdvp, struct vnode *fvp, if (fdvp->v_op->vop_rename == NULL) return (EOPNOTSUPP); - fdvp->v_inflight++; - tdvp->v_inflight++; - r = (fdvp->v_op->vop_rename)(&a); - fdvp->v_inflight--; - tdvp->v_inflight--; - return r; + return ((fdvp->v_op->vop_rename)(&a)); } int VOP_MKDIR(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct vattr *vap) { - int r; struct vop_mkdir_args a; a.a_dvp = dvp; a.a_vpp = vpp; @@ -452,16 +401,12 @@ VOP_MKDIR(struct vnode *dvp, struct vnode **vpp, if (dvp->v_op->vop_mkdir == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_mkdir)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_mkdir)(&a)); } int VOP_RMDIR(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { - int r; struct vop_rmdir_args a; a.a_dvp = dvp; a.a_vp = vp; @@ -475,19 +420,13 @@ VOP_RMDIR(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (dvp->v_op->vop_rmdir == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - vp->v_inflight++; - r = (dvp->v_op->vop_rmdir)(&a); - dvp->v_inflight--; - vp->v_inflight--; - return r; + return ((dvp->v_op->vop_rmdir)(&a)); } int VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct vattr *vap, char *target) { - int r; struct vop_symlink_args a; a.a_dvp = dvp; a.a_vpp = vpp; @@ -500,17 +439,13 @@ VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp, if (dvp->v_op->vop_symlink == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_symlink)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_symlink)(&a)); } int VOP_READDIR(struct vnode *vp, struct uio *uio, struct ucred *cred, int *eofflag) { - int r; struct vop_readdir_args a; a.a_vp = vp; a.a_uio = uio; @@ -522,16 +457,12 @@ VOP_READDIR(struct vnode *vp, struct uio *uio, struct ucred *cred, if (vp->v_op->vop_readdir == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_readdir)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_readdir)(&a)); } int VOP_READLINK(struct vnode *vp, struct uio *uio, struct ucred *cred) { - int r; struct vop_readlink_args a; a.a_vp = vp; a.a_uio = uio; @@ -542,16 +473,12 @@ VOP_READLINK(struct vnode *vp, struct uio *uio, struct ucred *cred) if (vp->v_op->vop_readlink == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_readlink)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_readlink)(&a)); } int VOP_ABORTOP(struct vnode *dvp, struct componentname *cnp) { - int r; struct vop_abortop_args a; a.a_dvp = dvp; a.a_cnp = cnp; @@ -559,10 +486,7 @@ VOP_ABORTOP(struct vnode *dvp, struct componentname *cnp) if (dvp->v_op->vop_abortop == NULL) return (EOPNOTSUPP); - dvp->v_inflight++; - r = (dvp->v_op->vop_abortop)(&a); - dvp->v_inflight--; - return r; + return ((dvp->v_op->vop_abortop)(&a)); } int @@ -584,7 +508,6 @@ VOP_INACTIVE(struct vnode *vp, struct proc *p) int VOP_RECLAIM(struct vnode *vp, struct proc *p) { - int r; struct vop_reclaim_args a; a.a_vp = vp; a.a_p = p; @@ -593,10 +516,7 @@ VOP_RECLAIM(struct vnode *vp, struct proc *p) if (vp->v_op->vop_reclaim == NULL) return (EOPNOTSUPP); - vp->v_inflight++; - r = (vp->v_op->vop_reclaim)(&a); - vp->v_inflight--; - return r; + return ((vp->v_op->vop_reclaim)(&a)); } int diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index d393c7cce6c..3668f954a9a 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.158 2021/10/02 08:51:41 semarie Exp $ */ +/* $OpenBSD: vnode.h,v 1.159 2021/10/04 08:11:02 claudio Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -107,7 +107,6 @@ struct vnode { u_int v_bioflag; u_int v_holdcnt; /* buffer references */ u_int v_id; /* capability identifier */ - u_int v_inflight; struct mount *v_mount; /* ptr to vfs we are in */ TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 4561dda88be..371ca53f096 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.115 2020/06/24 22:03:44 cheloha Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.116 2021/10/04 08:11:02 claudio Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -717,9 +717,6 @@ ext2fs_sync_vnode(struct vnode *vp, void *args) if (vp->v_type == VNON) return (0); - if (vp->v_inflight) - esa->inflight = MIN(esa->inflight+1, 65536); - ip = VTOI(vp); if (ip->i_e2fs_nlink == 0) @@ -731,7 +728,7 @@ ext2fs_sync_vnode(struct vnode *vp, void *args) } if (vget(vp, LK_EXCLUSIVE | LK_NOWAIT)) { - nlink0 = 1; /* potentially */ + esa->inflight = MIN(esa->inflight+1, 65536); goto end; } @@ -742,6 +739,7 @@ end: esa->nlink0 = MIN(esa->nlink0 + nlink0, 65536); return (0); } + /* * Go through the disk queues to initiate sandbagged IO; * go through the inodes to write those that have been modified; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index a7cc61b2b51..48303e6a811 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.189 2021/05/01 16:18:29 gnezdo Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.190 2021/10/04 08:11:02 claudio Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -1165,9 +1165,6 @@ ffs_sync_vnode(struct vnode *vp, void *arg) ip = VTOI(vp); - if (vp->v_inflight && !(vp->v_type == VCHR || vp->v_type == VBLK)) - fsa->inflight = MIN(fsa->inflight+1, 65536); - /* * If unmounting or converting rw to ro, then stop deferring * timestamp writes. @@ -1187,7 +1184,7 @@ ffs_sync_vnode(struct vnode *vp, void *arg) } if (vget(vp, LK_EXCLUSIVE | LK_NOWAIT)) { - nlink0 = 1; /* potentially.. */ + fsa->inflight = MIN(fsa->inflight+1, 65536); goto end; } |