RunningTransaction

Struct RunningTransaction 

Source
pub struct RunningTransaction<'a> {
    tx: RefCell<Vec<(LogicalBlockAddress, Box<[u8; 4096]>)>>,
    journal: Option<SpinLockGuard<'a, Journal>>,
    tx_id: u64,
    io: Option<JournalIO<'a>>,
    debug_journal: bool,
    pub ffs: &'a FastFileSystemInner,
}
Expand description

Represents an in-progress file system transaction using write-ahead journaling.

A RunningTransaction buffers metadata updates to disk blocks before they are permanently written, ensuring crash consistency. When a transaction is committed, the buffered blocks are flushed to the journal area first. Once the journal write completes, the updates are applied to the actual metadata locations on disk.

Transactions are used to group file system changes atomically — either all updates in a transaction are committed, or none are, preventing partial updates.

§Fields

  • tx: A buffer that stores staged metadata writes as a list of (LBA, data) tuples.
  • journal: A locked handle to the global Journal, used during commit.
  • tx_id: Unique identifier for the current transaction.
  • io: The journal I/O interface used for block-level reads/writes.
  • debug_journal: Enables logging of journal operations for debugging.
  • ffs: A reference to the file system’s core structure.

Fields§

§tx: RefCell<Vec<(LogicalBlockAddress, Box<[u8; 4096]>)>>§journal: Option<SpinLockGuard<'a, Journal>>§tx_id: u64§io: Option<JournalIO<'a>>§debug_journal: bool§ffs: &'a FastFileSystemInner

Implementations§

Source§

impl<'a> RunningTransaction<'a>

Source

pub fn begin( name: &str, ffs: &'a FastFileSystemInner, io: JournalIO<'a>, debug_journal: bool, ) -> Self

Begins a new journaled transaction.

Initializes the transaction state and prepares to buffer metadata writes.

§Parameters
  • name: A label for the transaction, useful for debugging.
  • ffs: The file system core structure.
  • io: The journal I/O interface for block operations.
  • debug_journal: Enables verbose logging if set to true.
Source

pub fn write_meta( &self, lba: LogicalBlockAddress, data: Box<[u8; 4096]>, ty: &str, )

Buffers a metadata block modification for inclusion in the transaction.

The actual write is deferred until commit() is called.

§Parameters
  • lba: The logical block address where the metadata will eventually be written.
  • data: A boxed page of data representing the new metadata contents.
  • ty: A type string name of the metadata (for debugging).
Source

pub fn commit(self) -> Result<(), KernelError>

Commits the transaction to the journal and applies changes to disk.

This method performs the following steps:

  1. Writes all staged metadata blocks to the journal region on disk.
  2. Updates the journal superblock.
  3. Checkpoint the journal.
§Returns
  • Ok(()): If the transaction was successfully committed and checkpointed.
  • Err(KernelError): If an I/O or consistency error occurred.

Trait Implementations§

Source§

impl Drop for RunningTransaction<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for RunningTransaction<'a>

§

impl<'a> !RefUnwindSafe for RunningTransaction<'a>

§

impl<'a> !Send for RunningTransaction<'a>

§

impl<'a> !Sync for RunningTransaction<'a>

§

impl<'a> Unpin for RunningTransaction<'a>

§

impl<'a> !UnwindSafe for RunningTransaction<'a>

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<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.