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
impl JournalWriter
Sourcepub fn open(fs: &Filesystem) -> Result<Option<Self>>
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).
Sourcepub fn begin(&self) -> Transaction
pub fn begin(&self) -> Transaction
Begin a new transaction with the next sequence number. Caller adds
writes, then calls Self::commit to publish.
Sourcepub fn max_blocks_per_transaction(&self) -> usize
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].
Sourcepub fn commit(&mut self, dev: &dyn BlockDevice, tx: &Transaction) -> Result<()>
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).
Sourcepub fn is_healthy(&self) -> bool
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.