Author: axeld Date: 2010-02-21 21:03:52 +0100 (Sun, 21 Feb 2010) New Revision: 35565 Changeset: http://dev.haiku-os.org/changeset/35565/haiku Ticket: http://dev.haiku-os.org/ticket/5415 Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: This should finally nail #5415: * Since the same block can be in up to two transactions, it's very well possible that one shouldn't write all transactions in a single run. * Forgot to pass on the iterator from BlockWriter::Add(transaction) to Add(block). Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-02-21 20:03:37 UTC (rev 35564) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-02-21 20:03:52 UTC (rev 35565) @@ -189,7 +189,8 @@ bool Add(cached_block* block, hash_iterator* iterator = NULL); bool Add(cache_transaction* transaction, - hash_iterator* iterator); + hash_iterator* iterator, + bool& hasLeftOvers); status_t Write(hash_iterator* iterator = NULL, bool canUnlock = true); @@ -1083,16 +1084,27 @@ If no more blocks can be added, false is returned, otherwise true. */ bool -BlockWriter::Add(cache_transaction* transaction, hash_iterator* iterator) +BlockWriter::Add(cache_transaction* transaction, hash_iterator* iterator, + bool& hasLeftOvers) { ASSERT(!transaction->open); - if (transaction->busy_writing_count != 0) + if (transaction->busy_writing_count != 0) { + hasLeftOvers = true; return true; + } + hasLeftOvers = false; + block_list::Iterator blockIterator = transaction->blocks.GetIterator(); while (cached_block* block = blockIterator.Next()) { - if (!Add(block)) + if (!block->CanBeWritten()) { + // This block was already part of a previous transaction within this + // writer + hasLeftOvers = true; + continue; + } + if (!Add(block, iterator)) return false; if (DeletedTransaction()) @@ -2491,7 +2503,9 @@ continue; } - if (!writer.Add(transaction, &iterator)) + bool hasLeftOvers; + // we ignore this one + if (!writer.Add(transaction, &iterator, hasLeftOvers)) break; } @@ -2689,7 +2703,14 @@ // write back all of their remaining dirty blocks T(Action("sync", cache, transaction)); - writer.Add(transaction, &iterator); + bool hasLeftOvers; + writer.Add(transaction, &iterator, hasLeftOvers); + + if (hasLeftOvers) { + // This transaction contains blocks that a previous + // transaction is trying to write back in this write run + hadBusy = true; + } } }