From 0a084a15e2fcadf30a53e5ce4562b3906de0ff39 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 5 Feb 2005 01:26:14 +0000 Subject: - Don't release BKGRDINPROG until after we've bufdone'd the copy. Sponsored by: Isilon Systems, Inc. --- sys/kern/vfs_bio.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 044e7e1..d36ceae 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -949,20 +949,6 @@ vfs_backgroundwritedone(struct buf *bp) BO_LOCK(bp->b_bufobj); if ((origbp = gbincore(bp->b_bufobj, bp->b_lblkno)) == NULL) panic("backgroundwritedone: lost buffer"); - - /* - * Clear the BV_BKGRDINPROG flag in the original buffer - * and awaken it if it is waiting for the write to complete. - * If BV_BKGRDINPROG is not set in the original buffer it must - * have been released and re-instantiated - which is not legal. - */ - KASSERT((origbp->b_vflags & BV_BKGRDINPROG), - ("backgroundwritedone: lost buffer2")); - origbp->b_vflags &= ~BV_BKGRDINPROG; - if (origbp->b_vflags & BV_BKGRDWAIT) { - origbp->b_vflags &= ~BV_BKGRDWAIT; - wakeup(&origbp->b_xflags); - } BO_UNLOCK(bp->b_bufobj); /* * Process dependencies then return any unfinished ones. @@ -982,6 +968,21 @@ vfs_backgroundwritedone(struct buf *bp) bp->b_flags &= ~(B_CACHE | B_DONE); bp->b_iodone = 0; bufdone(bp); + BO_LOCK(origbp->b_bufobj); + /* + * Clear the BV_BKGRDINPROG flag in the original buffer + * and awaken it if it is waiting for the write to complete. + * If BV_BKGRDINPROG is not set in the original buffer it must + * have been released and re-instantiated - which is not legal. + */ + KASSERT((origbp->b_vflags & BV_BKGRDINPROG), + ("backgroundwritedone: lost buffer2")); + origbp->b_vflags &= ~BV_BKGRDINPROG; + if (origbp->b_vflags & BV_BKGRDWAIT) { + origbp->b_vflags &= ~BV_BKGRDWAIT; + wakeup(&origbp->b_xflags); + } + BO_UNLOCK(origbp->b_bufobj); } /* -- cgit v1.1