Author: kib
Date: Wed Mar 13 10:04:47 2013
New Revision: 248234
URL: http://svnweb.freebsd.org/changeset/base/248234

Log:
  MFC r247389:
  Make recursive getblk() slightly more useful.

Modified:
  stable/9/sys/kern/vfs_bio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_bio.c
==============================================================================
--- stable/9/sys/kern/vfs_bio.c Wed Mar 13 10:01:05 2013        (r248233)
+++ stable/9/sys/kern/vfs_bio.c Wed Mar 13 10:04:47 2013        (r248234)
@@ -1252,6 +1252,15 @@ brelse(struct buf *bp)
        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 @@ brelse(struct buf *bp)
                        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 @@ loop:
                /* 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 @@ loop:
        }
        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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to