TrackedInodeWriteGuard

Struct TrackedInodeWriteGuard 

Source
pub struct TrackedInodeWriteGuard<'a, 'b, 'c, 'd> {
    mem_layout: RwLockWriteGuard<'a, Inode>,
    disk_layout: BlockPointsToWriteGuard<'b, 'c, 'd, InodeArray>,
    index: usize,
}
Expand description

A guard that provides mutable access to the in-memory within a transactional context.

This guard is constructed internally by TrackedInode::write_with and ensures that any modifications are performed consistently across both memory and disk. The changes must be explicitly committed using the associated transaction.

§Panics

If dropped without submitting the change to the transaction, this guard will panic to ensure no silent inconsistency between in-memory and on-disk state.

§Example

tracked_inode.write_with(tx, |mut guard| {
    guard.mem_layout.size += 1;
    guard.disk_layout[guard.index].size = guard.mem_layout.size;
    guard.submit();
    Ok(())
})?;

Fields§

§mem_layout: RwLockWriteGuard<'a, Inode>

Write guard protecting the in-memory inode.

§disk_layout: BlockPointsToWriteGuard<'b, 'c, 'd, InodeArray>

Write guard protecting the on-disk inode array.

§index: usize

Index to the inode.

Implementations§

Source§

impl TrackedInodeWriteGuard<'_, '_, '_, '_>

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

fn do_submit(self)

Methods from Deref<Target = Inode>§

Source

pub fn into_disk_format(&self) -> Inode

Converts the in-memory Inode structure into its on-disk representation.

This is used when persisting an inode to disk, typically during checkpointing or journal submission. The returned disk_layout::Inode struct matches the format expected by the on-disk inode array.

Source

pub fn get( &self, ffs: &FastFileSystemInner, fba: FileBlockNumber, ) -> Result<Option<LogicalBlockAddress>, KernelError>

Retrieves the logical block address (LBA) corresponding to a file block.

§Arguments
  • ffs: Reference to the file system.
  • fba: FileBlockNumber, relative to the beginning of the file.
§Returns
  • Ok(lba): The logical block address where the specified file block is stored.
  • Err(KernelError): If the block is not allocated or the block number is out of bounds.
Source

pub fn grow( &mut self, ffs: &FastFileSystemInner, until: FileBlockNumber, tx: &RunningTransaction<'_>, ) -> Result<(), KernelError>

Grows the inode to include at least the given number of file blocks.

§Arguments
  • ffs: Reference to the file system.
  • until: The target FileBlockNumber (inclusive) that the inode should grow to cover.
  • tx: The running transaction used to log allocation changes.
§Returns
  • Ok(()): If the inode was successfully extended.
  • Err(KernelError): If allocation fails or the inode cannot be grown.

This function ensures that all blocks up to until are allocated, performing allocation of direct and indirect blocks as needed. The transaction log is updated to support crash consistency.

Trait Implementations§

Source§

impl Deref for TrackedInodeWriteGuard<'_, '_, '_, '_>

Source§

type Target = Inode

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl DerefMut for TrackedInodeWriteGuard<'_, '_, '_, '_>

Source§

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

Mutably dereferences the value.
Source§

impl Drop for TrackedInodeWriteGuard<'_, '_, '_, '_>

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, 'd> Freeze for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

§

impl<'a, 'b, 'c, 'd> !RefUnwindSafe for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

§

impl<'a, 'b, 'c, 'd> !Send for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

§

impl<'a, 'b, 'c, 'd> !Sync for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

§

impl<'a, 'b, 'c, 'd> Unpin for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

§

impl<'a, 'b, 'c, 'd> !UnwindSafe for TrackedInodeWriteGuard<'a, 'b, 'c, 'd>

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.