Ext4: Difference between revisions

3,255 bytes added ,  3 years ago
Add journaling description.
[unchecked revision][unchecked revision]
(Add disclaimer.)
(Add journaling description.)
Line 474:
|-
| 1020 || 1023 || 4 || Checksum (crc32c(UUID+MMP Block number))
|}
 
== Journaling ==
 
See [[Journaling]] for a high level description of a filesystem journal.
 
Ext4 uses the [[Jbd2]] Journaling layer.
 
Ext4 defines the journal inode as inode 8. The superblock contains the first 68 bytes of the journal. The journal is a hidden file in the filesystem, usually using an entire block group, but it is preferred to be in the middle of the volume.
 
The optional feature filesystem journal protects against filesystem corruption if the system crashes. The filesystem journal writes important data to a small contigous sliver of disk. Once this is flushed to disk, the driver writes a record of the data to be written to the journal. Later, the driver can write the transactions to disk. If the system crashes during the second write, it can simply replay the journal to the last sync. If the write succeedes, the write's record is removed from the journal.
 
The default journaling strategy is 'ordered', writing only filesystem metadata through journaling. If stronger guarantees are preferred, the filesystem can be use the 'journal' strategy, writing both metadata and data through the journal, slowing operation. The filesystem can also use the 'writeback' strategy, where data is not flushed to the disk before a metadata update.
 
Ext4 may also use a seperate journal device, specified in the superblock's journal UUID. The separate journal device will have 1024 bytes of padding, then an ext4 superblock with a matching UUID. The journal follows on the next complete block.
 
===Journal Superblock Fields===
 
Ext4 uses [[Jbd2]] as the journal.
 
All fields are big endian unless otherwise specified.
 
{| {{wikitable}}
! Starting
Byte
! Ending
Byte
! Size
! Description
|-
| 0 || 11 || 12 || Journal header ([[#Journal_Header|see below]])
|-
| 12 || 15 || 4 || Block size of the journal device.
|-
| 16 || 19 || 4 || Total number of blocks in the journal device.
|-
| 20 || 23 || 4 || First block of journal information.
|-
| 24 || 27 || 4 || First journal transaction expected.
|-
| 28 || 31 || 4 || First block of the journal.
|-
| 32 || 35 || 4 || Errno, if the journal has an error.
|-
| 36 || 39 || 4 || Required features present.
|-
| 40 || 43 || 4 || Optional features present.
|-
| 44 || 47 || 4 || Features that if not supported the journal must be mounted read-only. There are no read-only features as of Linux 5.9rc3.
|-
| 48 || 63 || 16 || Journal UUID.
|-
| 64 || 67 || 4 || Number of filesystems using this journal.
|-
| 68 || 71 || 4 || Block number of the journal superblock copy.
|-
| 72 || 75 || 4 || Maximum journal blocks per transaction. This is unused as of Linux 5.9rc3.
|-
| 76 || 79 || 4 || Maximum data blocks per transaction. This is unused as of Linux 5.9rc3.
|-
| 80 || 80 || 1 || Checksum algorithm.
|-
| 81 || 83 || 3 || Padding.
|-
| 84 || 251 || 168 || Padding.
|-
| 252 || 255 || 4 || Checksum of the journal superblock.
|-
| 256 || 1023 || 768 || UUID of filesyste
|}
 
===Journal Header===
 
All fields are big endian unless otherwise specified.
 
{| {{wikitable}}
! Starting
Byte
! Ending
Byte
! Size
! Description
|-
| 0 || 3 || 4 || Magic signature (0xc03b3998)
|-
| 4 || 7 || 4 || Block Type ([[#Journal_Block_Type|see below]])
|-
| 8 || 11 || 4 || Journal transaction for this block.
|}
 
Anonymous user