From 23b6e06ac62c43eedcff6729b0a526568e5fd142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Mar 2005 17:55:49 +0000 Subject: [PATCH] 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 --- src/add-ons/kernel/file_systems/bfs/Journal.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index a86cfc8537..120a121fc3 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -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; }