]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_readwrite.c
xnu-344.32.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_readwrite.c
index 6f0311411a8af16e6a32141c64f3c232562ea658..e7fba04137416943204f3ba9c723f0c69dc798a3 100644 (file)
@@ -998,6 +998,7 @@ hfs_cmap(ap)
                return (0);
 
        p = current_proc();
+  retry:
        if (fp->ff_unallocblocks) {
                lockExtBtree = 1;
 
@@ -1036,6 +1037,22 @@ hfs_cmap(ap)
        if (fp->ff_unallocblocks) {
                SInt64 reqbytes, actbytes;
 
+               //
+               // Make sure we have a transaction.  It's possible
+               // that we came in and fp->ff_unallocblocks was zero
+               // but during the time we blocked acquiring the extents
+               // btree, ff_unallocblocks became non-zero and so we
+               // will need to start a transaction.
+               //
+               if (hfsmp->jnl && started_tr == 0) {
+                   if (lockExtBtree) {
+                       (void) hfs_metafilelocking(hfsmp, kHFSExtentsFileID, LK_RELEASE, p);
+                       lockExtBtree = 0;
+                   }
+    
+                   goto retry;
+               }
+
                reqbytes = (SInt64)fp->ff_unallocblocks *
                             (SInt64)HFSTOVCB(hfsmp)->blockSize;
                /*