pub struct ChunkMap { /* private fields */ }Expand description
The chunk-tree logical→physical map: the union of every CHUNK_ITEM’s span and its physical placement. Covers single-device profiles (SINGLE/DUP); for DUP the first stripe (first mirror) is returned.
Implementations§
Source§impl ChunkMap
impl ChunkMap
Sourcepub fn add_from_node(&mut self, node: &Node)
pub fn add_from_node(&mut self, node: &Node)
Add every CHUNK_ITEM found in a chunk-tree leaf node to the map.
Sourcepub fn logical_to_physical(&self, logical: u64) -> Option<(u64, u64)>
pub fn logical_to_physical(&self, logical: u64) -> Option<(u64, u64)>
Translate a logical address to (devid, physical_byte) on the first
stripe’s device, for single-device single/DUP chunks. Returns None if
no chunk covers logical, or the covering chunk has no stripe.
Sourcepub fn walk(image: &[u8], sb: &Superblock) -> Result<Self, BtrfsError>
pub fn walk(image: &[u8], sb: &Superblock) -> Result<Self, BtrfsError>
Build the full chunk map by bootstrapping from the superblock’s
sys_chunk_array and walking the chunk tree from sb.chunk_root.
The sys_chunk_array covers the chunk_root’s own logical range (that is
its whole purpose), so chunk_root is reachable; each subsequently read
node’s blockptrs are translated through the map built so far (the
chunk tree is self-describing). On the oracle the chunk tree is a single
leaf, but interior nodes are followed recursively (bounded).
§Errors
BtrfsError::Truncatedifsb.chunk_rootcannot be translated to a readable node withinimage(a failed bootstrap is loud, never an empty map — see the Paranoid Gatekeeper standard).