Re: [f2fs-dev] [PATCH v2] f2fs: evict: truncate page cache before clear_inode
From: Chao Yu
Date: Tue Mar 17 2026 - 23:41:11 EST
Hi,
On 2026/3/17 23:28, kth5965@xxxxxxxxx wrote:
Hi Chao,
I checked the repro again based on your comment and added some debug
logs around the related paths.
What I saw was roughly as follows.
There was already an abnormal inline state in the read path:
inline flag: set
data_exist: clear
blocks: present
This case was not rejected by sanity_check_inode(). From what I saw,
the inline sanity check does an early return when inode_has_blocks()
is true, so I think this case was skipped there. I think this may also
explain why there was no sanity warning in the log.
After that, in the eviction path, i_size was already reduced to 0, but
f2fs_truncate() still entered the inline conversion path, and
f2fs_convert_inline_inode() created folio 0 in the page cache first.
Then f2fs_convert_inline_folio() handled the empty inline case as
success because of !f2fs_exist_data(inode), and the created folio 0
remained in the page cache. Because of this, nrpages stayed 1 right
before clear_inode().
The root cause that you pointing out make sense to me. Thanks for the debug
and analysis!
From this, I think there may be two possible directions for fixing
this:
1. prevent folio 0 from being created at all in the empty inline case,
or delay folio creation until it is actually needed
2. detect or guard this abnormal inline state earlier, in sanity check
or before that stage
IMO, I think we need to fix both two places:
2) helps to detect this in early stage, so that we can know target inode is
corrupted via log and error number returned.
However, during 2) process, we will still call into f2fs_evict_inode(), and
do inline conversion eventually, so we need to implement 1) to avoid remained
page #0 cache, IIUC.
What do you think?
Thanks,
At this point, both directions seem possible to me. I wanted to ask
which direction you think would be more appropriate.
If there is anything else I should check, please let me know.
Thanks.