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: u32Header block-type (JBD2_SUPERBLOCK_V1 or _V2).
header_sequence: u32Next expected sequence number from the header (not s_sequence).
block_size: u32Journal block size in bytes.
max_len: u32Total blocks in the journal.
first: u32First block of log information (typically 1 — block 0 is the sb).
sequence: u32First commit ID expected when replay starts.
start: u32Start block of the log. 0 means clean unmount (nothing to replay).
errno: u32s_errno: the error an aborted journal records, 0 if healthy.
feature_compat: u32V2-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: u32Number of filesystems sharing this journal (V2 only; always 1 for internal ext4 journals).
checksum_type: u8Checksum algorithm id (V2 only; 1 = crc32, 4 = crc32c).
num_fc_blocks: u32Total fast-commit blocks (V2, INCOMPAT_FAST_COMMIT only).
checksum: u32Superblock checksum as stored on disk (V2 only).
Implementations§
Source§impl JournalSuperblock
impl JournalSuperblock
Sourcepub fn validate_plain_recovery(
&self,
block_size: u32,
blocks_count: u64,
) -> Result<()>
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.
Sourcepub fn is_clean(&self) -> bool
pub fn is_clean(&self) -> bool
True when the log has no outstanding transactions and replay is a no-op.
Sourcepub fn uses_csum_v3(&self) -> bool
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.
pub fn uses_csum_v2_or_v3(&self) -> bool
Sourcepub fn uses_64bit(&self) -> bool
pub fn uses_64bit(&self) -> bool
Returns true if the journal uses 64-bit block numbers (tag.t_blocknr_high).
Sourcepub fn has_revoke(&self) -> bool
pub fn has_revoke(&self) -> bool
Returns true if revoke blocks are used.
Sourcepub fn unsupported_incompat(&self) -> u32
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.
Sourcepub fn checksum_declaration_error(&self) -> Option<&'static str>
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.
Sourcepub fn csum_seed(&self) -> u32
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.
Sourcepub fn tag_bytes(&self) -> usize
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.