Skip to main content

ExtentItem

Struct ExtentItem 

Source
pub struct ExtentItem {
    pub refs: u64,
    pub generation: u64,
    pub flags: ExtentFlags,
    pub tree_block_key: Option<DiskKey>,
    pub tree_block_level: Option<u8>,
    pub skinny_level: Option<u64>,
    pub inline_refs: Vec<InlineRef>,
}
Expand description

Extent allocation record from the extent tree.

Tracks reference counts, ownership, and backreferences for a contiguous range of allocated disk space. Used for both data extents (EXTENT_ITEM) and metadata blocks (METADATA_ITEM with skinny metadata).

Fields§

§refs: u64

Number of references to this extent.

§generation: u64

Generation when this extent was allocated.

§flags: ExtentFlags

Whether this extent holds data or a tree block.

§tree_block_key: Option<DiskKey>

For non-skinny tree block extents: the first key in the block.

§tree_block_level: Option<u8>

For non-skinny tree block extents: the block’s tree level.

§skinny_level: Option<u64>

For skinny metadata items: the tree level (from the key offset).

§inline_refs: Vec<InlineRef>

Inline backreferences packed after the extent header.

Implementations§

Source§

impl ExtentItem

Source

pub const SKINNY_SIZE: usize = 33

Size of a skinny metadata extent item with one TREE_BLOCK_REF.

Layout: extent header (24) + inline ref type (1) + offset (8) = 33.

Source

pub const NON_SKINNY_SIZE: usize = 51

Size of a non-skinny metadata extent item with tree_block_info and one TREE_BLOCK_REF.

Layout: extent header (24) + tree_block_info (18) + inline ref (9) = 51.

Source

pub const DATA_INLINE_SIZE: usize = 53

Size of a data extent item with one inline EXTENT_DATA_REF.

Layout: extent header (24) + inline ref type (1) + data ref (28) = 53.

Source

pub fn is_data(&self) -> bool

Returns true if this extent holds file data.

Source

pub fn is_tree_block(&self) -> bool

Returns true if this extent holds a metadata tree block.

Source

pub fn parse(data: &[u8], key: &DiskKey) -> Option<Self>

Parse an extent item from a raw byte buffer, using the item key to determine whether this is a skinny metadata item or a full extent item.

Source

pub fn to_bytes_skinny(refs: u64, generation: u64, root_id: u64) -> Vec<u8>

Serialize a skinny metadata extent item (METADATA_ITEM) with a single TREE_BLOCK_REF inline backref (33 bytes).

Source

pub fn to_bytes_non_skinny( refs: u64, generation: u64, root_id: u64, first_key: &DiskKey, level: u8, ) -> Vec<u8>

Serialize a non-skinny metadata extent item (EXTENT_ITEM) with tree_block_info and a TREE_BLOCK_REF inline backref (51 bytes).

Source

pub fn to_bytes_data( refs: u64, generation: u64, root: u64, objectid: u64, offset: u64, count: u32, ) -> Vec<u8>

Serialize a data extent item (EXTENT_ITEM) with a single inline EXTENT_DATA_REF backref (53 bytes).

Trait Implementations§

Source§

impl Clone for ExtentItem

Source§

fn clone(&self) -> ExtentItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtentItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.