[Midnightbsd-cvs] src [8940] trunk/sys/kern/vfs_bio.c: make recursive getblk slightly more useful

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 26 19:07:19 EDT 2016


Revision: 8940
          http://svnweb.midnightbsd.org/src/?rev=8940
Author:   laffer1
Date:     2016-09-26 19:07:19 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
make recursive getblk slightly more useful

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

Modified: trunk/sys/kern/vfs_bio.c
===================================================================
--- trunk/sys/kern/vfs_bio.c	2016-09-26 23:06:55 UTC (rev 8939)
+++ trunk/sys/kern/vfs_bio.c	2016-09-26 23:07:19 UTC (rev 8940)
@@ -1252,6 +1252,15 @@
 	KASSERT(!(bp->b_flags & (B_CLUSTER|B_PAGING)),
 	    ("brelse: inappropriate B_PAGING or B_CLUSTER bp %p", bp));
 
+	if (BUF_LOCKRECURSED(bp)) {
+		/*
+		 * Do not process, in particular, do not handle the
+		 * B_INVAL/B_RELBUF and do not release to free list.
+		 */
+		BUF_UNLOCK(bp);
+		return;
+	}
+
 	if (bp->b_flags & B_MANAGED) {
 		bqrelse(bp);
 		return;
@@ -1428,12 +1437,6 @@
 			brelvp(bp);
 	}
 			
-	if (BUF_LOCKRECURSED(bp)) {
-		/* do not release to free list */
-		BUF_UNLOCK(bp);
-		return;
-	}
-
 	/* enqueue */
 	mtx_lock(&bqlock);
 	/* Handle delayed bremfree() processing. */
@@ -2683,6 +2686,9 @@
 		/* We timed out or were interrupted. */
 		else if (error)
 			return (NULL);
+		/* If recursed, assume caller knows the rules. */
+		else if (BUF_LOCKRECURSED(bp))
+			goto end;
 
 		/*
 		 * The buffer is locked.  B_CACHE is cleared if the buffer is 
@@ -2862,6 +2868,7 @@
 	}
 	CTR4(KTR_BUF, "getblk(%p, %ld, %d) = %p", vp, (long)blkno, size, bp);
 	BUF_ASSERT_HELD(bp);
+end:
 	KASSERT(bp->b_bufobj == bo,
 	    ("bp %p wrong b_bufobj %p should be %p", bp, bp->b_bufobj, bo));
 	return (bp);



More information about the Midnightbsd-cvs mailing list