BlockPointsToWriteGuard

Struct BlockPointsToWriteGuard 

Source
pub struct BlockPointsToWriteGuard<'a, 'b, 'c, M: MetaData> {
    lba: LogicalBlockAddress,
    b: Option<SpinLockGuard<'a, [u8; 4096]>>,
    tx: &'b RunningTransaction<'c>,
    _m: PhantomData<M>,
}
Expand description

A mutable guard for modifying metadata loaded from a block on disk, paired with a transaction context for journaling or rollback.

This guard is returned by BlockPointsTo::write and provides exclusive, mutable access to in-memory metadata of type M, along with a reference to the current transaction. Any modifications made through this guard must be explicitly committed via submit to ensure they are persisted and journaled properly.

§Use Case

Use this when modifying metadata that needs to be tracked in a RunningTransaction, such as updating inode entries, marking blocks as allocated, or changing filesystem state.

§Safety and Enforcement

The implementation panics if this guard is dropped without calling submit, enforcing that all metadata updates must go through the transaction system to maintain consistency.

Fields§

§lba: LogicalBlockAddress

Logical block address of the block being modified.

§b: Option<SpinLockGuard<'a, [u8; 4096]>>

Spinlock guard protecting the block contents.

§tx: &'b RunningTransaction<'c>

Mutable reference to the ongoing transaction.

§_m: PhantomData<M>

Marker to associate the block with its metadata type.

Implementations§

Source§

impl<M: MetaData> BlockPointsToWriteGuard<'_, '_, '_, M>

Source

pub fn submit(self)

Submits the modified metadata block to the RunningTransaction.

This function marks the block as dirty and ensures it will be written to disk as part of the journal. After calling submit, the guard is consumed.

Source

pub fn forget(self)

Explictly drops the modified metadata block to the RunningTransaction.

This function marks the block as intact and ensures it will never be written to disk as part of the journal. After calling forget, the guard is consumed.

Trait Implementations§

Source§

impl<M: MetaData> Deref for BlockPointsToWriteGuard<'_, '_, '_, M>

Source§

type Target = M

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<M: MetaData> DerefMut for BlockPointsToWriteGuard<'_, '_, '_, M>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<M: MetaData> Drop for BlockPointsToWriteGuard<'_, '_, '_, M>

Source§

fn drop(&mut self)

Panics if the guard is dropped without calling submit.

This ensures that all metadata changes are either explicitly recorded in a transaction or clearly rejected, helping prevent silent data loss.

Auto Trait Implementations§

§

impl<'a, 'b, 'c, M> Freeze for BlockPointsToWriteGuard<'a, 'b, 'c, M>

§

impl<'a, 'b, 'c, M> !RefUnwindSafe for BlockPointsToWriteGuard<'a, 'b, 'c, M>

§

impl<'a, 'b, 'c, M> !Send for BlockPointsToWriteGuard<'a, 'b, 'c, M>

§

impl<'a, 'b, 'c, M> !Sync for BlockPointsToWriteGuard<'a, 'b, 'c, M>

§

impl<'a, 'b, 'c, M> Unpin for BlockPointsToWriteGuard<'a, 'b, 'c, M>
where M: Unpin,

§

impl<'a, 'b, 'c, M> !UnwindSafe for BlockPointsToWriteGuard<'a, 'b, 'c, M>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.