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: LogicalBlockAddressLogical 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>
impl<M: MetaData> BlockPointsToWriteGuard<'_, '_, '_, M>
Sourcepub fn submit(self)
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.
Sourcepub fn forget(self)
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.