BTRFS: Implement GetNewBlock() function that will find the logical address for allocating and convert it to physical block.

Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
hyche
2017-12-10 11:02:57 -05:00
committed by Augustin Cavalier
parent c1320b3a33
commit 4368661f03
2 changed files with 17 additions and 0 deletions
@@ -534,6 +534,20 @@ Volume::FindBlock(off_t logical, off_t& physical)
}
/* Wrapper function for allocating new block
*/
status_t
Volume::GetNewBlock(uint64& logical, fsblock_t& physical, uint64 start,
uint64 flags)
{
status_t status = fExtentAllocator->AllocateTreeBlock(logical, start, flags);
if (status != B_OK)
return status;
return FindBlock(logical, physical);
}
// #pragma mark - Disk scanning and initialization
@@ -62,6 +62,9 @@ public:
status_t FindBlock(off_t logical, fsblock_t& physical);
status_t FindBlock(off_t logical, off_t& physical);
status_t GetNewBlock(uint64& logical, fsblock_t& physical,
uint64 start = (uint64)-1,
uint64 flags = BTRFS_BLOCKGROUP_FLAG_METADATA);
private:
mutex fLock;