From f1993be39f8ef0573a33dbd9302d5aa032252355 Mon Sep 17 00:00:00 2001 From: visa Date: Sun, 12 Dec 2021 09:14:58 +0000 Subject: [PATCH] Add vnode parameter to VOP_STRATEGY() Pass the device vnode as a parameter to VOP_STRATEGY() to allow calling the correct vop_strategy callback. Now the vnode is also available in the callback. OK mpi@ --- share/man/man9/VOP_LOOKUP.9 | 13 ++++++++----- sys/dev/softraid.c | 6 +++--- sys/isofs/cd9660/cd9660_vnops.c | 4 ++-- sys/isofs/udf/udf_vnops.c | 4 ++-- sys/kern/vfs_bio.c | 8 ++++---- sys/kern/vfs_vops.c | 9 +++++---- sys/miscfs/deadfs/dead_vnops.c | 4 ++-- sys/msdosfs/msdosfs_vnops.c | 4 ++-- sys/nfs/nfs_vnops.c | 4 ++-- sys/sys/vnode.h | 7 ++++--- sys/ufs/ext2fs/ext2fs_bmap.c | 4 ++-- sys/ufs/ext2fs/ext2fs_inode.c | 4 ++-- sys/ufs/ffs/ffs_inode.c | 4 ++-- sys/ufs/ufs/ufs_bmap.c | 4 ++-- sys/ufs/ufs/ufs_vnops.c | 4 ++-- sys/uvm/uvm_swap.c | 8 ++++---- 16 files changed, 48 insertions(+), 43 deletions(-) diff --git a/share/man/man9/VOP_LOOKUP.9 b/share/man/man9/VOP_LOOKUP.9 index 37af6826a58..ae09ca1b32e 100644 --- a/share/man/man9/VOP_LOOKUP.9 +++ b/share/man/man9/VOP_LOOKUP.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: VOP_LOOKUP.9,v 1.44 2018/10/06 23:08:13 beck Exp $ +.\" $OpenBSD: VOP_LOOKUP.9,v 1.45 2021/12/12 09:14:58 visa Exp $ .\" .\" Copyright (c) 2003 Ted Unangst .\" Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -24,7 +24,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: October 6 2018 $ +.Dd $Mdocdate: December 12 2021 $ .Dt VOP_LOOKUP 9 .Os .Sh NAME @@ -264,6 +264,7 @@ .Fc .Ft int .Fo VOP_STRATEGY +.Fa "struct vnode *vp" .Fa "struct buf *bp" .Fc .Ft int @@ -876,9 +877,11 @@ Both are locked on entry and unlocked on exit. The name of the directory for removal is additionally contained in .Fa cnp . .Pp -.It Fn VOP_STRATEGY bp -Call the appropriate strategy function for the device backing the -buffer's vnode. +.It Fn VOP_STRATEGY vp bp +Call the appropriate strategy function for the device vnode +.Fa vp +to read or write the buffer +.Fa bp . .Pp .It Fn VOP_SYMLINK dvp vpp cnp vap target Create a symbolic link with name diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index e31a72f4fbd..20ab010ef3f 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.419 2021/05/16 15:10:19 deraadt Exp $ */ +/* $OpenBSD: softraid.c,v 1.420 2021/12/12 09:14:58 visa Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom * Copyright (c) 2008 Chris Kuethe @@ -441,7 +441,7 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr_t blkno, vp->v_numoutput++; LIST_INIT(&b.b_dep); - VOP_STRATEGY(&b); + VOP_STRATEGY(vp, &b); biowait(&b); if (b.b_flags & B_ERROR) { @@ -4261,7 +4261,7 @@ sr_raid_startwu(struct sr_workunit *wu) wu->swu_cb_active = 1; TAILQ_FOREACH(ccb, &wu->swu_ccb, ccb_link) - VOP_STRATEGY(&ccb->ccb_buf); + VOP_STRATEGY(ccb->ccb_buf.b_vp, &ccb->ccb_buf); wu->swu_cb_active = 0; } diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index 20efc932833..33a1314679e 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.91 2021/12/11 09:28:26 visa Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.92 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -746,7 +746,7 @@ cd9660_strategy(void *v) } vp = ip->i_devvp; bp->b_dev = vp->v_rdev; - (vp->v_op->vop_strategy)(ap); + VOP_STRATEGY(vp, bp); return (0); } diff --git a/sys/isofs/udf/udf_vnops.c b/sys/isofs/udf/udf_vnops.c index 181fb621933..33b1c1ddf05 100644 --- a/sys/isofs/udf/udf_vnops.c +++ b/sys/isofs/udf/udf_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vnops.c,v 1.68 2020/01/20 23:21:55 claudio Exp $ */ +/* $OpenBSD: udf_vnops.c,v 1.69 2021/12/12 09:14:59 visa Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -886,7 +886,7 @@ udf_strategy(void *v) splx(s); } else { bp->b_dev = vp->v_rdev; - (up->u_devvp->v_op->vop_strategy)(ap); + VOP_STRATEGY(up->u_devvp, bp); } return (0); diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 843d2e0a965..1e29dfcbce0 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.207 2021/09/05 11:44:46 mpi Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.208 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /* @@ -444,7 +444,7 @@ bio_doread(struct vnode *vp, daddr_t blkno, int size, int async) SET(bp->b_flags, B_READ | async); bcstats.pendingreads++; bcstats.numreads++; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); /* Pay for the read. */ curproc->p_ru.ru_inblock++; /* XXX */ } else if (async) { @@ -675,7 +675,7 @@ bread_cluster(struct vnode *vp, daddr_t blkno, int size, struct buf **rbpp) bcstats.pendingreads++; bcstats.numreads++; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); curproc->p_ru.ru_inblock++; out: @@ -753,7 +753,7 @@ bwrite(struct buf *bp) splx(s); buf_flip_dma(bp); SET(bp->b_flags, B_WRITEINPROG); - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); /* * If the queue is above the high water mark, wait till diff --git a/sys/kern/vfs_vops.c b/sys/kern/vfs_vops.c index c4562ecfaf5..2b4bc3467a0 100644 --- a/sys/kern/vfs_vops.c +++ b/sys/kern/vfs_vops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vops.c,v 1.33 2021/10/20 06:35:39 semarie Exp $ */ +/* $OpenBSD: vfs_vops.c,v 1.34 2021/12/12 09:14:59 visa Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson * @@ -629,18 +629,19 @@ VOP_ADVLOCK(struct vnode *vp, void *id, int op, struct flock *fl, int flags) } int -VOP_STRATEGY(struct buf *bp) +VOP_STRATEGY(struct vnode *vp, struct buf *bp) { struct vop_strategy_args a; + a.a_vp = vp; a.a_bp = bp; if ((ISSET(bp->b_flags, B_BC)) && (!ISSET(bp->b_flags, B_DMA))) panic("Non dma reachable buffer passed to VOP_STRATEGY"); - if (bp->b_vp->v_op->vop_strategy == NULL) + if (vp->v_op->vop_strategy == NULL) return (EOPNOTSUPP); - return ((bp->b_vp->v_op->vop_strategy)(&a)); + return ((vp->v_op->vop_strategy)(&a)); } int diff --git a/sys/miscfs/deadfs/dead_vnops.c b/sys/miscfs/deadfs/dead_vnops.c index b197bc0b7f5..c36111f1cb2 100644 --- a/sys/miscfs/deadfs/dead_vnops.c +++ b/sys/miscfs/deadfs/dead_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dead_vnops.c,v 1.38 2021/10/19 06:09:39 semarie Exp $ */ +/* $OpenBSD: dead_vnops.c,v 1.39 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: dead_vnops.c,v 1.16 1996/02/13 13:12:48 mycroft Exp $ */ /* @@ -203,7 +203,7 @@ dead_strategy(void *v) splx(s); return (EIO); } - return (VOP_STRATEGY(ap->a_bp)); + return (VOP_STRATEGY(ap->a_bp->b_vp, ap->a_bp)); } int diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 1f0571e719b..b048525f0f9 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.136 2021/12/11 09:28:26 visa Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.137 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */ /*- @@ -1810,7 +1810,7 @@ msdosfs_strategy(void *v) vp = dep->de_devvp; bp->b_dev = vp->v_rdev; - (vp->v_op->vop_strategy)(ap); + VOP_STRATEGY(vp, bp); return (0); } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 69fe85b41cd..9c9cbc38202 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.187 2021/10/02 08:51:41 semarie Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.188 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -3211,7 +3211,7 @@ nfs_writebp(struct buf *bp, int force) buf_flip_dma(bp); if (force) bp->b_flags |= B_WRITEINPROG; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); } if( (oldflags & B_ASYNC) == 0) { diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index f318b77cc7c..0aa8eaddb68 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.162 2021/10/20 06:35:39 semarie Exp $ */ +/* $OpenBSD: vnode.h,v 1.163 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -562,12 +562,13 @@ struct vop_advlock_args { }; int VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int); -/* Special cases: */ struct vop_strategy_args { + struct vnode *a_vp; struct buf *a_bp; }; -int VOP_STRATEGY(struct buf *); +int VOP_STRATEGY(struct vnode *, struct buf *); +/* Special cases: */ struct vop_bwrite_args { struct buf *a_bp; }; diff --git a/sys/ufs/ext2fs/ext2fs_bmap.c b/sys/ufs/ext2fs/ext2fs_bmap.c index 3311e1b76bb..4d5c6099532 100644 --- a/sys/ufs/ext2fs/ext2fs_bmap.c +++ b/sys/ufs/ext2fs/ext2fs_bmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_bmap.c,v 1.27 2019/07/19 00:24:31 cheloha Exp $ */ +/* $OpenBSD: ext2fs_bmap.c,v 1.28 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: ext2fs_bmap.c,v 1.5 2000/03/30 12:41:11 augustss Exp $ */ /* @@ -226,7 +226,7 @@ ext2fs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, else { bp->b_blkno = blkptrtodb(ump, daddr); bp->b_flags |= B_READ; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); curproc->p_ru.ru_inblock++; /* XXX */ bcstats.pendingreads++; if ((error = biowait(bp)) != 0) { diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index d4feff0a8f0..5c76a5956b3 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.64 2021/03/11 13:31:35 jsg Exp $ */ +/* $OpenBSD: ext2fs_inode.c,v 1.65 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: ext2fs_inode.c,v 1.24 2001/06/19 12:59:18 wiz Exp $ */ /* @@ -456,7 +456,7 @@ ext2fs_indirtrunc(struct inode *ip, int32_t lbn, int32_t dbn, int32_t lastbn, in if (bp->b_bcount > bp->b_bufsize) panic("ext2fs_indirtrunc: bad buffer size"); bp->b_blkno = dbn; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); error = biowait(bp); } if (error) { diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 11a24acbcbb..4ef913f4450 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.80 2019/07/25 01:43:21 cheloha Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.81 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -488,7 +488,7 @@ ffs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn, if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); bp->b_blkno = dbn; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); error = biowait(bp); } if (error) { diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index d7034ed1a10..b094e5b9da4 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_bmap.c,v 1.36 2019/07/19 00:24:32 cheloha Exp $ */ +/* $OpenBSD: ufs_bmap.c,v 1.37 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: ufs_bmap.c,v 1.3 1996/02/09 22:36:00 christos Exp $ */ /* @@ -173,7 +173,7 @@ ufs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap, bp->b_flags |= B_READ; bcstats.pendingreads++; bcstats.numreads++; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); curproc->p_ru.ru_inblock++; /* XXX */ if ((error = biowait(bp)) != 0) { brelse(bp); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index ea6e2649e1d..9056ff6c453 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.154 2021/12/11 09:28:26 visa Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.155 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -1608,7 +1608,7 @@ ufs_strategy(void *v) } vp = ip->i_devvp; bp->b_dev = vp->v_rdev; - (vp->v_op->vop_strategy)(ap); + VOP_STRATEGY(vp, bp); return (0); } diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index 661b10caa8e..4c991e74ba2 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap.c,v 1.151 2021/11/11 09:34:27 tb Exp $ */ +/* $OpenBSD: uvm_swap.c,v 1.152 2021/12/12 09:14:59 visa Exp $ */ /* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */ /* @@ -1099,7 +1099,7 @@ swstrategy(struct buf *bp) bp->b_blkno = bn; splx(s); - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); return; case VREG: /* delegate to sw_reg_strategy function. */ @@ -1299,7 +1299,7 @@ sw_reg_start(struct swapdev *sdp) if ((bp->b_flags & B_READ) == 0) bp->b_vp->v_numoutput++; - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); } sdp->swd_flags &= ~SWF_BUSY; } @@ -1817,7 +1817,7 @@ uvm_swap_io(struct vm_page **pps, int startslot, int npages, int flags) } /* now we start the I/O, and if async, return. */ - VOP_STRATEGY(bp); + VOP_STRATEGY(bp->b_vp, bp); if (async) return (VM_PAGER_PEND); -- 2.20.1