diff options
author | phk <phk@FreeBSD.org> | 2004-10-25 09:14:03 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-10-25 09:14:03 +0000 |
commit | 0e87ab8bc6e542c845f82c2bb526208587b200ad (patch) | |
tree | 200ff5f062ab8c134c56e5c8d6bd7fb2f35f6bad | |
parent | 100e94e682f93c8aeae0f6683f1adab50f67b1f7 (diff) | |
download | FreeBSD-src-0e87ab8bc6e542c845f82c2bb526208587b200ad.zip FreeBSD-src-0e87ab8bc6e542c845f82c2bb526208587b200ad.tar.gz |
Loose the v_dirty* and v_clean* alias macros.
Check the count field where we just want to know the full/empty state,
rather than using TAILQ_EMPTY() or TAILQ_FIRST().
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vfsops.c | 9 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode.c | 4 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 3 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_inode.c | 4 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 3 | ||||
-rw-r--r-- | sys/kern/vfs_default.c | 7 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 14 | ||||
-rw-r--r-- | sys/nfs4client/nfs4_vfsops.c | 3 | ||||
-rw-r--r-- | sys/sys/vnode.h | 7 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_rawread.c | 30 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 11 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 9 |
14 files changed, 56 insertions, 58 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 4893798..2f7695a 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -741,9 +741,9 @@ msdosfs_unmount(mp, mntflags, td) TAILQ_NEXT(vp, v_freelist), vp->v_freelist.tqe_prev, vp->v_mount); printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n", - TAILQ_FIRST(&vp->v_cleanblkhd), - TAILQ_FIRST(&vp->v_dirtyblkhd), - vp->v_numoutput, vp->v_type); + TAILQ_FIRST(&vp->v_bufobj.bo_clean.bv_hd), + TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd), + vp->v_bufobj.bo_numoutput, vp->v_type); printf("union %p, tag %s, data[0] %08x, data[1] %08x\n", vp->v_socket, vp->v_tag, ((u_int *)vp->v_data)[0], @@ -854,7 +854,8 @@ loop: if (vp->v_type == VNON || ((dep->de_flag & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 && - (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) { + (vp->v_bufobj.bo_dirty.bv_cnt == 0 || + waitfor == MNT_LAZY))) { VI_UNLOCK(vp); MNT_ILOCK(mp); continue; diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index 24f41d9..d55ddfd 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -326,8 +326,8 @@ done: if (newblks[i] != oip->i_db[i]) panic("itrunc2"); VI_LOCK(ovp); - if (length == 0 && (!TAILQ_EMPTY(&ovp->v_dirtyblkhd) || - !TAILQ_EMPTY(&ovp->v_cleanblkhd))) + if (length == 0 && (ovp->v_bufobj.bo_dirty.bv_cnt != 0 || + ovp->v_bufobj.bo_clean.bv_cnt != 0)) panic("itrunc3"); VI_UNLOCK(ovp); #endif /* DIAGNOSTIC */ diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index bf0a2fd..292f20e 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -931,7 +931,8 @@ loop: if (vp->v_type == VNON || ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) { + (vp->v_bufobj.bo_dirty.bv_cnt == 0 || + waitfor == MNT_LAZY))) { VI_UNLOCK(vp); MNT_ILOCK(mp); continue; diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index 24f41d9..d55ddfd 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -326,8 +326,8 @@ done: if (newblks[i] != oip->i_db[i]) panic("itrunc2"); VI_LOCK(ovp); - if (length == 0 && (!TAILQ_EMPTY(&ovp->v_dirtyblkhd) || - !TAILQ_EMPTY(&ovp->v_cleanblkhd))) + if (length == 0 && (ovp->v_bufobj.bo_dirty.bv_cnt != 0 || + ovp->v_bufobj.bo_clean.bv_cnt != 0)) panic("itrunc3"); VI_UNLOCK(ovp); #endif /* DIAGNOSTIC */ diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index bf0a2fd..292f20e 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -931,7 +931,8 @@ loop: if (vp->v_type == VNON || ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) { + (vp->v_bufobj.bo_dirty.bv_cnt == 0 || + waitfor == MNT_LAZY))) { VI_UNLOCK(vp); MNT_ILOCK(mp); continue; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 72e03bf..0f77900 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -550,7 +550,7 @@ loop1: * MARK/SCAN initialization to avoid infinite loops. */ s = splbio(); - TAILQ_FOREACH(bp, &vp->v_dirtyblkhd, b_bobufs) { + TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs) { bp->b_vflags &= ~BV_SCANNED; bp->b_error = 0; } @@ -561,8 +561,7 @@ loop1: */ loop2: s = splbio(); - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp != NULL; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_bobufs); + TAILQ_FOREACH_SAFE(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs, nbp) { if ((bp->b_vflags & BV_SCANNED) != 0) continue; bp->b_vflags |= BV_SCANNED; @@ -724,7 +723,7 @@ loop: MNT_VNODE_FOREACH(vp, mp, nvp) { VI_LOCK(vp); - if (TAILQ_EMPTY(&vp->v_dirtyblkhd)) { + if (vp->v_bufobj.bo_dirty.bv_cnt == 0) { VI_UNLOCK(vp); continue; } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e3dcaf9..a233c5a 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -952,13 +952,15 @@ vinvalbuf(vp, flags, cred, td, slpflag, slptimeo) * no race conditions occur from this. */ for (error = 0;;) { - if ((blist = TAILQ_FIRST(&vp->v_cleanblkhd)) != 0 && + blist = TAILQ_FIRST(&vp->v_bufobj.bo_clean.bv_hd); + if (blist != NULL && flushbuflist(blist, flags, vp, slpflag, slptimeo, &error)) { if (error) break; continue; } - if ((blist = TAILQ_FIRST(&vp->v_dirtyblkhd)) != 0 && + blist = TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd); + if (blist != NULL && flushbuflist(blist, flags, vp, slpflag, slptimeo, &error)) { if (error) break; @@ -985,7 +987,7 @@ vinvalbuf(vp, flags, cred, td, slpflag, slptimeo) VM_OBJECT_UNLOCK(object); } VI_LOCK(vp); - } while (vp->v_numoutput > 0); + } while (bo->bo_numoutput > 0); VI_UNLOCK(vp); /* @@ -1001,8 +1003,8 @@ vinvalbuf(vp, flags, cred, td, slpflag, slptimeo) #ifdef INVARIANTS VI_LOCK(vp); if ((flags & (V_ALT | V_NORMAL)) == 0 && - (!TAILQ_EMPTY(&vp->v_dirtyblkhd) || - !TAILQ_EMPTY(&vp->v_cleanblkhd))) + (vp->v_bufobj.bo_dirty.bv_cnt > 0 || + vp->v_bufobj.bo_clean.bv_cnt > 0)) panic("vinvalbuf: flush failed"); VI_UNLOCK(vp); #endif @@ -1398,7 +1400,7 @@ brelvp(struct buf *bp) bo = bp->b_bufobj; if (bp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN)) buf_vlist_remove(bp); - if ((vp->v_iflag & VI_ONWORKLST) && TAILQ_EMPTY(&vp->v_dirtyblkhd)) { + if ((vp->v_iflag & VI_ONWORKLST) && bo->bo_dirty.bv_cnt == 0) { vp->v_iflag &= ~VI_ONWORKLST; mtx_lock(&sync_mtx); LIST_REMOVE(vp, v_synclist); diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index b8e8a32..c3f029e 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -726,7 +726,8 @@ loop: MNT_VNODE_FOREACH(vp, mp, nvp) { VI_LOCK(vp); MNT_IUNLOCK(mp); - if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) || + if (VOP_ISLOCKED(vp, NULL) || + vp->v_bufobj.bo_dirty.bv_cnt == 0 || waitfor == MNT_LAZY) { VI_UNLOCK(vp); MNT_ILOCK(mp); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 0aa01de..07a86d7 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -163,13 +163,6 @@ struct vnode { /* XXX: These are temporary to avoid a source sweep at this time */ #define v_object v_bufobj.bo_object -#define v_cleanblkhd v_bufobj.bo_clean.bv_hd -#define v_cleanblkroot v_bufobj.bo_clean.bv_root -#define v_cleanbufcnt v_bufobj.bo_clean.bv_cnt -#define v_dirtyblkhd v_bufobj.bo_dirty.bv_hd -#define v_dirtyblkroot v_bufobj.bo_dirty.bv_root -#define v_dirtybufcnt v_bufobj.bo_dirty.bv_cnt -#define v_numoutput v_bufobj.bo_numoutput /* * Userland version of struct vnode, for sysctl. diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 372d83c..012542a 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -483,8 +483,8 @@ done: VI_LOCK(ovp); if (length == 0 && (fs->fs_magic != FS_UFS2_MAGIC || oip->i_din2->di_extsize == 0) && - (!TAILQ_EMPTY(&ovp->v_dirtyblkhd) || - !TAILQ_EMPTY(&ovp->v_cleanblkhd))) + (vp->v_bufobj.bo_dirty.bv_cnt > 0 || + vp->v_bufobj.bo_clean.bv_cnt > 0)) panic("ffs_truncate3"); VI_UNLOCK(ovp); #endif /* DIAGNOSTIC */ diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c index e5cc03e..05f1577 100644 --- a/sys/ufs/ffs/ffs_rawread.c +++ b/sys/ufs/ffs/ffs_rawread.c @@ -102,13 +102,15 @@ ffs_rawread_sync(struct vnode *vp, struct thread *td) int spl; int error; int upgraded; + struct bufobj *bo; GIANT_REQUIRED; /* Check for dirty mmap, pending writes and dirty buffers */ spl = splbio(); VI_LOCK(vp); - if (vp->v_numoutput > 0 || - !TAILQ_EMPTY(&vp->v_dirtyblkhd) || + bo = &vp->v_bufobj; + if (bo->bo_numoutput > 0 || + bo->bo_dirty.bv_cnt > 0) || (vp->v_iflag & VI_OBJDIRTY) != 0) { splx(spl); VI_UNLOCK(vp); @@ -136,19 +138,17 @@ ffs_rawread_sync(struct vnode *vp, struct thread *td) /* Wait for pending writes to complete */ spl = splbio(); - while (vp->v_numoutput) { - error = bufobj_wwait(&vp->v_bufobj, 0, 0); - if (error != 0) { - /* XXX: can't happen with a zero timeout ??? */ - splx(spl); - VI_UNLOCK(vp); - if (upgraded != 0) - VOP_LOCK(vp, LK_DOWNGRADE, td); - return (error); - } + error = bufobj_wwait(&vp->v_bufobj, 0, 0); + if (error != 0) { + /* XXX: can't happen with a zero timeout ??? */ + splx(spl); + VI_UNLOCK(vp); + if (upgraded != 0) + VOP_LOCK(vp, LK_DOWNGRADE, td); + return (error); } /* Flush dirty buffers */ - if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) { + if (bo->bo_dirty.bv_cnt > 0)) { splx(spl); VI_UNLOCK(vp); if ((error = VOP_FSYNC(vp, NOCRED, MNT_WAIT, td)) != 0) { @@ -158,8 +158,8 @@ ffs_rawread_sync(struct vnode *vp, struct thread *td) } VI_LOCK(vp); spl = splbio(); - if (vp->v_numoutput > 0 || - !TAILQ_EMPTY(&vp->v_dirtyblkhd)) + if (bo->bo_numoutput > 0 || + bo->bo_dirty.bv_cnt > 0)) panic("ffs_rawread_sync: dirty bufs"); } splx(spl); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 0d1ef2c..757de54 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2068,7 +2068,7 @@ softdep_setup_freeblocks(ip, length, flags) VI_LOCK(vp); drain_output(vp, 1); restart: - TAILQ_FOREACH(bp, &vp->v_dirtyblkhd, b_bobufs) { + TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs) { if (((flags & IO_EXT) == 0 && (bp->b_xflags & BX_ALTDATA)) || ((flags & IO_NORMAL) == 0 && (bp->b_xflags & BX_ALTDATA) == 0)) @@ -4924,8 +4924,7 @@ softdep_fsync_mountdev(vp) panic("softdep_fsync_mountdev: vnode not a disk"); ACQUIRE_LOCK(&lk); VI_LOCK(vp); - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_bobufs); + TAILQ_FOREACH_SAFE(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs, nbp) { /* * If it is already scheduled, skip to the next buffer. */ @@ -4956,7 +4955,7 @@ softdep_fsync_mountdev(vp) * to start from a known point. */ VI_LOCK(vp); - nbp = TAILQ_FIRST(&vp->v_dirtyblkhd); + nbp = TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd); } drain_output(vp, 1); VI_UNLOCK(vp); @@ -5030,7 +5029,7 @@ top: */ VI_LOCK(vp); drain_output(vp, 1); - bp = getdirtybuf(&TAILQ_FIRST(&vp->v_dirtyblkhd), + bp = getdirtybuf(&TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd), VI_MTX(vp), MNT_WAIT); if (bp == NULL) { VI_UNLOCK(vp); @@ -5217,7 +5216,7 @@ loop: */ VI_LOCK(vp); drain_output(vp, 1); - if (TAILQ_FIRST(&vp->v_dirtyblkhd) == NULL) { + if (vp->v_bufobj.bo_dirty.bv_cnt == 0) { VI_UNLOCK(vp); FREE_LOCK(&lk); return (0); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 4d9cc32..ad63665 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1099,6 +1099,7 @@ ffs_sync(mp, waitfor, cred, td) struct ufsmount *ump = VFSTOUFS(mp); struct fs *fs; int error, count, wait, lockreq, allerror = 0; + struct bufobj *bo; fs = ump->um_fs; if (fs->fs_fmod != 0 && fs->fs_ronly != 0) { /* XXX */ @@ -1132,7 +1133,7 @@ loop: ip = VTOI(vp); if (vp->v_type == VNON || ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - TAILQ_EMPTY(&vp->v_dirtyblkhd))) { + vp->v_bufobj.bo_dirty.bv_cnt == 0)) { VI_UNLOCK(vp); continue; } @@ -1167,8 +1168,9 @@ loop: #endif devvp = ump->um_devvp; VI_LOCK(devvp); + bo = &devvp->v_bufobj; if (waitfor != MNT_LAZY && - (devvp->v_numoutput > 0 || TAILQ_FIRST(&devvp->v_dirtyblkhd))) { + (bo->bo_numoutput > 0 || bo->bo_dirty.bv_cnt > 0)) { vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td); if ((error = VOP_FSYNC(devvp, cred, waitfor, td)) != 0) allerror = error; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 1532674..4bcf5f2 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -197,10 +197,9 @@ ffs_fsync(ap) s = splbio(); VI_LOCK(vp); loop: - TAILQ_FOREACH(bp, &vp->v_dirtyblkhd, b_bobufs) + TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs) bp->b_vflags &= ~BV_SCANNED; - for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { - nbp = TAILQ_NEXT(bp, b_bobufs); + TAILQ_FOREACH_SAFE(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs, nbp) { /* * Reasons to skip this buffer: it has already been considered * on this pass, this pass is the first time through on a @@ -273,7 +272,7 @@ loop: * to start from a known point. */ VI_LOCK(vp); - nbp = TAILQ_FIRST(&vp->v_dirtyblkhd); + nbp = TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd); } /* * If we were asked to do this synchronously, then go back for @@ -298,7 +297,7 @@ loop: s = splbio(); VI_LOCK(vp); - if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) { + if (vp->v_bufobj.bo_dirty.bv_cnt > 0) { /* * Block devices associated with filesystems may * have new I/O requests posted for them even if |