Chapter 4. The ext4 File System
4.1. Features of ext4
- Main Features
- The ext4 file system uses extents (as opposed to the traditional block mapping scheme used by ext2 and ext3), which improves performance when using large files and reduces metadata overhead for large files. In addition, ext4 also labels unallocated block groups and inode table sections accordingly, which allows them to be skipped during a file system check. This makes for quicker file system checks, which becomes more beneficial as the file system grows in size.
- Allocation Features
- The ext4 file system features the following allocation schemes:
Because of delayed allocation and other performance optimizations, ext4's behavior of writing files to disk is different from ext3. In ext4, a program's writes to the file system are not guaranteed to be on-disk unless the program issues an
- Persistent pre-allocation
- Delayed allocation
- Multi-block allocation
- Stripe-aware allocation
fsync()call afterwards.By default, ext3 automatically forces newly created files to disk almost immediately even without
fsync(). This behavior hid bugs in programs that did not use
fsync()to ensure that written data was on-disk. The ext4 file system, on the other hand, often waits several seconds to write out changes to disk, allowing it to combine and reorder writes for better disk performance than ext3.
WarningUnlike ext3, the ext4 file system does not force data to disk on transaction commit. As such, it takes longer for buffered writes to be flushed to disk. As with any file system, use data integrity calls such as
fsync()to ensure that data is written to permanent storage.
- Other ext4 Features
- The ext4 file system also supports the following:
- Extended attributes (
xattr), which allows the system to associate several additional name/value pairs per file.
- Quota journaling, which avoids the need for lengthy quota consistency checks after a crash.
NoteThe only supported journaling mode in ext4 is
- Subsecond timestamps, which allow to specify inode timestamp fields in nanosecond resolution.