Skip to main content

JournalSuperblock

Struct JournalSuperblock 

Source
pub struct JournalSuperblock {
Show 16 fields pub block_type: u32, pub header_sequence: u32, pub block_size: u32, pub max_len: u32, pub first: u32, pub sequence: u32, pub start: u32, pub errno: u32, pub feature_compat: u32, pub feature_incompat: u32, pub feature_ro_compat: u32, pub uuid: [u8; 16], pub nr_users: u32, pub checksum_type: u8, pub num_fc_blocks: u32, pub checksum: u32,
}
Expand description

Parsed JBD2 superblock (read-only view).

Fields§

§block_type: u32

Header block-type (JBD2_SUPERBLOCK_V1 or _V2).

§header_sequence: u32

Next expected sequence number from the header (not s_sequence).

§block_size: u32

Journal block size in bytes.

§max_len: u32

Total blocks in the journal.

§first: u32

First block of log information (typically 1 — block 0 is the sb).

§sequence: u32

First commit ID expected when replay starts.

§start: u32

Start block of the log. 0 means clean unmount (nothing to replay).

§errno: u32

s_errno: the error an aborted journal records, 0 if healthy.

§feature_compat: u32

V2-only feature flags (zero on V1 superblocks).

§feature_incompat: u32§feature_ro_compat: u32§uuid: [u8; 16]

UUID identifying this journal (V2 only).

§nr_users: u32

Number of filesystems sharing this journal (V2 only; always 1 for internal ext4 journals).

§checksum_type: u8

Checksum algorithm id (V2 only; 1 = crc32, 4 = crc32c).

§num_fc_blocks: u32

Total fast-commit blocks (V2, INCOMPAT_FAST_COMMIT only).

§checksum: u32

Superblock checksum as stored on disk (V2 only).

Implementations§

Source§

impl JournalSuperblock

Source

pub fn validate_plain_recovery( &self, block_size: u32, blocks_count: u64, ) -> Result<()>

The journal format supported by the checked recovery/write lifecycle. Feature refusal is a dependency capability boundary, not filesystem damage.

Source

pub fn is_clean(&self) -> bool

True when the log has no outstanding transactions and replay is a no-op.

Source

pub fn uses_csum_v3(&self) -> bool

Returns true if the journal uses v2 or v3 checksum tags. Whether this journal uses the v3 tag layout.

Distinct from Self::uses_csum_v2_or_v3, which says whether it is checksummed at all: the tag layout changes with V3 alone, and confusing the two lays tags neither this crate’s reader nor the kernel can parse.

Source

pub fn uses_csum_v2_or_v3(&self) -> bool

Source

pub fn uses_64bit(&self) -> bool

Returns true if the journal uses 64-bit block numbers (tag.t_blocknr_high).

Source

pub fn has_revoke(&self) -> bool

Returns true if revoke blocks are used.

Source

pub fn unsupported_incompat(&self) -> u32

The s_feature_incompat bits this driver does not handle. Replay and writing both refuse a journal carrying any (#81): the field’s own rule. ASYNC_COMMIT makes a transaction’s completeness rest on checksums alone, and FAST_COMMIT keeps committed updates in an area the walker never visits.

Source

pub fn checksum_declaration_error(&self) -> Option<&'static str>

Why this journal’s checksum declaration is one that cannot be honoured, or None when it names a single, usable scheme.

A journal declares at most one way of checksumming its blocks: the v1 commit-block checksum (compat bit 0x1), or the per-block v2 (incompat 0x8) or v3 (incompat 0x10) scheme, whose checksums are crc32c (s_checksum_type 4). journal.html lists the bits and the type codes; which combinations are refused was observed in the harness VM by patching the superblock of a clean journal (tests/ jbd2_layouts_oracle.rs): the kernel will not load, and e2fsck -fn calls “Journal superblock is corrupt”, exactly the three cases below. A journal without v2 or v3 is accepted whatever its type byte says.

Replay and the writer each support v2 and v3 one at a time, so a journal naming both would otherwise pass the incompat check and be read with a layout its declaration does not name.

Source

pub fn csum_seed(&self) -> u32

The journal checksum seed: the crc32c of the journal’s UUID, from ~0. Every transaction-block checksum starts from it.

Source

pub fn tag_bytes(&self) -> usize

Bytes per descriptor-block tag, not counting the 16-byte UUID that follows a tag without the “same UUID” flag.

journal.html describes two tag records: the v3 one (block number, flags, high block number, 32-bit checksum – always all four words) and the older one (block number, 16-bit checksum, 16-bit flags, and the high block number only under 64BIT). It does not say the older record’s checksum slot exists only under v2; that was measured on journals debugfs jo/jw wrote in the harness VM (tests/jbd2_layouts_oracle.rs), where the distance between consecutive tags is exactly this table.

Source§

impl JournalSuperblock

Source

pub fn parse(raw: &[u8]) -> Result<Self>

Parse a journal superblock from its 1024-byte on-disk representation. raw should be at least 1024 bytes (block-size bytes in practice); we only read up to offset 0x100.

Trait Implementations§

Source§

impl Clone for JournalSuperblock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JournalSuperblock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&JournalSuperblock> for ReplaySummary

Source§

fn from(jsb: &JournalSuperblock) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.