The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>
Cc: chao@kernel.org, Sunmin Jeong <s_min.jeong@samsung.com>,
	Sungjong Seo <sj1557.seo@samsung.com>,
	Yeongjin Gil <youngjin.gil@samsung.com>,
	Yunji Kang <yunji0.kang@samsung.com>,
	zhanxusheng@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] f2fs: fix i_size when pinned fallocate partially fails
Date: Wed, 19 Aug 2026 09:44:05 +0800	[thread overview]
Message-ID: <8f85cf1e-fcc2-431e-b005-59a8ca6f5b8e@kernel.org> (raw)
In-Reply-To: <20260818145535.449055-1-zhanxusheng@xiaomi.com>

On 8/18/26 22:55, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng1024@gmail.com>
> 
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
> 
> Commit 4275b59673eb ("f2fs: fix to round down start offset of fallocate
> for pin file") moved the allocation loop's start down to a section
> boundary, but the error path still converts @expanded against @pg_start,
> which holds the unrounded start.
> 
> @pg_start exists for that conversion: commit 88f2cfc5fa90 ("f2fs: fix to
> update last i_size if fallocate partially succeeds") added it as an
> immutable base because map.m_lblk moves every round.  Each round now maps
> exactly sec_blks blocks starting from rounddown(pg_start, sec_blks), so
> pg_start + expanded overshoots the last allocated block by
> pg_start % sec_blks, and a partial failure leaves i_size covering a tail
> that was never allocated.  Nothing corrects that afterwards either, since
> file_dont_truncate() has already cleared FADVISE_TRUNC_BIT.
> 
> It needs a start offset that is not section aligned plus a fallocate that
> hits ENOSPC partway, so the error path runs with expanded > 0.  On an
> 80 MiB image with 2 MiB sections:
> 
>   truncate -s 80M img
>   mkfs.f2fs -s 1 -f img
>   mount -o loop img /mnt
>   touch /mnt/pinned
>   f2fs_io pinfile set /mnt/pinned
>   # 2093056 = block 511, so pg_start % sec_blks = 511
>   f2fs_io fallocate 0 2093056 536870912 /mnt/pinned
>   stat -c %s /mnt/pinned
>   filefrag -v /mnt/pinned
> 
> The last extent ends at block 10737 either way.  Before, i_size is
> 46075904, block 11249, so 511 blocks of it were never allocated, and
> filefrag does not mark the last extent eof.  After, i_size is 43982848,
> block 10738, and eof is back.  A kernel from before that commit also
> shows no overshoot.
> 
> Keep @pg_start pointing at where allocation actually begins.
> 
> Fixes: 4275b59673eb ("f2fs: fix to round down start offset of fallocate for pin file")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

  reply	other threads:[~2026-08-19  1:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 14:55 [PATCH v2] f2fs: fix i_size when pinned fallocate partially fails Zhan Xusheng
2026-08-19  1:44 ` Chao Yu [this message]
2026-08-21 15:50 ` [f2fs-dev] " patchwork-bot+f2fs

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=8f85cf1e-fcc2-431e-b005-59a8ca6f5b8e@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s_min.jeong@samsung.com \
    --cc=sj1557.seo@samsung.com \
    --cc=stable@vger.kernel.org \
    --cc=youngjin.gil@samsung.com \
    --cc=yunji0.kang@samsung.com \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@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