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

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
hyche 2017-08-24 02:02:17 +07:00 committed by Augustin Cavalier
parent c1320b3a33
commit 4368661f03
2 changed files with 17 additions and 0 deletions

View File

@ -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 // #pragma mark - Disk scanning and initialization

View File

@ -62,6 +62,9 @@ public:
status_t FindBlock(off_t logical, fsblock_t& physical); status_t FindBlock(off_t logical, fsblock_t& physical);
status_t FindBlock(off_t logical, off_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: private:
mutex fLock; mutex fLock;