* For whatever weird reason, BFS apparently restricts a log entry to 126

entries, even though many more could fit in the blog. This fixes mounting
  a dirty (original-)BFS volume with a block size larger than 1024 bytes,
  and probably vice versa.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24401 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-03-15 16:25:55 +00:00
parent 6cc5885822
commit f426071223
@@ -24,8 +24,7 @@ struct run_array {
// that -1 accounts for an off-by-one error in Be's BFS implementation // that -1 accounts for an off-by-one error in Be's BFS implementation
const block_run &RunAt(int32 i) const { return runs[i]; } const block_run &RunAt(int32 i) const { return runs[i]; }
static int32 MaxRuns(int32 blockSize) static int32 MaxRuns(int32 blockSize);
{ return (blockSize - sizeof(run_array)) / sizeof(block_run); }
private: private:
static int _Compare(block_run &a, block_run &b); static int _Compare(block_run &a, block_run &b);
@@ -152,6 +151,18 @@ run_array::Insert(block_run &run)
} }
/*static*/ int32
run_array::MaxRuns(int32 blockSize)
{
// For whatever reason, BFS restricts the maximum array size
uint32 maxCount = (blockSize - sizeof(run_array)) / sizeof(block_run);
if (maxCount < 128)
return maxCount;
return 127;
}
/*static*/ int /*static*/ int
run_array::_Compare(block_run &a, block_run &b) run_array::_Compare(block_run &a, block_run &b)
{ {
@@ -424,8 +435,10 @@ Journal::_ReplayRunArray(int32 *_start)
if (offset == 0) { if (offset == 0) {
// This log entry writes over the super block - check if // This log entry writes over the super block - check if
// it's valid! // it's valid!
if (Volume::CheckSuperBlock(data) != B_OK) if (Volume::CheckSuperBlock(data) != B_OK) {
FATAL(("Log contains invalid super block!\n"));
RETURN_ERROR(B_BAD_DATA); RETURN_ERROR(B_BAD_DATA);
}
} }
ssize_t written = write_pos(fVolume->Device(), offset, data, ssize_t written = write_pos(fVolume->Device(), offset, data,