Skip to main content

JournalWriter

Struct JournalWriter 

Source
pub struct JournalWriter { /* private fields */ }
Expand description

Owns the live-write side of the JBD2 journal. Built once at mount time (when the FS has a journal); reused across every mutating capi call.

Cheap to construct (one inode read + extent walk). Not thread-safe; the outer Filesystem lock must serialize mutating ops anyway.

Implementations§

Source§

impl JournalWriter

Source

pub fn open(fs: &Filesystem) -> Result<Option<Self>>

Open the writer for a mounted filesystem.

Returns Ok(None) when the FS has no journal (s_journal_inum == 0) — callers should fall back to unjournaled writes in that case. Returns Err when the journal is misconfigured (e.g. the journal inode is missing or unparsable).

Flavor-aware: walks the journal inode’s block tree via crate::indirect::map_logical_any, so ext3 journals (legacy indirect block pointers) work the same as ext4 ones (extent tree).

Source

pub fn begin(&self) -> Transaction

Begin a new transaction with the next sequence number. Caller adds writes, then calls Self::commit to publish.

Source

pub fn max_blocks_per_transaction(&self) -> usize

The capacity (in fs blocks) the caller can fit into one transaction. One block is reserved for the JBD2 superblock; the remaining max_len - 1 carry [descriptor, data…, (revoke), commit].

Source

pub fn commit(&mut self, dev: &dyn BlockDevice, tx: &Transaction) -> Result<()>

Publish a transaction crash-safely (see module docs for the four- fence ordering). On success, the in-memory JSB is up-to-date and the on-disk JSB has been written back twice (dirty marker + clean marker).

Source

pub fn is_healthy(&self) -> bool

False once a commit failed after its first device write: the log and the final locations are then in a state only a fresh replay can judge, so this writer refuses every later commit. A refusal before any write (read-only device, stale sequence, oversized transaction) leaves the device untouched and the writer usable.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.