Journal

Struct Journal 

Source
pub struct Journal {
    pub sb: Box<JournalSb>,
}
Expand description

A structure representing the journal metadata used for crash consistency.

Journaling allows the file system to recover from crashes by recording changes in a write-ahead log before committing them to the main file system. This ensures that partially written operations do not corrupt the file system state.

The Journal struct encapsulates the journaling superblock and the total size of the journal region on disk. It is responsible for managing the checkpointing process, which commits durable changes and clears completed transactions.

§Fields

  • sb: The journal superblock, containing configuration and state of the journal.
  • size: The total number of blocks allocated for the journal region.

Fields§

§sb: Box<JournalSb>

Journal superblock.

Implementations§

Source§

impl Journal

Source

pub fn recovery( &mut self, ffs: &FastFileSystemInner, io: &JournalIO<'_>, ) -> Result<(), KernelError>

Recovers and commited but not checkpointed transactions from the journal.

This function is invoked during file system startup to ensure metadata consistency in the event of a system crash or power failure. It scans the on-disk journal area for valid transactions and re-applies them to the file system metadata.

If no complete transaction is detected, the journal is left unchanged. If a partial or corrupt transaction is found, it is safely discarded.

§Parameters
  • ffs: A reference to the core file system state, used to apply recovered metadata.
  • io: The journal I/O interface used to read journal blocks and perform recovery writes.
§Returns
  • Ok(()) if recovery completed successfully or no action was needed.
  • Err(KernelError) if an unrecoverable error occurred during recovery.
Source

pub fn checkpoint( &mut self, ffs: &FastFileSystemInner, io: &JournalIO<'_>, debug_journal: bool, ) -> Result<(), KernelError>

Commits completed journal transactions to the file system.

This method performs the checkpoint operation: it flushes completed transactions from the journal into the main file system, ensuring their effects are permanently recorded.

§Parameters
  • ffs: A reference to the file system core (FastFileSystemInner), needed to apply changes to metadata blocks.
  • io: An object for performing I/O operations related to the journal.
  • debug_journal: If true, enables debug logging for checkpointing.
§Returns
  • Ok(()): If checkpointing succeeds and all transactions are flushed.
  • Err(KernelError): If I/O or consistency errors are encountered.

Auto Trait Implementations§

§

impl Freeze for Journal

§

impl RefUnwindSafe for Journal

§

impl Send for Journal

§

impl Sync for Journal

§

impl Unpin for Journal

§

impl UnwindSafe for Journal

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.