From: Chao Yu <chao@kernel.org>
To: kth5965@gmail.com, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Cc: chao@kernel.org,
syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: evict: truncate page cache before clear_inode
Date: Fri, 13 Mar 2026 15:45:11 +0800 [thread overview]
Message-ID: <0b5bfbdd-fc2d-4dc2-91d3-9af1b5703a76@kernel.org> (raw)
In-Reply-To: <20260309142509.75703-1-kth5965@gmail.com>
On 3/9/2026 10:25 PM, kth5965@gmail.com wrote:
> Hi Chao,
>
> Thanks for the comment.
>
> I took another look at the path, and I think you are right that my
> current fix is too broad and may hide the real problem.
>
> It looks like this happens in a more specific case, where an inode
> still has FI_INLINE_DATA set, but FI_DATA_EXIST is not set.
>
> In that case, f2fs_truncate() goes into the inline conversion path,
> and f2fs_convert_inline_inode() grabs folio 0 before it checks
> whether there is real inline data to move.
>
> Then f2fs_convert_inline_folio() does this:
>
> if (!f2fs_exist_data(dn->inode))
> goto clear_out;
>
> So for the empty-inline case, it returns success, but folio 0 seems to
> have already been added to the page cache by then.
>
> From what I can see, f2fs_grab_cache_folio() may create folio 0 and add
> it to inode->i_mapping when there is no folio at that index, so
> inode->i_data.nrpages becomes 1 there.
>
> After that, f2fs_folio_put() only drops the ref, and the folio stays
> there. Because of that, clear_inode() later sees nrpages != 0 and
> hits the BUG.
>
> This is the flow I am seeing:
>
> f2fs_evict_inode()
> -> truncate_inode_pages_final(&inode->i_data)
> // nrpages = 0
>
> -> i_size_write(inode, 0)
> -> f2fs_truncate(inode)
> -> !f2fs_may_inline_data(inode)
> -> f2fs_convert_inline_inode(inode)
> -> f2fs_grab_cache_folio(inode->i_mapping, 0, false)
> // folio 0 is inserted into page cache
> // nrpages = 1
> -> f2fs_convert_inline_folio(&dn, folio)
> -> !f2fs_exist_data(inode)
> -> clear_out
> -> f2fs_folio_put(folio, true)
> // only drops the ref
> // folio stays in page cache
>
> -> clear_inode()
> -> BUG_ON(inode->i_data.nrpages)
Hi,
Sorry for the late reply.
Yes, we may missed to truncate page #0 cache once we converted inline
inode.
The reason why we convert the inline inode is the inode may already
be corrupted (filesize is larger than MAX_INLINE_DATA(), and it has
FI_INLINE_DATA flag).
My question is: we should has ability to detect such corrupted inode
in sanity_check_inode(), however, I didn't find any log related to that,
any thoughts?
Thanks,
>
> So it seems better to fix this in the inline conversion path,
> instead of truncating all page cache again at the end of eviction.
>
> If you agree, I can send a new patch in that direction.
>
> Thanks,
next prev parent reply other threads:[~2026-03-13 7:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 16:06 [PATCH] " Taerang Kim
2026-02-24 16:54 ` [PATCH v2] " Taerang Kim
2026-03-09 7:44 ` Chao Yu
2026-03-09 14:25 ` [f2fs-dev] " kth5965
2026-03-13 7:45 ` Chao Yu [this message]
2026-03-17 15:28 ` kth5965
2026-03-18 3:40 ` Chao Yu
2026-03-19 15:11 ` kth5965
2026-03-23 3:14 ` Chao Yu
2026-03-31 15:24 ` kth5965
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=0b5bfbdd-fc2d-4dc2-91d3-9af1b5703a76@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=kth5965@gmail.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+fc026e87558558f75c00@syzkaller.appspotmail.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®