^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Journal (jbd2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Introduced in ext3, the ext4 filesystem employs a journal to protect the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) filesystem against corruption in the case of a system crash. A small
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) continuous region of disk (default 128MiB) is reserved inside the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) filesystem as a place to land “important” data writes on-disk as quickly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) as possible. Once the important data transaction is fully written to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) disk and flushed from the disk write cache, a record of the data being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) committed is also written to the journal. At some later point in time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) the journal code writes the transactions to their final locations on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) disk (this could involve a lot of seeking or a lot of small
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) read-write-erases) before erasing the commit record. Should the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) crash during the second slow write, the journal can be replayed all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) way to the latest commit record, guaranteeing the atomicity of whatever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) gets written through the journal to the disk. The effect of this is to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) guarantee that the filesystem does not become stuck midway through a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) metadata update.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) For performance reasons, ext4 by default only writes filesystem metadata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) through the journal. This means that file data blocks are /not/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) guaranteed to be in any consistent state after a crash. If this default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) guarantee level (``data=ordered``) is not satisfactory, there is a mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) option to control journal behavior. If ``data=journal``, all data and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) metadata are written to disk through the journal. This is slower but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) safest. If ``data=writeback``, dirty data blocks are not flushed to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) disk before the metadata are written to disk through the journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) In case of ``data=ordered`` mode, Ext4 also supports fast commits which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) help reduce commit latency significantly. The default ``data=ordered``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) mode works by logging metadata blocks to the journal. In fast commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) mode, Ext4 only stores the minimal delta needed to recreate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) affected metadata in fast commit space that is shared with JBD2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Once the fast commit area fills in or if fast commit is not possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) or if JBD2 commit timer goes off, Ext4 performs a traditional full commit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) A full commit invalidates all the fast commits that happened before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) it and thus it makes the fast commit area empty for further fast
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) commits. This feature needs to be enabled at mkfs time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) The journal inode is typically inode 8. The first 68 bytes of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) journal inode are replicated in the ext4 superblock. The journal itself
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) is normal (but hidden) file within the filesystem. The file usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) consumes an entire block group, though mke2fs tries to put it in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) middle of the disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) All fields in jbd2 are written to disk in big-endian order. This is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) opposite of ext4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) NOTE: Both ext4 and ocfs2 use jbd2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) The maximum size of a journal embedded in an ext4 filesystem is 2^32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) blocks. jbd2 itself does not seem to care.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) Layout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Generally speaking, the journal has this format:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) :widths: 16 48 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * - Superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) - descriptor\_block (data\_blocks or revocation\_block) [more data or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) revocations] commmit\_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) - [more transactions...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) - One transaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) Notice that a transaction begins with either a descriptor and some data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) or a block revocation list. A finished transaction always ends with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) commit. If there is no commit record (or the checksums don't match), the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) transaction will be discarded during replay.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) External Journal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Optionally, an ext4 filesystem can be created with an external journal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) device (as opposed to an internal journal, which uses a reserved inode).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) In this case, on the filesystem device, ``s_journal_inum`` should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) zero and ``s_journal_uuid`` should be set. On the journal device there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) will be an ext4 super block in the usual place, with a matching UUID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) The journal superblock will be in the next full block after the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) superblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) :widths: 12 12 12 32 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * - 1024 bytes of padding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) - ext4 Superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) - Journal Superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) - descriptor\_block (data\_blocks or revocation\_block) [more data or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) revocations] commmit\_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) - [more transactions...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) - One transaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) Block Header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Every block in the journal starts with a common 12-byte header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ``struct journal_header_s``:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) - h\_magic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) - jbd2 magic number, 0xC03B3998.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * - 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) - h\_blocktype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) - Description of what this block contains. See the jbd2_blocktype_ table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * - 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) - h\_sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) - The transaction ID that goes with this block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .. _jbd2_blocktype:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) The journal block type can be any one of:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) :widths: 16 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * - Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * - 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) - Descriptor. This block precedes a series of data blocks that were
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) written through the journal during a transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * - 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) - Block commit record. This block signifies the completion of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * - 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) - Journal superblock, v1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * - 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) - Journal superblock, v2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * - 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) - Block revocation records. This speeds up recovery by enabling the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) journal to skip writing blocks that were subsequently rewritten.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) Super Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) The super block for the journal is much simpler as compared to ext4's.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) The key data kept within are size of the journal, and where to find the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) start of the log of transactions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) The journal superblock is recorded as ``struct journal_superblock_s``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) which is 1024 bytes long:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) - Static information describing the journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) - journal\_header\_t (12 bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) - s\_header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) - Common header identifying this as a superblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * - 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) - s\_blocksize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) - Journal device block size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * - 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) - s\_maxlen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) - Total number of blocks in this journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * - 0x14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) - s\_first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) - First block of log information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) - Dynamic information describing the current state of the log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * - 0x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) - s\_sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) - First commit ID expected in log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * - 0x1C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) - s\_start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) - Block number of the start of log. Contrary to the comments, this field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) being zero does not imply that the journal is clean!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * - 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) - s\_errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) - Error value, as set by jbd2\_journal\_abort().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) - The remaining fields are only valid in a v2 superblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * - 0x24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) - s\_feature\_compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) - Compatible feature set. See the table jbd2_compat_ below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * - 0x28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) - s\_feature\_incompat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) - Incompatible feature set. See the table jbd2_incompat_ below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * - 0x2C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) - s\_feature\_ro\_compat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) - Read-only compatible feature set. There aren't any of these currently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * - 0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) - \_\_u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) - s\_uuid[16]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) - 128-bit uuid for journal. This is compared against the copy in the ext4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) super block at mount time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * - 0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) - s\_nr\_users
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) - Number of file systems sharing this journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * - 0x44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) - s\_dynsuper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) - Location of dynamic super block copy. (Not used?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * - 0x48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) - s\_max\_transaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) - Limit of journal blocks per transaction. (Not used?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * - 0x4C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) - s\_max\_trans\_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) - Limit of data blocks per transaction. (Not used?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * - 0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) - \_\_u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) - s\_checksum\_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) - Checksum algorithm used for the journal. See jbd2_checksum_type_ for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) more info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * - 0x51
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) - \_\_u8[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) - s\_padding2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * - 0x54
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) - s\_num\_fc\_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) - Number of fast commit blocks in the journal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * - 0x58
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) - \_\_u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) - s\_padding[42]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * - 0xFC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) - s\_checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) - Checksum of the entire superblock, with this field set to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * - 0x100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) - \_\_u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) - s\_users[16\*48]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) - ids of all file systems sharing the log. e2fsprogs/Linux don't allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) shared external journals, but I imagine Lustre (or ocfs2?), which use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) the jbd2 code, might.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .. _jbd2_compat:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) The journal compat features are any combination of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) :widths: 16 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * - Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * - 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) - Journal maintains checksums on the data blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) (JBD2\_FEATURE\_COMPAT\_CHECKSUM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) .. _jbd2_incompat:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) The journal incompat features are any combination of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) :widths: 16 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * - Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * - 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) - Journal has block revocation records. (JBD2\_FEATURE\_INCOMPAT\_REVOKE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * - 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) - Journal can deal with 64-bit block numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) (JBD2\_FEATURE\_INCOMPAT\_64BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * - 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) - Journal commits asynchronously. (JBD2\_FEATURE\_INCOMPAT\_ASYNC\_COMMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * - 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) - This journal uses v2 of the checksum on-disk format. Each journal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) metadata block gets its own checksum, and the block tags in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) descriptor table contain checksums for each of the data blocks in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) journal. (JBD2\_FEATURE\_INCOMPAT\_CSUM\_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * - 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) - This journal uses v3 of the checksum on-disk format. This is the same as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) v2, but the journal block tag size is fixed regardless of the size of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) block numbers. (JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * - 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) - Journal has fast commit blocks. (JBD2\_FEATURE\_INCOMPAT\_FAST\_COMMIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .. _jbd2_checksum_type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) Journal checksum type codes are one of the following. crc32 or crc32c are the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) most likely choices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) :widths: 16 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * - Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * - 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) - CRC32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * - 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) - MD5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * - 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) - SHA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * - 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) - CRC32C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) Descriptor Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) The descriptor block contains an array of journal block tags that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) describe the final locations of the data blocks that follow in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) journal. Descriptor blocks are open-coded instead of being completely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) described by a data structure, but here is the block structure anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) Descriptor blocks consume at least 36 bytes, but use a full block:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) - Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) - journal\_header\_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) - (open coded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) - Common block header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * - 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) - struct journal\_block\_tag\_s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) - open coded array[]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) - Enough tags either to fill up the block or to describe all the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) blocks that follow this descriptor block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) Journal block tags have any of the following formats, depending on which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) journal feature and block tag flags are set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) If JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3 is set, the journal block tag is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) defined as ``struct journal_block_tag3_s``, which looks like the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) following. The size is 16 or 32 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) - Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) - t\_blocknr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) - Lower 32-bits of the location of where the corresponding data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) should end up on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * - 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) - t\_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) - Flags that go with the descriptor. See the table jbd2_tag_flags_ for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) more info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * - 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) - t\_blocknr\_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) - Upper 32-bits of the location of where the corresponding data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) should end up on disk. This is zero if JBD2\_FEATURE\_INCOMPAT\_64BIT is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) not enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * - 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) - t\_checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) - Checksum of the journal UUID, the sequence number, and the data block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) - This field appears to be open coded. It always comes at the end of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) tag, after t_checksum. This field is not present if the "same UUID" flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * - 0x8 or 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) - char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) - uuid[16]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) - A UUID to go with this tag. This field appears to be copied from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) ``j_uuid`` field in ``struct journal_s``, but only tune2fs touches that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) .. _jbd2_tag_flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) The journal tag flags are any combination of the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) :widths: 16 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * - Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * - 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) - On-disk block is escaped. The first four bytes of the data block just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) happened to match the jbd2 magic number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * - 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) - This block has the same UUID as previous, therefore the UUID field is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) omitted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * - 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) - The data block was deleted by the transaction. (Not used?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * - 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) - This is the last tag in this descriptor block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) If JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3 is NOT set, the journal block tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) is defined as ``struct journal_block_tag_s``, which looks like the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) following. The size is 8, 12, 24, or 28 bytes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) - Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) - t\_blocknr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) - Lower 32-bits of the location of where the corresponding data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) should end up on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * - 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) - \_\_be16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) - t\_checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) - Checksum of the journal UUID, the sequence number, and the data block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) Note that only the lower 16 bits are stored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * - 0x6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) - \_\_be16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) - t\_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) - Flags that go with the descriptor. See the table jbd2_tag_flags_ for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) more info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) - This next field is only present if the super block indicates support for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 64-bit block numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * - 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) - t\_blocknr\_high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) - Upper 32-bits of the location of where the corresponding data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) should end up on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) - This field appears to be open coded. It always comes at the end of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) tag, after t_flags or t_blocknr_high. This field is not present if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) "same UUID" flag is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * - 0x8 or 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) - char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) - uuid[16]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) - A UUID to go with this tag. This field appears to be copied from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) ``j_uuid`` field in ``struct journal_s``, but only tune2fs touches that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) If JBD2\_FEATURE\_INCOMPAT\_CSUM\_V2 or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3 are set, the end of the block is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) ``struct jbd2_journal_block_tail``, which looks like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) - Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) - t\_checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) - Checksum of the journal UUID + the descriptor block, with this field set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) Data Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) ~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) In general, the data blocks being written to disk through the journal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) are written verbatim into the journal file after the descriptor block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) However, if the first four bytes of the block match the jbd2 magic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) number then those four bytes are replaced with zeroes and the “escaped”
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) flag is set in the descriptor block tag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) Revocation Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) ~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) A revocation block is used to prevent replay of a block in an earlier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) transaction. This is used to mark blocks that were journalled at one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) time but are no longer journalled. Typically this happens if a metadata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) block is freed and re-allocated as a file data block; in this case, a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) journal replay after the file block was written to disk will cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) corruption.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) **NOTE**: This mechanism is NOT used to express “this journal block is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) superseded by this other journal block”, as the author (djwong)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) mistakenly thought. Any block being added to a transaction will cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) the removal of all existing revocation records for that block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) Revocation blocks are described in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) ``struct jbd2_journal_revoke_header_s``, are at least 16 bytes in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) length, but use a full block:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) - journal\_header\_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) - r\_header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) - Common block header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * - 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) - r\_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) - Number of bytes used in this block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * - 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) - \_\_be32 or \_\_be64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) - blocks[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) - Blocks to revoke.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) After r\_count is a linear array of block numbers that are effectively
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) revoked by this transaction. The size of each block number is 8 bytes if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) the superblock advertises 64-bit block number support, or 4 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) If JBD2\_FEATURE\_INCOMPAT\_CSUM\_V2 or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3 are set, the end of the revocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) block is a ``struct jbd2_journal_revoke_tail``, which has this format:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) - r\_checksum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) - Checksum of the journal UUID + revocation block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) Commit Block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) ~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) The commit block is a sentry that indicates that a transaction has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) completely written to the journal. Once this commit block reaches the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) journal, the data stored with this transaction can be written to their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) final locations on disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) The commit block is described by ``struct commit_header``, which is 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) bytes long (but uses a full block):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) :widths: 8 8 24 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) * - Offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) - Type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) - Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) - Descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * - 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) - journal\_header\_s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) - (open coded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) - Common block header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * - 0xC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) - unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) - h\_chksum\_type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) - The type of checksum to use to verify the integrity of the data blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) in the transaction. See jbd2_checksum_type_ for more info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * - 0xD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) - unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) - h\_chksum\_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) - The number of bytes used by the checksum. Most likely 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * - 0xE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) - unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) - h\_padding[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) * - 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) - h\_chksum[JBD2\_CHECKSUM\_BYTES]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) - 32 bytes of space to store checksums. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) JBD2\_FEATURE\_INCOMPAT\_CSUM\_V2 or JBD2\_FEATURE\_INCOMPAT\_CSUM\_V3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) are set, the first ``__be32`` is the checksum of the journal UUID and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) the entire commit block, with this field zeroed. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) JBD2\_FEATURE\_COMPAT\_CHECKSUM is set, the first ``__be32`` is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) crc32 of all the blocks already written to the transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) * - 0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) - \_\_be64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) - h\_commit\_sec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) - The time that the transaction was committed, in seconds since the epoch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) * - 0x38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) - \_\_be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) - h\_commit\_nsec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) - Nanoseconds component of the above timestamp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) Fast commits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) ~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) Fast commit area is organized as a log of tag length values. Each TLV has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) a ``struct ext4_fc_tl`` in the beginning which stores the tag and the length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) of the entire field. It is followed by variable length tag specific value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) Here is the list of supported tags and their meanings:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) .. list-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) :widths: 8 20 20 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) :header-rows: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) * - Tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) - Meaning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) - Value struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) - Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) * - EXT4_FC_TAG_HEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) - Fast commit area header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) - ``struct ext4_fc_head``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) - Stores the TID of the transaction after which these fast commits should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) be applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) * - EXT4_FC_TAG_ADD_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) - Add extent to inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) - ``struct ext4_fc_add_range``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) - Stores the inode number and extent to be added in this inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) * - EXT4_FC_TAG_DEL_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) - Remove logical offsets to inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) - ``struct ext4_fc_del_range``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) - Stores the inode number and the logical offset range that needs to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) removed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) * - EXT4_FC_TAG_CREAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) - Create directory entry for a newly created file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) - ``struct ext4_fc_dentry_info``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) - Stores the parent inode number, inode number and directory entry of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) newly created file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * - EXT4_FC_TAG_LINK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) - Link a directory entry to an inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) - ``struct ext4_fc_dentry_info``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) - Stores the parent inode number, inode number and directory entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * - EXT4_FC_TAG_UNLINK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) - Unlink a directory entry of an inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) - ``struct ext4_fc_dentry_info``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) - Stores the parent inode number, inode number and directory entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * - EXT4_FC_TAG_PAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) - Padding (unused area)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) - None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) - Unused bytes in the fast commit area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) * - EXT4_FC_TAG_TAIL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) - Mark the end of a fast commit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) - ``struct ext4_fc_tail``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) - Stores the TID of the commit, CRC of the fast commit of which this tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) represents the end of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)