From 5b58f2f951911f1075788268f99efccf1dba60eb Mon Sep 17 00:00:00 2001 From: mckusick Date: Sat, 26 Jun 1999 02:47:16 +0000 Subject: 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. --- sys/kern/kern_physio.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'sys/kern/kern_physio.c') diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 5f685b5..2208319 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: kern_physio.c,v 1.33 1999/05/07 07:03:39 phk Exp $ + * $Id: kern_physio.c,v 1.34 1999/05/08 06:39:37 phk Exp $ */ #include @@ -68,17 +68,10 @@ physio(strategy, bp, dev, rw, minp, uio) /* create and build a buffer header for a transfer */ bpa = (struct buf *)phygetvpbuf(dev, uio->uio_resid); - if (!bp_alloc) { - spl = splbio(); - while (bp->b_flags & B_BUSY) { - bp->b_flags |= B_WANTED; - tsleep((caddr_t)bp, PRIBIO, "physbw", 0); - } - bp->b_flags |= B_BUSY; - splx(spl); - } else { + if (!bp_alloc) + BUF_LOCK(bp, LK_EXCLUSIVE); + else bp = bpa; - } /* * get a copy of the kva from the physical buffer @@ -86,12 +79,12 @@ physio(strategy, bp, dev, rw, minp, uio) sa = bpa->b_data; error = bp->b_error = 0; - for(i=0;iuio_iovcnt;i++) { - while( uio->uio_iov[i].iov_len) { + for (i = 0; i < uio->uio_iovcnt; i++) { + while (uio->uio_iov[i].iov_len) { bp->b_dev = dev; bp->b_bcount = uio->uio_iov[i].iov_len; - bp->b_flags = B_BUSY | B_PHYS | B_CALL | bufflags; + bp->b_flags = B_PHYS | B_CALL | bufflags; bp->b_iodone = physwakeup; bp->b_data = uio->uio_iov[i].iov_base; bp->b_bcount = minp( bp); @@ -160,11 +153,8 @@ physio(strategy, bp, dev, rw, minp, uio) doerror: relpbuf(bpa, NULL); if (!bp_alloc) { - bp->b_flags &= ~(B_BUSY|B_PHYS); - if( bp->b_flags & B_WANTED) { - bp->b_flags &= ~B_WANTED; - wakeup((caddr_t)bp); - } + bp->b_flags &= ~B_PHYS; + BUF_UNLOCK(bp); } /* * Allow the process UPAGES to be swapped again. -- cgit v1.1