BTRFS: Refix ticket #12788

* Change block size to node size. Block is not always the same as sector.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
hyche 2017-06-09 17:47:40 +07:00 committed by Adrien Destugues
parent 299aba38f0
commit d87124efad
2 changed files with 4 additions and 17 deletions

View File

@ -164,22 +164,9 @@ BTree::_Find(btrfs_key& key, void** _value, size_t* _size,
if (_value != NULL) {
*_value = malloc(stream->entries[i].Size());
uint32 totalOffset = stream->entries[i].Offset() + sizeof(btrfs_header);
if ((fVolume->BlockSize() - totalOffset % fVolume->BlockSize())
>= stream->entries[i].Size()) {
//If there is enough space for *_value
memcpy(*_value, ((uint8*)cached.SetTo(physical
+ totalOffset / fVolume->BlockSize())
+ totalOffset % fVolume->BlockSize()),
stream->entries[i].Size());
} else {
read_pos(fVolume->Device(), physical
* fVolume->BlockSize() + totalOffset,
*_value, stream->entries[i].Size());
}
memcpy(*_value, ((uint8 *)&stream->entries[0]
+ stream->entries[i].Offset()),
stream->entries[i].Size());
key.SetOffset(stream->entries[i].key.Offset());
if (_size != NULL)
*_size = stream->entries[i].Size();

View File

@ -177,7 +177,7 @@ struct btrfs_super_block {
bool IsValid();
// implemented in Volume.cpp
uint64 TotalSize() const { return B_LENDIAN_TO_HOST_INT64(total_size); }
uint32 BlockSize() const { return B_LENDIAN_TO_HOST_INT32(sector_size); }
uint32 BlockSize() const { return B_LENDIAN_TO_HOST_INT32(node_size); }
uint64 RootDirObjectID() const
{ return B_LENDIAN_TO_HOST_INT64(root_dir_object_id); }
uint64 Generation() const