diff options
author | mckusick <mckusick@FreeBSD.org> | 1999-06-26 02:47:16 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 1999-06-26 02:47:16 +0000 |
commit | 5b58f2f951911f1075788268f99efccf1dba60eb (patch) | |
tree | 3f01ed42f71231eaa6a8cfa08b267634f1923fb1 /sys/ufs | |
parent | 3213b13650cb2206bbd62b5b1764d148750f63a0 (diff) | |
download | FreeBSD-src-5b58f2f951911f1075788268f99efccf1dba60eb.zip FreeBSD-src-5b58f2f951911f1075788268f99efccf1dba60eb.tar.gz |
Convert buffer locking from using the B_BUSY and B_WANTED flags to using
lockmgr locks. This commit should be functionally equivalent to the old
semantics. That is, all buffer locking is done with LK_EXCLUSIVE
requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will
be done in future commits.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 22 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 13 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vnops.c | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_disksubr.c | 10 |
4 files changed, 28 insertions, 22 deletions
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index df2791f..eaaa2ec 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * from: @(#)ffs_softdep.c 9.40 (McKusick) 6/15/99 - * $Id: ffs_softdep.c,v 1.30 1999/06/15 23:37:29 mckusick Exp $ + * $Id: ffs_softdep.c,v 1.31 1999/06/16 23:27:55 mckusick Exp $ */ /* @@ -1530,6 +1530,8 @@ setup_allocindir_phase2(bp, ip, aip) } newindirdep->ir_savebp = getblk(ip->i_devvp, bp->b_blkno, bp->b_bcount, 0, 0); + newindirdep->ir_savebp->b_flags |= B_ASYNC; + BUF_KERNPROC(newindirdep->ir_savebp); bcopy(bp->b_data, newindirdep->ir_savebp->b_data, bp->b_bcount); } } @@ -3698,7 +3700,7 @@ softdep_fsync_mountdev(vp) /* * If it is already scheduled, skip to the next buffer. */ - if (bp->b_flags & B_BUSY) + if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) continue; if ((bp->b_flags & B_DELWRI) == 0) panic("softdep_fsync_mountdev: not dirty"); @@ -3707,10 +3709,11 @@ softdep_fsync_mountdev(vp) * dependencies. */ if ((wk = LIST_FIRST(&bp->b_dep)) == NULL || - wk->wk_type != D_BMSAFEMAP) + wk->wk_type != D_BMSAFEMAP) { + BUF_UNLOCK(bp); continue; + } bremfree(bp); - bp->b_flags |= B_BUSY; FREE_LOCK(&lk); (void) bawrite(bp); ACQUIRE_LOCK(&lk); @@ -4414,19 +4417,20 @@ getdirtybuf(bpp, waitfor) for (;;) { if ((bp = *bpp) == NULL) return (0); - if ((bp->b_flags & B_BUSY) == 0) + if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT) == 0) break; if (waitfor != MNT_WAIT) return (0); - bp->b_flags |= B_WANTED; FREE_LOCK_INTERLOCKED(&lk); - tsleep((caddr_t)bp, PRIBIO + 1, "sdsdty", 0); + if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL) != ENOLCK) + panic("getdirtybuf: inconsistent lock"); ACQUIRE_LOCK_INTERLOCKED(&lk); } - if ((bp->b_flags & B_DELWRI) == 0) + if ((bp->b_flags & B_DELWRI) == 0) { + BUF_UNLOCK(bp); return (0); + } bremfree(bp); - bp->b_flags |= B_BUSY; return (1); } diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 97c96fc..29f403a 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95 - * $Id: ffs_vnops.c,v 1.56 1999/05/14 01:26:05 mckusick Exp $ + * $Id: ffs_vnops.c,v 1.57 1999/06/18 05:49:46 mckusick Exp $ */ #include <sys/param.h> @@ -159,8 +159,9 @@ loop: * or if it's already scheduled, skip to the next * buffer */ - if ((bp->b_flags & (B_BUSY | B_SCANNED)) || - ((skipmeta == 1) && (bp->b_lblkno < 0))) + if ((bp->b_flags & B_SCANNED) || + ((skipmeta == 1) && (bp->b_lblkno < 0)) || + BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) continue; if ((bp->b_flags & B_DELWRI) == 0) panic("ffs_fsync: not dirty"); @@ -181,17 +182,16 @@ loop: if (passes > 0 || (ap->a_waitfor != MNT_WAIT)) { if ((bp->b_flags & B_CLUSTEROK) && ap->a_waitfor != MNT_WAIT) { + BUF_UNLOCK(bp); (void) vfs_bio_awrite(bp); } else { bremfree(bp); - bp->b_flags |= B_BUSY; splx(s); (void) bawrite(bp); s = splbio(); } } else { bremfree(bp); - bp->b_flags |= B_BUSY; splx(s); if ((error = bwrite(bp)) != 0) return (error); @@ -203,11 +203,12 @@ loop: * off the file, then throw it away. */ bremfree(bp); - bp->b_flags |= B_BUSY | B_INVAL | B_NOCACHE; + bp->b_flags |= B_INVAL | B_NOCACHE; splx(s); brelse(bp); s = splbio(); } else { + BUF_UNLOCK(bp); vfs_bio_awrite(bp); } /* diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c index c9ae4dd..09b65e4 100644 --- a/sys/ufs/mfs/mfs_vnops.c +++ b/sys/ufs/mfs/mfs_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mfs_vnops.c 8.11 (Berkeley) 5/22/95 - * $Id: mfs_vnops.c,v 1.43 1999/04/11 02:28:32 eivind Exp $ + * $Id: mfs_vnops.c,v 1.44 1999/05/02 23:56:57 alc Exp $ */ #include <sys/param.h> @@ -147,11 +147,12 @@ mfs_freeblks(ap) panic("mfs_freeblks: bad dev"); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF | B_BUSY; + bp->b_flags |= B_FREEBUF | B_ASYNC; bp->b_dev = ap->a_vp->v_rdev; bp->b_blkno = ap->a_addr; bp->b_offset = dbtob(ap->a_addr); bp->b_bcount = ap->a_length; + BUF_KERNPROC(bp); VOP_STRATEGY(vp, bp); return(0); } diff --git a/sys/ufs/ufs/ufs_disksubr.c b/sys/ufs/ufs/ufs_disksubr.c index 33f1d2a..21088cb 100644 --- a/sys/ufs/ufs/ufs_disksubr.c +++ b/sys/ufs/ufs/ufs_disksubr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 - * $Id: ufs_disksubr.c,v 1.38 1998/10/17 07:49:04 bde Exp $ + * $Id: ufs_disksubr.c,v 1.39 1998/12/14 05:37:37 dillon Exp $ */ #include <sys/param.h> @@ -182,7 +182,7 @@ readdisklabel(dev, strat, lp) bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_bcount = lp->d_secsize; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_BUSY | B_READ; + bp->b_flags |= B_READ; (*strat)(bp); if (biowait(bp)) msg = "I/O error"; @@ -286,7 +286,7 @@ writedisklabel(dev, strat, lp) * (also stupid.. how do you write the first one? by raw writes?) */ bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_BUSY | B_READ; + bp->b_flags |= B_READ; (*strat)(bp); error = biowait(bp); if (error) @@ -299,7 +299,7 @@ writedisklabel(dev, strat, lp) dkcksum(dlp) == 0) { *dlp = *lp; bp->b_flags &= ~(B_DONE | B_READ); - bp->b_flags |= B_BUSY | B_WRITE; + bp->b_flags |= B_WRITE; #ifdef __alpha__ alpha_fix_srm_checksum(bp); #endif @@ -315,7 +315,7 @@ done: dlp = (struct disklabel *)bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_BUSY | B_WRITE; + bp->b_flags |= B_WRITE; (*strat)(bp); error = biowait(bp); #endif |