Re: [PATCH v3 08/14] erofs: use folio_attach/detach_private() instead of direct assignment
From: Zi Yan
Date: Wed Sep 09 2026 - 22:07:19 EST
On Wed Sep 9, 2026 at 9:27 AM EDT, David Hildenbrand (Arm) wrote:
> On 9/8/26 19:19, Zi Yan wrote:
>> 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.
>
> It would be great to summarize this interaction with core-mm (migration/split)
> in the patch description.
Will update the commit message.
--
Best Regards,
Yan, Zi