BTRFS: BlockNum -> LogicalAddress to prevent misunderstanding

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
hyche 2017-06-22 19:59:58 +07:00 committed by Adrien Destugues
parent 91d7f850cf
commit 7568abd559
4 changed files with 24 additions and 21 deletions

View File

@ -209,19 +209,19 @@ BTree::_Find(btrfs_key& key, void** _value, size_t* _size,
for (; i < stream->header.ItemCount(); i++) {
int32 comp = key.Compare(stream->index[i].key);
TRACE("Find() found index %" B_PRIu32 " at %" B_PRId64 " comp %"
B_PRId32 "\n", i, stream->index[i].BlockNum(), comp);
B_PRId32 "\n", i, stream->index[i].LogicalAddress(), comp);
if (comp > 0)
continue;
if (comp < 0 || type == BTREE_BACKWARD)
break;
}
TRACE("Find() getting index %" B_PRIu32 " at %" B_PRId64 "\n", i - 1,
stream->index[i - 1].BlockNum());
stream->index[i - 1].LogicalAddress());
if (fVolume->FindBlock(stream->index[i - 1].BlockNum(), physical)
if (fVolume->FindBlock(stream->index[i - 1].LogicalAddress(), physical)
!= B_OK) {
ERROR("Find() unmapped block %" B_PRId64 "\n",
stream->index[i - 1].BlockNum());
stream->index[i - 1].LogicalAddress());
return B_ERROR;
}
stream = (btrfs_stream*)cached.SetTo(physical);

View File

@ -48,8 +48,8 @@ public:
~BNode();
// just return from Header
uint64 BlockNum() const
{ return fNode->header.BlockNum(); }
uint64 LogicalAddress() const
{ return fNode->header.LogicalAddress(); }
uint64 Flags() const
{ return fNode->header.Flags(); }
uint64 Generation() const
@ -77,7 +77,7 @@ public:
void SetToWritable(off_t block,
int32 transactionId, bool empty);
off_t BlockNumber() const { return fBlockNumber; }
off_t BlockNum() const { return fBlockNumber;}
bool IsWritable() const { return fWritable; }
int32 SearchSlot(const btrfs_key& key, int* slot) const;

View File

@ -344,8 +344,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
return B_ERROR;
}
TRACE("Volume::Mount(): Found extent root: %" B_PRIu64 "\n",
root->BlockNum());
fExtentTree = new(std::nothrow) BTree(this, root->BlockNum());
root->LogicalAddress());
fExtentTree = new(std::nothrow) BTree(this, root->LogicalAddress());
free(root);
if (fExtentTree == NULL)
return B_NO_MEMORY;
@ -356,8 +356,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
ERROR("Volume::Mount(): Couldn't find fs root\n");
return B_ERROR;
}
TRACE("Volume::Mount(): Found fs root: %" B_PRIu64 "\n", root->BlockNum());
fFSTree = new(std::nothrow) BTree(this, root->BlockNum());
TRACE("Volume::Mount(): Found fs root: %" B_PRIu64 "\n", root->LogicalAddress());
fFSTree = new(std::nothrow) BTree(this, root->LogicalAddress());
free(root);
if (fFSTree == NULL)
return B_NO_MEMORY;
@ -369,8 +369,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
return B_ERROR;
}
TRACE("Volume::Mount(): Found dev root: %" B_PRIu64 "\n",
root->BlockNum());
fDevTree = new(std::nothrow) BTree(this, root->BlockNum());
root->LogicalAddress());
fDevTree = new(std::nothrow) BTree(this, root->LogicalAddress());
free(root);
if (fDevTree == NULL)
return B_NO_MEMORY;
@ -382,8 +382,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
return B_ERROR;
}
TRACE("Volume::Mount(): Found checksum root: %" B_PRIu64 "\n",
root->BlockNum());
fChecksumTree = new(std::nothrow) BTree(this, root->BlockNum());
root->LogicalAddress());
fChecksumTree = new(std::nothrow) BTree(this, root->LogicalAddress());
free(root);
if (fChecksumTree == NULL)
return B_NO_MEMORY;

View File

@ -40,14 +40,15 @@ struct btrfs_timespec {
struct btrfs_header {
uint8 checksum[32];
uint8 fsid[16];
uint64 blocknum;
uint64 logical_address;
uint64 flags;
uint8 chunk_tree_uuid[16];
uint64 generation;
uint64 owner;
uint32 item_count;
uint8 level;
uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); }
uint64 LogicalAddress() const
{ return B_LENDIAN_TO_HOST_INT64(logical_address); }
uint64 Flags() const { return B_LENDIAN_TO_HOST_INT64(flags); }
uint64 Generation() const
{ return B_LENDIAN_TO_HOST_INT64(generation); }
@ -61,9 +62,10 @@ struct btrfs_header {
struct btrfs_index {
btrfs_key key;
uint64 blocknum;
uint64 logical_address;
uint64 generation;
uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); }
uint64 LogicalAddress() const
{ return B_LENDIAN_TO_HOST_INT64(logical_address); }
uint64 Generation() const
{ return B_LENDIAN_TO_HOST_INT64(generation); }
} _PACKED;
@ -241,7 +243,7 @@ struct btrfs_root {
btrfs_inode inode;
uint64 generation;
uint64 root_dirid;
uint64 blocknum;
uint64 logical_address;
uint64 limit_bytes;
uint64 used_bytes;
uint64 last_snapshot;
@ -252,7 +254,8 @@ struct btrfs_root {
uint8 level;
uint64 Generation() const
{ return B_LENDIAN_TO_HOST_INT64(generation); }
uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); }
uint64 LogicalAddress() const
{ return B_LENDIAN_TO_HOST_INT64(logical_address); }
} _PACKED;