]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: fix to avoid running out of free segments
authorChao Yu <chao@kernel.org>
Wed, 12 Mar 2025 09:01:25 +0000 (17:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 12:55:15 +0000 (13:55 +0100)
commit65e42a7084d1a19d94ca4e1a620dabde2e0a76ae
treec191d7abb07f6bab9b57081ffdd9787d23426018
parent9933e05f508e08ff9054d859c6736234f8d3700f
f2fs: fix to avoid running out of free segments

[ Upstream commit f7f8932ca6bb22494ef6db671633ad3b4d982271 ]

If checkpoint is disabled, GC can not reclaim any segments, we need
to detect such condition and bail out from fallocate() of a pinfile,
rather than letting allocator running out of free segment, which may
cause f2fs to be shutdown.

reproducer:
mkfs.f2fs -f /dev/vda 16777216
mount -o checkpoint=disable:10% /dev/vda /mnt/f2fs
for ((i=0;i<4096;i++)) do { dd if=/dev/zero of=/mnt/f2fs/$i bs=1M count=1; } done
sync
for ((i=0;i<4096;i+=2)) do { rm /mnt/f2fs/$i; } done
sync
touch /mnt/f2fs/pinfile
f2fs_io pinfile set /mnt/f2fs/pinfile
f2fs_io fallocate 0 0 4201644032 /mnt/f2fs/pinfile

cat /sys/kernel/debug/f2fs/status
output:
  - Free: 0 (0)

Fixes: f5a53edcf01e ("f2fs: support aligned pinned file")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Stable-dep-of: e462fc48ceb8 ("f2fs: maintain one time GC mode is enabled during whole zoned GC cycle")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/file.c