class BaseAllocator
Defined at line 34 of file ../../src/storage/blobfs/allocator/base_allocator.h
Base class for managing the blobfs block bitmap and node allocations. Allows for reserving blocks
and nodes without updating the allocations so the reservations are not persisted prematurely.
Public Methods
void BaseAllocator (RawBitmap block_bitmap, std::unique_ptr<id_allocator::IdAllocator> node_bitmap)
Defined at line 31 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void BaseAllocator (RawBitmap block_bitmap, std::unique_ptr<id_allocator::IdAllocator> node_bitmap)
Defined at line 31 of file ../../src/storage/blobfs/allocator/base_allocator.cc
bool CheckBlocksAllocated (uint64_t start_block, uint64_t end_block, uint64_t * out_first_unallocated)
Returns true if [start_block, end_block) is allocated.
If any blocks are unallocated, will set the optional output parameter |out_first_unset| to
the first unallocated block within this range.
Defined at line 35 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void ~BaseAllocator ()
Defined at line 40 of file ../../src/storage/blobfs/allocator/base_allocator.h
zx::result<bool> IsBlockAllocated (uint64_t block_number)
Returns true if the block is allocated. If the block_number is invalid, returns error.
Defined at line 45 of file ../../src/storage/blobfs/allocator/base_allocator.cc
zx_status_t ReserveBlocks (uint64_t num_blocks, std::vector<ReservedExtent> * out_extents)
Reserves space for blocks in memory. Does not update disk.
On success, appends the (possibly non-contiguous) region of allocated blocks to |out_extents|.
On failure, |out_extents| is cleared.
Defined at line 52 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void MarkBlocksAllocated (const ReservedExtent & reserved_extent)
Marks blocks as allocated which have previously been reserved.
Defined at line 72 of file ../../src/storage/blobfs/allocator/base_allocator.cc
ReservedExtent FreeBlocks (const Extent & extent)
Frees blocks which have already been allocated (in-memory).
|extent| must represent a portion of the block map which has already been allocated. Returns a
ReservedExtent which keeps the blocks reserved until destroyed (which allows us to hold the
blocks until the transaction commits).
Defined at line 81 of file ../../src/storage/blobfs/allocator/base_allocator.cc
zx_status_t ReserveNodes (uint64_t num_nodes, std::vector<ReservedNode> * out_nodes)
Reserves space for nodes in memory. Does not update disk.
On success, appends the (possibly non-contiguous) nodes to |out_nodes|. On failure, |out_nodes|
is cleared.
Defined at line 92 of file ../../src/storage/blobfs/allocator/base_allocator.cc
zx::result<ReservedNode> ReserveNode ()
blobfs::NodeReserverInterface interface.
Defined at line 104 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void UnreserveNode (ReservedNode node)
Defined at line 169 of file ../../src/storage/blobfs/allocator/base_allocator.cc
uint64_t ReservedNodeCount ()
Defined at line 176 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void MarkInodeAllocated (ReservedNode node)
Marks a reserved node by updating the node map to indicate it is an allocated inode.
Defined at line 124 of file ../../src/storage/blobfs/allocator/base_allocator.cc
zx_status_t MarkContainerNodeAllocated (ReservedNode node, uint32_t previous_node_index)
Marks a reserved node by updating the node map to indicate it is an allocated extent container.
Makes |node| follow |previous_node_index| in the extent container list.
Defined at line 138 of file ../../src/storage/blobfs/allocator/base_allocator.cc
void MarkNodeAllocated (uint32_t node_index)
Mark a node allocated. The node may or may not be reserved.
Defined at line 120 of file ../../src/storage/blobfs/allocator/base_allocator.cc
zx_status_t FreeNode (uint32_t node_index)
Frees a node which has already been committed. Returns an error if the node could not be freed.
Defined at line 160 of file ../../src/storage/blobfs/allocator/base_allocator.cc
std::vector<BlockRegion> GetAllocatedRegions ()
Record the location and size of all non-free block regions.
Defined at line 365 of file ../../src/storage/blobfs/allocator/base_allocator.cc
Protected Methods
zx::result<> AddBlocks (uint64_t block_count)
Requests that blobfs increase the size of it's data section by |block_count| blocks.
zx::result<> AddNodes ()
Requests that blobfs increase the size of it's node map.
RawBitmap & GetBlockBitmap ()
Defined at line 102 of file ../../src/storage/blobfs/allocator/base_allocator.h
const RawBitmap & GetBlockBitmap ()
Defined at line 103 of file ../../src/storage/blobfs/allocator/base_allocator.h
id_allocator::IdAllocator & GetNodeBitmap ()
Defined at line 104 of file ../../src/storage/blobfs/allocator/base_allocator.h
const id_allocator::IdAllocator & GetNodeBitmap ()
Defined at line 105 of file ../../src/storage/blobfs/allocator/base_allocator.h