While the block list was written sorted to the log, the blocks were in

transaction order which caused corrupted disks when a log was replayed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11539 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-03-02 17:55:49 +00:00
parent 4bb67ad318
commit 23b6e06ac6
@@ -261,6 +261,7 @@ Journal::WriteLogEntry()
uint8 *arrayBlock = (uint8 *)array;
// ToDo: the single writes should be combined!
for (int32 size = fArray.BlocksUsed(); size-- > 0;) {
write_pos(fVolume->Device(), logOffset + (logPosition << blockShift),
arrayBlock, fVolume->BlockSize());
@@ -271,13 +272,18 @@ Journal::WriteLogEntry()
// Write logged blocks into the log
cookie = 0;
const uint8 *block;
while (cache_next_block_in_transaction(fVolume->BlockCache(), fTransactionID, &cookie,
NULL, (void **)&block, NULL) == B_OK) {
// ToDo: combine blocks if possible (using iovecs)!
for (int32 i = 0; i < array->count; i++) {
const uint8 *block = (const uint8 *)block_cache_get(fVolume->BlockCache(), array->values[i]);
if (block == NULL) {
FATAL(("Could not get block %Ld\n", array->values[i]));
continue;
}
// ToDo: combine blocks whenever possible (using iovecs)!
write_pos(fVolume->Device(), logOffset + (logPosition << blockShift),
block, fVolume->BlockSize());
block_cache_put(fVolume->BlockCache(), array->values[i]);
logPosition = (logPosition + 1) % fLogSize;
}