* Build fix for the boot loader (it's now using the new utility functions as

well). Sorry!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33560 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-12 19:42:50 +00:00
parent daff73b116
commit 361f5cdfaf
4 changed files with 43 additions and 32 deletions
@@ -1790,7 +1790,7 @@ BlockAllocator::CheckInode(Inode* inode, check_control* control)
if (status != B_OK) if (status != B_OK)
return status; return status;
int32 runsPerBlock = runs_per_block(fVolume); int32 runsPerBlock = runs_per_block(fVolume->BlockSize());
int32 runsPerArray = runsPerBlock * data->double_indirect.Length(); int32 runsPerArray = runsPerBlock * data->double_indirect.Length();
CachedBlock cachedDirect(fVolume); CachedBlock cachedDirect(fVolume);
+13 -10
View File
@@ -1327,8 +1327,8 @@ Inode::AllocatedSize() const
if (data.MaxDoubleIndirectRange() != 0) { if (data.MaxDoubleIndirectRange() != 0) {
off_t doubleIndirectSize = data.MaxDoubleIndirectRange() off_t doubleIndirectSize = data.MaxDoubleIndirectRange()
- data.MaxIndirectRange(); - data.MaxIndirectRange();
int32 indirectSize = double_indirect_max_indirect_size(fVolume, int32 indirectSize = double_indirect_max_indirect_size(
data.double_indirect.Length()); data.double_indirect.Length(), fVolume->BlockSize());
size += (2 * data.double_indirect.Length() size += (2 * data.double_indirect.Length()
+ doubleIndirectSize / indirectSize) + doubleIndirectSize / indirectSize)
@@ -1372,8 +1372,8 @@ Inode::FindBlockRun(off_t pos, block_run& run, off_t& offset)
int32 runsPerBlock; int32 runsPerBlock;
int32 directSize; int32 directSize;
int32 indirectSize; int32 indirectSize;
get_double_indirect_sizes(fVolume, data->double_indirect.Length(), get_double_indirect_sizes(data->double_indirect.Length(),
runsPerBlock, directSize, indirectSize); fVolume->BlockSize(), runsPerBlock, directSize, indirectSize);
off_t start = pos - data->MaxIndirectRange(); off_t start = pos - data->MaxIndirectRange();
int32 index = start / indirectSize; int32 index = start / indirectSize;
@@ -1855,8 +1855,8 @@ Inode::_GrowStream(Transaction& transaction, off_t size)
int32 runsPerBlock; int32 runsPerBlock;
int32 directSize; int32 directSize;
int32 indirectSize; int32 indirectSize;
get_double_indirect_sizes(fVolume, data->double_indirect.Length(), get_double_indirect_sizes(data->double_indirect.Length(),
runsPerBlock, directSize, indirectSize); fVolume->BlockSize(), runsPerBlock, directSize, indirectSize);
off_t start = data->MaxDoubleIndirectRange() off_t start = data->MaxDoubleIndirectRange()
- data->MaxIndirectRange(); - data->MaxIndirectRange();
@@ -1957,10 +1957,13 @@ Inode::_FreeStaticStreamArray(Transaction& transaction, int32 level,
block_run run, off_t size, off_t offset, off_t& max) block_run run, off_t size, off_t offset, off_t& max)
{ {
int32 indirectSize; int32 indirectSize;
if (level == 0) if (level == 0) {
indirectSize = double_indirect_max_indirect_size(fVolume, run.Length()); indirectSize = double_indirect_max_indirect_size(run.Length(),
else fVolume->BlockSize());
indirectSize = double_indirect_max_direct_size(fVolume, run.Length()); } else {
indirectSize = double_indirect_max_direct_size(run.Length(),
fVolume->BlockSize());
}
off_t start; off_t start;
if (size > offset) if (size > offset)
+15 -11
View File
@@ -8,7 +8,7 @@
#include "system_dependencies.h" #include "system_dependencies.h"
#include "Volume.h" #include "bfs.h"
enum inode_type { enum inode_type {
@@ -96,33 +96,37 @@ get_shift(uint64 i)
inline int32 inline int32
runs_per_block(Volume* volume) runs_per_block(uint32 blockSize)
{ {
return volume->BlockSize() / sizeof(block_run); #ifdef _BOOT_MODE
using namespace BFS;
#endif
return blockSize / sizeof(struct block_run);
} }
inline int32 inline int32
double_indirect_max_direct_size(Volume* volume, uint32 baseLength) double_indirect_max_direct_size(uint32 baseLength, uint32 blockSize)
{ {
return baseLength << volume->BlockShift(); return baseLength * blockSize;
} }
inline int32 inline int32
double_indirect_max_indirect_size(Volume* volume, uint32 baseLength) double_indirect_max_indirect_size(uint32 baseLength, uint32 blockSize)
{ {
return baseLength * double_indirect_max_direct_size(volume, baseLength) return baseLength * double_indirect_max_direct_size(baseLength, blockSize)
* runs_per_block(volume); * runs_per_block(blockSize);
} }
inline void inline void
get_double_indirect_sizes(Volume* volume, uint32 baseLength, get_double_indirect_sizes(uint32 baseLength, uint32 blockSize,
int32& runsPerBlock, int32& directSize, int32& indirectSize) int32& runsPerBlock, int32& directSize, int32& indirectSize)
{ {
runsPerBlock = runs_per_block(volume); runsPerBlock = runs_per_block(blockSize);
directSize = double_indirect_max_direct_size(volume, baseLength); directSize = double_indirect_max_direct_size(baseLength, blockSize);
indirectSize = baseLength * directSize * runsPerBlock; indirectSize = baseLength * directSize * runsPerBlock;
} }
@@ -1,8 +1,10 @@
/* Stream - inode stream access functions /*
** * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * This file may be used under the terms of the MIT License.
** Distributed under the terms of the OpenBeOS License. */
*/
//! Inode stream access functions
#include "Stream.h" #include "Stream.h"
@@ -200,12 +202,14 @@ Stream::FindBlockRun(off_t pos, block_run &run, off_t &offset)
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
int32 runsPerBlock;
int32 directSize;
int32 indirectSize;
get_double_indirect_sizes(data.double_indirect.Length(),
cached.BlockSize(), runsPerBlock, directSize, indirectSize);
off_t start = pos - data.MaxIndirectRange(); off_t start = pos - data.MaxIndirectRange();
int32 indirectSize = (1L << (INDIRECT_BLOCKS_SHIFT + cached.BlockShift()))
* (fVolume.BlockSize() / sizeof(block_run));
int32 directSize = NUM_ARRAY_BLOCKS << cached.BlockShift();
int32 index = start / indirectSize; int32 index = start / indirectSize;
int32 runsPerBlock = cached.BlockSize() / sizeof(block_run);
block_run *indirect = (block_run *)cached.SetTo( block_run *indirect = (block_run *)cached.SetTo(
fVolume.ToBlock(data.double_indirect) + index / runsPerBlock); fVolume.ToBlock(data.double_indirect) + index / runsPerBlock);