Re: [PATCH v3 08/14] erofs: use folio_attach/detach_private() instead of direct assignment
From: Zi Yan
Date: Tue Sep 08 2026 - 14:28:33 EST
On Tue Sep 8, 2026 at 12:13 PM EDT, David Hildenbrand (Arm) wrote:
> On 9/8/26 04:56, Zi Yan wrote:
>> erofs_onlinefolio_init/split/end() use folio->private without setting
>> PG_private or increasing folio refcount and it works. But after PG_private
>> is replaced by checking folio->private in a future commit, it can break
>> folio_expected_ref_count(), since the folio has private data without
>> elevated refcount. Change them to use folio_attach/detach_private().
>
> Freezing the folio will properly work I assume, as we'd always freeze with that
> refcount in mind or remove the reference (detach private) early?
Yes.
>
> I'm thinking of folio_ref_freeze() in __folio_freeze_and_split_unmapped().
>
> Or is the ref only very short-lived either way such that we don't care?
The folios here are locked since they are in the process of
readahead, which requires all folios locked. So they are not reachable
from folio split code. In additio, the private is deatched and ref is
decreased before the folio lock is dropped.
--
Best Regards,
Yan, Zi