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).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-02-21 20:03:52 +00:00
parent 57c418cdd6
commit 9d071e27f1

View File

@ -189,7 +189,8 @@ public:
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 @@ BlockWriter::Add(cached_block* block, hash_iterator* iterator)
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 @@ block_notifier_and_writer(void* /*data*/)
continue;
}
if (!writer.Add(transaction, &iterator))
bool hasLeftOvers;
// we ignore this one
if (!writer.Add(transaction, &iterator, hasLeftOvers))
break;
}
@ -2689,7 +2703,14 @@ cache_sync_transaction(void* _cache, int32 id)
// 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;
}
}
}