linux/fs/f2fs
Sunmin Jeong 4275b59673 f2fs: fix to round down start offset of fallocate for pin file
Currently, the length of fallocate for pin file is section-aligned to
keep allocated sections from being selected as victims of GC. However,
for the case that the start offset of fallocate is not aligned in
section, the allocated sections can't be fully utilized. It's because a
new section is allocated by f2fs_allocate_pinning_section() after using
blks_per_sec blocks regardless of the start offset. As a result, several
unexpected dirty segments may be created, including blocks assigned to
the pinned file.

To address this issue, let's round down the start offset of fallocate
to the length of section.

The reproducing scenario is as below

chunk=$(((2<<20)+4096)) # 2MB + 4KB
touch test
f2fs_io pinfile set test
f2fs_io fallocate 0 0 $chunk test
f2fs_io fallocate 0 $chunk $chunk test
f2fs_io fallocate 0 $((chunk*2)) $chunk test
f2fs_io fiemap 0 $((chunk*3)) test

Fiemap: offset = 0 len = 12288
    logical addr.    physical addr.   length           flags
0   0000000000000000 000000068c600000 0000000000400000 00001088
1   0000000000400000 000000003d400000 0000000000001000 00001088
2   0000000000401000 00000003eb200000 0000000000200000 00001088
3   0000000000601000 00000005e4200000 0000000000001000 00001088
4   0000000000602000 0000000605400000 0000000000200000 00001089

Cc: stable@vger.kernel.org
Fixes: f5a53edcf0 ("f2fs: support aligned pinned file")
Reviewed-by: Yunji Kang <yunji0.kang@samsung.com>
Reviewed-by: Yeongjin Gil <youngjin.gil@samsung.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Sunmin Jeong <s_min.jeong@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2026-06-22 19:55:27 +00:00
..
acl.c f2fs: validate ACL entry sizes in f2fs_acl_from_disk() 2026-06-22 19:52:37 +00:00
acl.h f2fs: Pass folios to f2fs_init_acl() 2025-04-28 15:26:41 +00:00
checkpoint.c f2fs: validate orphan inode entry count 2026-06-22 19:52:36 +00:00
compress.c f2fs: remove unneeded f2fs_is_compressed_page() 2026-06-22 19:52:38 +00:00
data.c f2fs: Split f2fs_write_end_io() 2026-06-22 19:52:37 +00:00
debug.c f2fs: Add defrag_blocks sysfs node 2026-03-24 17:20:59 +00:00
dir.c f2fs: validate dentry name length before lookup compares it 2026-06-22 19:52:37 +00:00
extent_cache.c f2fs: fix incorrect FI_NO_EXTENT handling in __destroy_extent_node() 2026-05-22 03:49:06 +00:00
f2fs.h f2fs: Rename f2fs_post_read_wq into f2fs_wq 2026-06-22 19:52:37 +00:00
file.c f2fs: fix to round down start offset of fallocate for pin file 2026-06-22 19:55:27 +00:00
gc.c f2fs: fix wrong description in printed log 2026-06-22 19:52:38 +00:00
gc.h f2fs: set default valid_thresh_ratio to 80 for zoned devices 2025-10-24 21:23:55 +00:00
hash.c fs: add helpers name_is_dot{,dot,_dotdot} 2026-01-29 10:06:59 +01:00
inline.c f2fs: validate inline dentry name lengths before conversion 2026-06-22 19:52:36 +00:00
inode.c f2fs: bound i_inline_xattr_size for non-inline-xattr inodes 2026-06-22 19:52:37 +00:00
iostat.c f2fs: add page-order information for large folio reads in iostat 2026-04-18 22:44:42 +00:00
iostat.h f2fs: add page-order information for large folio reads in iostat 2026-04-18 22:44:42 +00:00
Kconfig f2fs: switch to using the crc32 library 2024-12-01 17:23:02 -08:00
Makefile
namei.c f2fs-for-7.1-rc1 2026-04-21 14:50:04 -07:00
node.c f2fs: fix to do sanity check on f2fs_get_node_folio_ra() 2026-06-22 19:52:36 +00:00
node.h f2fs: annotate lockless NAT counter reads 2026-06-22 19:52:34 +00:00
recovery.c f2fs: support to report fserror 2026-05-22 03:49:06 +00:00
segment.c f2fs: avoid unnecessary sanity check on ckpt_valid_blocks 2026-06-22 19:52:38 +00:00
segment.h Revert: "f2fs: check in-memory sit version bitmap" 2026-06-22 19:52:35 +00:00
shrinker.c f2fs: handle error cases of memory donation 2025-05-06 15:46:55 +00:00
super.c f2fs: misc cleanup in f2fs_record_stop_reason() 2026-06-22 19:52:38 +00:00
sysfs.c f2fs: support to report fserror 2026-05-22 03:49:06 +00:00
verity.c f2fs: support to report fserror 2026-05-22 03:49:06 +00:00
xattr.c f2fs: fix listxattr handling of corrupted xattr entries 2026-06-22 19:55:27 +00:00
xattr.h f2fs: use global inline_xattr_slab instead of per-sb slab cache 2025-12-04 02:00:02 +00:00