- if (options & kLockTransaction) {
-
- /*
- *
- * Set the B_LOCKED flag and unlock the buffer, causing brelse to move
- * the buffer onto the LOCKED free list. This is necessary, otherwise
- * getnewbuf() would try to reclaim the buffers using bawrite, which
- * isn't going to work.
- *
- */
- bp->b_flags |= B_LOCKED;
- };
- bdwrite(bp);
+ if (options & kLockTransaction) {
+ /*
+ *
+ * Set the B_LOCKED flag and unlock the buffer, causing brelse to move
+ * the buffer onto the LOCKED free list. This is necessary, otherwise
+ * getnewbuf() would try to reclaim the buffers using bawrite, which
+ * isn't going to work.
+ *
+ */
+ extern int count_lock_queue __P((void));
+ /* Don't hog all the buffers... */
+ if (count_lock_queue() > kMaxLockedMetaBuffers) {
+ hfs_btsync(vp, HFS_SYNCTRANS);
+ /* Rollback sync time to cause a sync on lock release... */
+ (void) BTSetLastSync(VTOF(vp), time.tv_sec - (kMaxSecsForFsync + 1));
+ }
+ bp->b_flags |= B_LOCKED;
+ }
+ /*
+ * Delay-write this block.
+ * If the maximum delayed buffers has been exceeded then
+ * free up some buffers and fall back to an asynchronous write.
+ */
+ if (bdwrite_internal(bp, 1) != 0) {
+ hfs_btsync(vp, 0);
+ /* Rollback sync time to cause a sync on lock release... */
+ (void) BTSetLastSync(VTOF(vp), time.tv_sec - (kMaxSecsForFsync + 1));
+ bp->b_flags &= ~B_LOCKED;
+ bawrite(bp);
+ }