From d89cda9ff7655a5847beaa8c83cf9fb97f765d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 16 Mar 2008 15:53:42 +0000 Subject: [PATCH] * Fixed another big bug in the logging code: I obviously got confused what RunArrays::Length() meant; it should have been the length of a log entry, but was only the block count. * Now I've improved naming and fixed initializing the LogEntry with a wrong size, causing subsequent log entries to lose track in the log (the log_start pointer got wrong, so BFS would not be able to replay such a log). * This at least fixes one part of the problem of bug #1911. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24410 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Journal.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Journal.cpp b/src/add-ons/kernel/file_systems/bfs/Journal.cpp index 25dc47e078..74161527ea 100644 --- a/src/add-ons/kernel/file_systems/bfs/Journal.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Journal.cpp @@ -36,13 +36,14 @@ class RunArrays { RunArrays(Journal *journal); ~RunArrays(); - uint32 Length() const { return fLength; } - status_t Insert(off_t blockNumber); run_array *ArrayAt(int32 i) { return fArrays.Array()[i]; } int32 CountArrays() const { return fArrays.CountItems(); } + uint32 CountBlocks() const { return fBlockCount; } + uint32 LogEntryLength() const { return CountBlocks() + CountArrays(); } + int32 MaxArrayLength(); private: @@ -51,7 +52,7 @@ class RunArrays { bool _AddRun(block_run &run); Journal *fJournal; - uint32 fLength; + uint32 fBlockCount; Stack fArrays; run_array *fLastArray; }; @@ -213,7 +214,7 @@ run_array::_FindInsertionIndex(block_run &run) RunArrays::RunArrays(Journal *journal) : fJournal(journal), - fLength(0), + fBlockCount(0), fArrays(), fLastArray(NULL) { @@ -266,7 +267,7 @@ RunArrays::_AddRun(block_run &run) return false; fLastArray->Insert(run); - fLength++; + fBlockCount++; return true; } @@ -639,7 +640,7 @@ Journal::_WriteTransactionToLog() } } - if (runArrays.Length() == 0) { + if (runArrays.CountBlocks() == 0) { // nothing has changed during this transaction if (detached) { fTransactionID = cache_detach_sub_transaction(fVolume->BlockCache(), @@ -729,7 +730,7 @@ Journal::_WriteTransactionToLog() free(vecs); LogEntry *logEntry = new LogEntry(this, fVolume->LogEnd(), - runArrays.Length()); + runArrays.LogEntryLength()); if (logEntry == NULL) { FATAL(("no memory to allocate log entries!")); return B_NO_MEMORY;