Re: [RFC PATCH] btrfs: defer freeing of subpage private state to free_folio

From: Qu Wenruo

Date: Fri Jan 30 2026 - 15:37:38 EST




在 2026/1/31 03:40, JP Kobryn 写道:
On 1/29/26 9:14 PM, Matthew Wilcox wrote:
On Fri, Jan 30, 2026 at 01:46:59PM +1030, Qu Wenruo wrote:
Another question is, why only two fses (nfs for dir inode, and orangefs) are
utilizing the free_folio() callback.

Alas, secretmem and guest_memfd are also using it.  Nevertheless, I'm
not a fan of this interface existing, and would prefer to not introduce
new users.  Like launder_folio, which btrfs has also mistakenly used.


The part that felt concerning is how the private state is lost. If
release_folio() frees this state but the folio persists in the cache,
users of the folio afterward have to recreate the state. Is that the
expectation on how filesystems should handle this situation?

I believe that's the case.

Just like what we did in btrfs_do_readpage() and prepare_one_folio().

There is no difference between getting a new page and a page that is released but not removed from the filemap.


In the case of the existing btrfs code, when the state is recreated (in
subpage mode), the bitmap data and lock states are all zeroed.

That's expected.

Thanks,
Qu