ext4: add KUnit tests for fs/ext4/block_validity.c
Add the ext4_block_validity_test KUnit test suite in
fs/ext4/block_validity-test.c (16 test cases, 40 subtests total) to
comprehensively exercise system-zone rbtree construction, RCU release,
block range validation, reserved journal inode protection, and indirect
block reference checking in fs/ext4/block_validity.c using an in-memory
VFS superblock and mock block device without requiring a mounted disk:
- Bounds and 64-bit overflow checks (ext4_sb_block_valid and
ext4_inode_block_valid) across 1KiB (s_first_data_block = 1) and 4KiB
(s_first_data_block = 0) geometries, exact end-of-filesystem single
and multi-block spans, 64-bit u64 addition wrap-around, >32-bit block
counts under EXT4_FEATURE_INCOMPAT_64BIT, and high-32-bit masking when
64bit is cleared.
- System-zone lifecycle management (ext4_setup_system_zone and
ext4_release_system_zone), covering pre-setup NULL behavior, RCU
publication and teardown, and idempotent double-release handling.
- Multi-group sparse_super and flex_bg layouts (including groups with
zero base metadata blocks and relocated bitmaps/inode tables) as well
as DEBUG mount-option tree printing (debug_print_tree).
- System-zone rbtree merging (add_system_zone and can_merge) across
left-neighbor merges, right-neighbor merges, 3-way bridge merges, and
64-bit (>2^32) group descriptor metadata zones, plus parameterized
interval-overlap geometries (adjacent, single-block, boundary
straddling, interior, exact, and enclosing spans).
- Corrupt overlapping group metadata detection (-EFSCORRUPTED) across
block bitmap, inode bitmap, inode table, and cross-group collisions,
verifying partial rbtree cleanup without publishing s_system_blks.
- Reserved journal inode protection (ext4_protect_reserved_inode),
verifying non-block-aligned i_size rounding, multi-extent and sparse
hole mapping, journal-inode ownership vs. regular/NULL inode
rejection, can_merge() isolation between adjacent ino=0 and journal
zones, disabled-feature/zero-inum/empty-inode skips, and -EINVAL,
ext4_iget, ext4_map_blocks, and metadata-overlap (-EFSCORRUPTED +
EXT4_ERROR_FS) failure paths.
- Block reference array validation (ext4_check_blockref,
ext4_ind_check_inode, and ext4_check_indirect_blockref) across empty
and sparse arrays, metadata and out-of-bounds corruption reporting,
active journal inode (s_journal->j_inode) bypass, and integration with
ext4_map_blocks() block validity checks.
Export the five runtime entry points in fs/ext4/block_validity.c with
EXPORT_SYMBOL_FOR_EXT4_TEST for the ext4-test KUnit module.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 files changed