[BUG] INFO: task hung in f2fs_balance_fs (fs/f2fs/segment.c:461, v7.4-rc3)
From: Zheng Zheng
Date: Fri Nov 20 2026 - 08:17:26 EST
Hi Jaegeuk, Chao,
We found a reproducible F2FS hang on v7.4-rc3 with syzkaller. The supplied
recipe reproduced on independent fresh VMs.
Repository and reproducer:
https://github.com/Zheng-zheng-codes/f2fs-balance-fs-hang
Hung-task report
----------------
INFO: task syz.3.29:17033 blocked for more than 143 seconds.
task:syz.3.29 state:D
Call Trace:
io_schedule
f2fs_balance_fs+0x5a2/0x9e0 fs/f2fs/segment.c:461
f2fs_map_blocks+0x2626/0x4d00 fs/f2fs/data.c:2160
f2fs_iomap_begin fs/f2fs/data.c:4798 [inline]
f2fs_iomap_next+0x3d9/0xc20 fs/f2fs/data.c:4856
iomap_iter
__iomap_dio_rw
f2fs_dio_write_iter fs/f2fs/file.c:5587 [inline]
f2fs_file_write_iter+0x1da1/0x2d10 fs/f2fs/file.c:5711
vfs_write
ksys_write
The blocked task is a direct-I/O writer sleeping in the GC_MERGE branch
of f2fs_balance_fs(), which hands the request to the background GC
thread and waits:
if (test_opt(sbi, GC_MERGE) && sbi->gc_thread.f2fs_gc_task) {
prepare_to_wait(&sbi->gc_thread.fggc_wq, &wait, TASK_UNINTERRUPTIBLE);
wake_up(&sbi->gc_thread.gc_wait_queue_head);
io_schedule();
finish_wait(&sbi->gc_thread.fggc_wq, &wait);
}
While it sleeps, the writer holds:
#0: (&f->f_pos_lock) at: fdget_pos+0x2a5 fs/file.c:1413
#1: (sb_writers#15) at: ksys_write+0x126 fs/read_write.c:719
#2: (&sb->s_type->i_mutex_key#29) at: f2fs_file_write_iter fs/f2fs/file.c:5675
#3: (&fi->i_gc_rwsem[1]) READ at: f2fs_dio_write_iter fs/f2fs/file.c:5573
The same report shows two collateral stalls caused by this sleeper: a
second thread of the same process blocked in fdget_pos() on the held
f_pos_lock, and a freeze_super() task waiting in sb_wait_write() for
sb_writers to drain.
Possible root cause
-------------------
The writer waits for the background GC thread while holding
fi->i_gc_rwsem[1] for reading. If the GC thread selects this inode as
a victim, it must take i_gc_rwsem for writing first and cannot proceed,
which would make the wait in f2fs_balance_fs() unbounded. The GC
thread's stack is not captured in the report, so we could not confirm
this mutual-wait explanation, nor what drove the filesystem low on free
segments. We would appreciate your analysis.
This hang is distinct from the previously reported
"INFO: task hung in f2fs_write_data_pages" (writeback path,
sbi->writepages mutex, fs/f2fs/data.c:3834): different call chain and
different blocking primitive, though both occur under segment
allocation / GC pressure.
Reproduction
------------
git clone https://github.com/Zheng-zheng-codes/f2fs-balance-fs-hang
cd f2fs-balance-fs-hang
# boot v7.4-rc3 with the supplied kernel config
# using a Debian trixie x86_64 guest
# in the guest, as root:
syz-execprog -procs=1 -repeat=1 reproducer/repro.kernsight.prog
Note: run with a single process. With -procs=8 the recipe's
state-building sequence is executed out of order and the crash does not
reproduce.
The recipe is a state-reconstruction sequence (107 replay programs plus
one model-selected priming program, followed by the crashing testcase).
The crash depends on the kernel state built by the recipe; the testcase
alone is not sufficient.
Verification:
- five independent fresh-VM runs: 5/5 reproductions, 201-205 s to the
hung-task dump in every run (2026-11-20, external-verify/)
- C reproducer: not generated; the syzkaller recipe is the primary
reproducer
Kernel/guest details:
kernel: v7.4-rc3, bzImage sha256
0c16409f8aec508ac44a63e631c2bd352536401f3fd0856df1d839fb953a1882
guest: Debian trixie x86_64, 6 GiB RAM, 4 vCPU, QEMU/KVM
boot: oops=panic panic_on_warn=1 hung_task_panic=0
config: CONFIG_KASAN=y, CONFIG_PROVE_LOCKING=y, CONFIG_F2FS_FS=y
Thanks,
Zheng