From 6c62b2acd07bf6e6011a4fd5a563fc030d71f500 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Mon, 9 Jan 2006 19:32:21 +0000 Subject: [PATCH] If the lock passed to getdirtybuf() is the softdep lock then the background write completed wakeup could be missed. Close the race by grabbing the lock normally used for protection of bp->b_xflags. Reviewed by: truckman --- sys/ufs/ffs/ffs_softdep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 088b4fea2c0..d60fe111cf5 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -5901,6 +5901,19 @@ getdirtybuf(bp, mtx, waitfor) return (NULL); } if ((bp->b_vflags & BV_BKGRDINPROG) != 0) { + if (mtx == &lk && waitfor == MNT_WAIT) { + mtx_unlock(mtx); + BO_LOCK(bp->b_bufobj); + BUF_UNLOCK(bp); + if ((bp->b_vflags & BV_BKGRDINPROG) != 0) { + bp->b_vflags |= BV_BKGRDWAIT; + msleep(&bp->b_xflags, BO_MTX(bp->b_bufobj), + PRIBIO | PDROP, "getbuf", 0); + } else + BO_UNLOCK(bp->b_bufobj); + mtx_lock(mtx); + return (NULL); + } BUF_UNLOCK(bp); if (waitfor != MNT_WAIT) return (NULL);