* 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
This commit is contained in:
Axel Dörfler 2008-03-16 15:53:42 +00:00
parent 1f83df03bc
commit d89cda9ff7

View File

@ -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<run_array *> 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;