From d8b3df3cb90ffaa3381db166cd1e1f43fa25aa69 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 15 Nov 2004 09:18:27 +0000 Subject: [PATCH] Make VOP_BMAP return a struct bufobj for the underlying storage device instead of a vnode for it. The vnode_pager does not and should not have any interest in what the filesystem uses for backend. (vfs_cluster doesn't use the backing store argument.) --- sys/coda/coda_vnops.c | 8 ++++---- sys/fs/cd9660/cd9660_bmap.c | 6 +++--- sys/fs/coda/coda_vnops.c | 8 ++++---- sys/fs/deadfs/dead_vnops.c | 4 ++-- sys/fs/hpfs/hpfs_vnops.c | 6 +++--- sys/fs/msdosfs/msdosfs_vnops.c | 6 +++--- sys/fs/ntfs/ntfs_vnops.c | 6 +++--- sys/fs/udf/udf_vnops.c | 4 ++-- sys/gnu/ext2fs/ext2_bmap.c | 6 +++--- sys/gnu/fs/ext2fs/ext2_bmap.c | 6 +++--- sys/isofs/cd9660/cd9660_bmap.c | 6 +++--- sys/kern/vfs_default.c | 6 +++--- sys/kern/vnode_if.src | 3 +-- sys/ufs/ufs/ufs_bmap.c | 6 +++--- sys/vm/vnode_pager.c | 23 +++++++++++++---------- 15 files changed, 53 insertions(+), 51 deletions(-) diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c index 97621a8c4c7b..a7e84a8558fe 100644 --- a/sys/coda/coda_vnops.c +++ b/sys/coda/coda_vnops.c @@ -1679,7 +1679,7 @@ coda_bmap(v) struct vop_bmap_args *ap = v; struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */ daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */ - struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */ + struct bufobj **bop = ap->a_bop; /* RETURN bufobj of device */ daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */ struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ @@ -1691,10 +1691,10 @@ coda_bmap(v) cp = VTOC(vp); if (cp->c_ovp) { return EINVAL; - ret = VOP_BMAP(cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb); + ret = VOP_BMAP(cp->c_ovp, bn, bop, bnp, ap->a_runp, ap->a_runb); #if 0 - printf("VOP_BMAP(cp->c_ovp %p, bn %p, vpp %p, bnp %lld, ap->a_runp %p, ap->a_runb %p) = %d\n", - cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb, ret); + printf("VOP_BMAP(cp->c_ovp %p, bn %p, bop %p, bnp %lld, ap->a_runp %p, ap->a_runb %p) = %d\n", + cp->c_ovp, bn, bop, bnp, ap->a_runp, ap->a_runb, ret); #endif return ret; } else { diff --git a/sys/fs/cd9660/cd9660_bmap.c b/sys/fs/cd9660/cd9660_bmap.c index a2563130943f..147f4457b85b 100644 --- a/sys/fs/cd9660/cd9660_bmap.c +++ b/sys/fs/cd9660/cd9660_bmap.c @@ -55,7 +55,7 @@ cd9660_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -69,8 +69,8 @@ cd9660_bmap(ap) * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = ip->i_mnt->im_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &ip->i_mnt->im_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c index 97621a8c4c7b..a7e84a8558fe 100644 --- a/sys/fs/coda/coda_vnops.c +++ b/sys/fs/coda/coda_vnops.c @@ -1679,7 +1679,7 @@ coda_bmap(v) struct vop_bmap_args *ap = v; struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */ daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */ - struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */ + struct bufobj **bop = ap->a_bop; /* RETURN bufobj of device */ daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */ struct thread *td __attribute__((unused)) = curthread; /* upcall decl */ @@ -1691,10 +1691,10 @@ coda_bmap(v) cp = VTOC(vp); if (cp->c_ovp) { return EINVAL; - ret = VOP_BMAP(cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb); + ret = VOP_BMAP(cp->c_ovp, bn, bop, bnp, ap->a_runp, ap->a_runb); #if 0 - printf("VOP_BMAP(cp->c_ovp %p, bn %p, vpp %p, bnp %lld, ap->a_runp %p, ap->a_runb %p) = %d\n", - cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb, ret); + printf("VOP_BMAP(cp->c_ovp %p, bn %p, bop %p, bnp %lld, ap->a_runp %p, ap->a_runb %p) = %d\n", + cp->c_ovp, bn, bop, bnp, ap->a_runp, ap->a_runb, ret); #endif return ret; } else { diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c index ff30d2fab3f7..ee57feb44d65 100644 --- a/sys/fs/deadfs/dead_vnops.c +++ b/sys/fs/deadfs/dead_vnops.c @@ -220,7 +220,7 @@ dead_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -229,7 +229,7 @@ dead_bmap(ap) if (!chkvnlock(ap->a_vp)) return (EIO); - return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb)); + return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_bop, ap->a_bnp, ap->a_runp, ap->a_runb)); } /* diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c index f4d35683fecc..58a2097ca683 100644 --- a/sys/fs/hpfs/hpfs_vnops.c +++ b/sys/fs/hpfs/hpfs_vnops.c @@ -240,7 +240,7 @@ hpfs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -250,8 +250,8 @@ hpfs_bmap(ap) daddr_t blkno; int error; - if (ap->a_vpp != NULL) - *ap->a_vpp = hp->h_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &hp->h_devvp->v_bufobj; if (ap->a_runb != NULL) *ap->a_runb = 0; if (ap->a_bnp == NULL) diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 66c600e3ada9..1b29db97c638 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -1736,7 +1736,7 @@ msdosfs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -1746,8 +1746,8 @@ msdosfs_bmap(ap) daddr_t blkno; int error; - if (ap->a_vpp != NULL) - *ap->a_vpp = dep->de_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &dep->de_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); if (ap->a_runp) { diff --git a/sys/fs/ntfs/ntfs_vnops.c b/sys/fs/ntfs/ntfs_vnops.c index 8a8f422d291f..4d683f44358a 100644 --- a/sys/fs/ntfs/ntfs_vnops.c +++ b/sys/fs/ntfs/ntfs_vnops.c @@ -91,15 +91,15 @@ ntfs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; } */ *ap; { dprintf(("ntfs_bmap: vn: %p, blk: %d\n", ap->a_vp,(u_int32_t)ap->a_bn)); - if (ap->a_vpp != NULL) - *ap->a_vpp = ap->a_vp; + if (ap->a_bop != NULL) + *ap->a_bop = &ap->a_vp->v_bufobj; if (ap->a_bnp != NULL) *ap->a_bnp = ap->a_bn; if (ap->a_runp != NULL) diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 80f39ed13ad7..c46dc7aba8d3 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -867,8 +867,8 @@ udf_bmap(struct vop_bmap_args *a) node = VTON(a->a_vp); - if (a->a_vpp != NULL) - *a->a_vpp = node->i_devvp; + if (a->a_bop != NULL) + *a->a_bop = &node->i_devvp->v_bufobj; if (a->a_bnp == NULL) return (0); if (a->a_runb) diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c index c6c3fa73457d..4b159aa83abf 100644 --- a/sys/gnu/ext2fs/ext2_bmap.c +++ b/sys/gnu/ext2fs/ext2_bmap.c @@ -61,7 +61,7 @@ ext2_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -74,8 +74,8 @@ ext2_bmap(ap) * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = VTOI(ap->a_vp)->i_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c index c6c3fa73457d..4b159aa83abf 100644 --- a/sys/gnu/fs/ext2fs/ext2_bmap.c +++ b/sys/gnu/fs/ext2fs/ext2_bmap.c @@ -61,7 +61,7 @@ ext2_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -74,8 +74,8 @@ ext2_bmap(ap) * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = VTOI(ap->a_vp)->i_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); diff --git a/sys/isofs/cd9660/cd9660_bmap.c b/sys/isofs/cd9660/cd9660_bmap.c index a2563130943f..147f4457b85b 100644 --- a/sys/isofs/cd9660/cd9660_bmap.c +++ b/sys/isofs/cd9660/cd9660_bmap.c @@ -55,7 +55,7 @@ cd9660_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -69,8 +69,8 @@ cd9660_bmap(ap) * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = ip->i_mnt->im_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &ip->i_mnt->im_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index eacdd0f430ac..9cd0695b40d5 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -508,15 +508,15 @@ vop_stdbmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; } */ *ap; { - if (ap->a_vpp != NULL) - *ap->a_vpp = ap->a_vp; + if (ap->a_bop != NULL) + *ap->a_bop = &ap->a_vp->v_bufobj; if (ap->a_bnp != NULL) *ap->a_bnp = ap->a_bn * btodb(ap->a_vp->v_mount->mnt_stat.f_iosize); if (ap->a_runp != NULL) diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 434dd13afa32..26c36e714277 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -382,12 +382,11 @@ vop_unlock { # #% bmap vp L L L -#% bmap vpp - U - # vop_bmap { IN struct vnode *vp; IN daddr_t bn; - OUT struct vnode **vpp; + OUT struct bufobj **bop; IN daddr_t *bnp; OUT int *runp; OUT int *runb; diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index 63f958c17f80..7219a86d3fff 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -63,7 +63,7 @@ ufs_bmap(ap) struct vop_bmap_args /* { struct vnode *a_vp; daddr_t a_bn; - struct vnode **a_vpp; + struct bufobj **a_bop; daddr_t *a_bnp; int *a_runp; int *a_runb; @@ -76,8 +76,8 @@ ufs_bmap(ap) * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ - if (ap->a_vpp != NULL) - *ap->a_vpp = VTOI(ap->a_vp)->i_devvp; + if (ap->a_bop != NULL) + *ap->a_bop = &VTOI(ap->a_vp)->i_devvp->v_bufobj; if (ap->a_bnp == NULL) return (0); diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 32b06f180bca..0856f96330f4 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -433,7 +433,8 @@ vnode_pager_input_smlfs(object, m) vm_page_t m; { int i; - struct vnode *dp, *vp; + struct vnode *vp; + struct bufobj *bo; struct buf *bp; struct sf_buf *sf; int fileaddr; @@ -448,7 +449,7 @@ vnode_pager_input_smlfs(object, m) bsize = vp->v_mount->mnt_stat.f_iosize; - VOP_BMAP(vp, 0, &dp, 0, NULL, NULL); + VOP_BMAP(vp, 0, &bo, 0, NULL, NULL); sf = sf_buf_alloc(m, 0); @@ -476,7 +477,7 @@ vnode_pager_input_smlfs(object, m) bp->b_wcred = crhold(curthread->td_ucred); bp->b_data = (caddr_t)sf_buf_kva(sf) + i * bsize; bp->b_blkno = fileaddr; - pbgetvp(dp, bp); + pbgetbo(bo, bp); bp->b_bcount = bsize; bp->b_bufsize = bsize; bp->b_runningbufspace = bp->b_bufsize; @@ -496,7 +497,7 @@ vnode_pager_input_smlfs(object, m) /* * free the buffer header back to the swap buffer pool */ - pbrelvp(bp); + pbrelbo(bp); relpbuf(bp, &vnode_pbuf_freecnt); if (error) break; @@ -645,7 +646,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) vm_offset_t kva; off_t foff, tfoff, nextoff; int i, j, size, bsize, first, firstaddr; - struct vnode *dp; + struct bufobj *bo; int runpg; int runend; struct buf *bp; @@ -656,6 +657,8 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) object = vp->v_object; count = bytecount / PAGE_SIZE; + KASSERT(vp->v_type != VCHR && vp->v_type != VBLK, + ("vnode_pager_generic_getpages does not support devices")); if (vp->v_mount == NULL) return VM_PAGER_BAD; @@ -672,7 +675,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) /* * if we can't bmap, use old VOP code */ - if (VOP_BMAP(vp, 0, &dp, 0, NULL, NULL)) { + if (VOP_BMAP(vp, 0, &bo, 0, NULL, NULL)) { VM_OBJECT_LOCK(object); vm_page_lock_queues(); for (i = 0; i < count; i++) @@ -803,8 +806,8 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) /* * round up physical size for real devices. */ - if (dp->v_type == VBLK || dp->v_type == VCHR) { - int secmask = dp->v_bufobj.bo_bsize - 1; + if (1) { + int secmask = bo->bo_bsize - 1; KASSERT(secmask < PAGE_SIZE && secmask > 0, ("vnode_pager_generic_getpages: sector size %d too large", secmask + 1)); @@ -827,7 +830,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) bp->b_rcred = crhold(curthread->td_ucred); bp->b_wcred = crhold(curthread->td_ucred); bp->b_blkno = firstaddr; - pbgetvp(dp, bp); + pbgetbo(bo, bp); bp->b_bcount = size; bp->b_bufsize = size; bp->b_runningbufspace = bp->b_bufsize; @@ -854,7 +857,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) /* * free the buffer header back to the swap buffer pool */ - pbrelvp(bp); + pbrelbo(bp); relpbuf(bp, &vnode_pbuf_freecnt); VM_OBJECT_LOCK(object);