[Midnightbsd-cvs] src [9028] trunk/sys/kern/vfs_bio.c: increment the write ref counter for the buffer object before calling bundirty.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Oct 1 05:44:37 EDT 2016


Revision: 9028
          http://svnweb.midnightbsd.org/src/?rev=9028
Author:   laffer1
Date:     2016-10-01 05:44:37 -0400 (Sat, 01 Oct 2016)
Log Message:
-----------
increment the write ref counter for the buffer object before calling bundirty.

Modified Paths:
--------------
    trunk/sys/kern/vfs_bio.c

Modified: trunk/sys/kern/vfs_bio.c
===================================================================
--- trunk/sys/kern/vfs_bio.c	2016-10-01 09:44:07 UTC (rev 9027)
+++ trunk/sys/kern/vfs_bio.c	2016-10-01 09:44:37 UTC (rev 9028)
@@ -930,7 +930,13 @@
 	else
 		vp_md = 0;
 
-	/* Mark the buffer clean */
+	/*
+	 * Mark the buffer clean.  Increment the bufobj write count
+	 * before bundirty() call, to prevent other thread from seeing
+	 * empty dirty list and zero counter for writes in progress,
+	 * falsely indicating that the bufobj is clean.
+	 */
+	bufobj_wref(bp->b_bufobj);
 	bundirty(bp);
 
 	bp->b_flags &= ~B_DONE;
@@ -938,7 +944,6 @@
 	bp->b_flags |= B_CACHE;
 	bp->b_iocmd = BIO_WRITE;
 
-	bufobj_wref(bp->b_bufobj);
 	vfs_busy_pages(bp, 1);
 
 	/*



More information about the Midnightbsd-cvs mailing list