From: Hungyu Lin <dennylin0707@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: lizhijun3@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, dennylin0707@gmail.com
Subject: [PATCH v2 1/2] f2fs: fix to avoid pinfile fragment on checkpoint=disable mode
Date: Sat, 5 Dec 2026 02:21:10 +0000 [thread overview]
Message-ID: <20261205022111.49900-2-dennylin0707@gmail.com> (raw)
In-Reply-To: <20261205022111.49900-1-dennylin0707@gmail.com>
fallocate() on pinfile allocates a whole section at a time, so on a
large section device the pinned log moves to the next segment in the
middle of the allocation. If checkpoint is disabled, need_new_seg()
picks an SSR segment at that point instead of the next segment of the
section, so that the rest of the blocks come from dirty segments. It
results in fragment blocks in pinfile, which violates the semantics of
pinfile introduced in commit f5a53edcf01e ("f2fs: support aligned
pinned file"), and fallocate() may also fail with -ENOSPC, as the pinned
log is closed once an SSR segment at the end of a section is used up.
mkfs.f2fs -f -s 4 /dev/vda
mount /dev/vda /mnt/f2fs
for ((i=0;i<32;i++)) do
dd if=/dev/zero of=/mnt/f2fs/$i bs=1M count=1
done
sync
for ((i=0;i<32;i+=2)) do { rm /mnt/f2fs/$i; } done
sync
mount -o remount,checkpoint=disable:10% /mnt/f2fs
touch /mnt/f2fs/pinfile
f2fs_io pinfile set /mnt/f2fs/pinfile
f2fs_io fallocate 0 0 $((1024*1024*16)) /mnt/f2fs/pinfile
filefrag -v /mnt/f2fs/pinfile
Before, fallocate() fails with -ENOSPC after 2816 blocks and filefrag
shows 9 extents: the first segment of each new section and 256-block
pieces of dirty segments. After, it succeeds and the file is one extent
of 4096 blocks.
Let's always allocate a new segment in LFS manner for pinfile.
Fixes: e1175f022911 ("f2fs: fix to align to section for fallocate() on pinned file")
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
fs/f2fs/segment.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 84fa9b95de82..61be4dbf76db 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3445,6 +3445,8 @@ static bool need_new_seg(struct f2fs_sb_info *sbi, int type)
{
struct curseg_info *curseg = CURSEG_I(sbi, type);
+ if (type == CURSEG_COLD_DATA_PINNED)
+ return true;
if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) &&
curseg->seg_type == CURSEG_WARM_NODE)
return true;
--
2.43.0
next prev parent reply other threads:[~2026-12-05 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 2:21 [PATCH v2 0/2] f2fs: zero preallocated blocks of pinned files for unprivileged users Hungyu Lin
2026-12-05 2:21 ` Hungyu Lin [this message]
2026-12-05 2:21 ` [PATCH v2 2/2] " Hungyu Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261205022111.49900-2-dennylin0707@gmail.com \
--to=dennylin0707@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhijun3@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®