From: kth5965@gmail.com
To: Chao Yu <chao@kernel.org>,
jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net
Cc: syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com,
linux-kernel@vger.kernel.org, kth5965@gmail.com
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: evict: truncate page cache before clear_inode
Date: Mon, 9 Mar 2026 23:25:09 +0900 [thread overview]
Message-ID: <20260309142509.75703-1-kth5965@gmail.com> (raw)
In-Reply-To: <9df7bc57-f0e1-4c7b-9ce1-0017eab62c2a@kernel.org>
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)
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-09 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 16:06 [PATCH] f2fs: evict: truncate page cache before clear_inode Taerang Kim
2026-02-24 16:54 ` [PATCH v2] " Taerang Kim
2026-03-09 7:44 ` Chao Yu
2026-03-09 14:25 ` kth5965 [this message]
2026-03-13 7:45 ` [f2fs-dev] " Chao Yu
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=20260309142509.75703-1-kth5965@gmail.com \
--to=kth5965@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--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