syzbot
WARNING in ext4_destroy_inode
Status:
moderation: reported on 2026/12/06 07:57
Subsystems:
ext4
Labels:
prio:low
[Documentation on labels]
Reported-by: syzbot+6b817707764bef770790@syzkaller.appspotmail.com
First crash: 4h14m, last: 4h14m
✨ AI-generated root cause summary:
In ext4's iomap buffered I/O path, ext4_block_zero_eof() zeroes the tail of the EOF block before i_size is extended and unlocks the folio before calling ext4_iomap_mark_disksize_pending(). If writeback cleans that EOF block during this gap (without advancing i_disksize because i_size is still unextended) and another block in the same multi-block folio is dirtied (e.g. via concurrent ext4_page_mkwrite(), which does not take inode_lock), ext4_iomap_mark_disksize_pending() checks folio-wide folio_test_dirty(folio) instead of the sub-folio dirty state for the EOF block and erroneously sets EXT4_STATE_DISKSIZE_GROW_PENDING. Subsequent writeback skips the already-clean EOF block in iomap_folio_state and never submits an EXT4_IOMAP_IOEND_DISKSIZE_GROW_IO bio to clear the flag, leaving EXT4_STATE_DISKSIZE_GROW_PENDING set when ext4_destroy_inode() runs during unmount.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
The warning in ext4_destroy_inode() (fs/ext4/super.c:1554-1558) indicates that an inode using the iomap buffered I/O path (EXT4_STATE_BUFFERED_IOMAP) was evicted during unmount (generic_shutdown_super() → sync_filesystem() → evict_inodes() → ext4_evict_inode() → destroy_inode() → ext4_destroy_inode()) with EXT4_STATE_DISKSIZE_GROW_PENDING still set.
Affected Functions, Structs, and Fields
Mechanism and Lifecycle Violation
-
Pre-extension EOF zeroing and folio unlock window:
Callers such as ext4_write_checks() (fs/ext4/file.c:325, prior to ext4_iomap_buffered_write()), ext4_truncate_up() (fs/ext4/inode.c:7035, prior to ext4_set_inode_size()), and ext4_alloc_file_blocks() (fs/ext4/extents.c:4683, prior to ext4_update_inode_size()) invoke ext4_block_zero_eof(inode, from, end) before advancing inode->i_size. Inside it, ext4_block_iomap_zero_range() → iomap_zero_range() zeroes [from, round_up(from, blocksize)) in the EOF block B = from >> i_blkbits, dirties block B in the folio / iomap_folio_state, and unlocks the folio.
-
Writeback cleans block B without advancing i_disksize:
Before ext4_iomap_mark_disksize_pending(inode, from) (fs/ext4/inode.c:4980) re-locks the folio via filemap_lock_folio() and waits via folio_wait_writeback(), writeback can run on the folio. Because inode->i_size has not been extended yet (still equal to old_size), ext4_iomap_wb_update_disksize() (fs/ext4/page-io.c:635) computes new_disksize = min(end, i_size) = old_size, so EXT4_I(inode)->i_disksize is not advanced. As a result, the check at fs/ext4/inode.c:5017:
if (from >= round_up(READ_ONCE(EXT4_I(inode)->i_disksize), i_blocksize(inode)))
goto out;
does not bail out even though the zeroed EOF block B has already been written back and cleaned.
-
Folio-wide dirty check sets EXT4_STATE_DISKSIZE_GROW_PENDING for a clean block:
When folio_size(folio) > blocksize (either blocksize < PAGE_SIZE such as 1K/2K ext4 blocks on 4K pages, or large folios enabled via ext4_set_inode_mapping_order() at fs/ext4/inode.c:6286), another block < B in the same folio can be dirtied before ext4_iomap_mark_disksize_pending() acquires the folio lock — for example via concurrent ext4_page_mkwrite() (fs/ext4/inode.c:7994-8003), which acquires mapping->invalidate_lock shared and does not acquire inode->i_rwsem (inode_lock), whereas ext4_buffered_write_iter() holds inode_lock without invalidate_lock.
At fs/ext4/inode.c:5032-5037, ext4_iomap_mark_disksize_pending() only checks folio-wide folio_test_dirty(folio) rather than checking whether the sub-folio block containing from/i_disksize is dirty in iomap_folio_state. Because another block in the folio is dirty, folio_test_dirty(folio) returns true and EXT4_STATE_DISKSIZE_GROW_PENDING is set even though block B is already clean.
-
Flag never cleared through writeback or i_nlink != 0 eviction:
- If the pending operation subsequently fails before dirtying at or beyond
B (e.g., -EFAULT during iomap_file_buffered_write()), or only blocks < B are dirty, iomap_writeback_folio() (fs/iomap/buffered-io.c:2052) iterates only dirty sub-folio ranges via iomap_find_dirty_range(). Clean block B is skipped, so ext4_iomap_writeback_submit() (fs/ext4/inode.c:4505-4514) never sees an ioend covering [pstart, pstart + plen) ([i_disksize, round_up(i_disksize, blocksize))) and never tags an ioend with EXT4_IOMAP_IOEND_DISKSIZE_GROW_IO. Consequently, ext4_iomap_end_bio() (fs/ext4/page-io.c:754-755) never clears EXT4_STATE_DISKSIZE_GROW_PENDING.
- During unmount (
generic_shutdown_super() → sync_filesystem() → evict_inodes()), sync_filesystem() writes back and cleans any remaining dirty blocks < B without clearing EXT4_STATE_DISKSIZE_GROW_PENDING. When ext4_evict_inode() runs for a linked inode (inode->i_nlink != 0), it jumps to goto no_delete; at fs/ext4/inode.c:255-265, bypassing the ext4_iomap_clear_disksize_pending(inode) call that only exists in the i_nlink == 0 deletion path at line 275. ext4_destroy_inode() then observes EXT4_STATE_DISKSIZE_GROW_PENDING still set and triggers the WARN_ON_ONCE at fs/ext4/super.c:1554-1555.
Sample crash report:
* Struck through repros no longer work on HEAD.