Re: [f2fs-dev] [PATCH] f2fs: fix i_size when pinned fallocate partially fails
Chao Yu via Linux-f2fs-devel <[email protected]>
| Newsgroups | net.sourceforge.lists.linux-f2fs-devel,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On 8/17/26 10:27, Zhan Xusheng wrote: > From: Zhan Xusheng <[email protected]> > > From: Zhan Xusheng <[email protected]> > > 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. > > Keep @pg_start pointing at where allocation actually begins. Hi Xuesheng, Can you please provide a reproducer? Thanks, > > Fixes: 4275b59673eb ("f2fs: fix to round down start offset of fallocate for pin file") > Cc: [email protected] > Signed-off-by: Zhan Xusheng <[email protected]> > --- > fs/f2fs/file.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 4b52c56d71f0..cc0d2b8c4684 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -1919,8 +1919,9 @@ static int f2fs_expand_inode_data(struct inode *inode, loff_t offset, > block_t sec_len; > > if (map.m_lblk % sec_blks) { > - map.m_lblk = rounddown(map.m_lblk, sec_blks); > - map.m_len = pg_end - map.m_lblk; > + pg_start = rounddown(map.m_lblk, sec_blks); > + map.m_lblk = pg_start; > + map.m_len = pg_end - pg_start; > if (off_end) > map.m_len++; > } _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel