Re: [PATCH RFC 08/14] fs/erofs: use folio_attach/detach_private() instead of direct assignment

From: Zi Yan

Date: Tue Aug 04 2026 - 22:41:38 EST


On Mon Aug 3, 2026 at 7:40 PM EDT, Gao Xiang wrote:
> Hi Zi,
>
> On Fri, Jul 31, 2026 at 10:13:31PM -0400, Zi Yan wrote:
>> erofs_onelinefolio_init/split/end() use folio->private without setting
>> PG_private or increase 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 it now.
>>
>> It prepares for a future commit that removes PG_private.
>>
>> No funtional change intended.
>>
>> Assisted-by: Claude:claude-opus-4-8
>> Assisted-by: Codex:gpt-5
>> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
>> To: Gao Xiang <xiang@xxxxxxxxxx>
>> To: Chao Yu <chao@xxxxxxxxxx>
>> Cc: Yue Hu <zbestahu@xxxxxxxxx>
>> Cc: Jeffle Xu <jefflexu@xxxxxxxxxxxxxxxxx>
>> Cc: Sandeep Dhavale <dhavale@xxxxxxxxxx>
>> Cc: Hongbo Li <hongbohbli@xxxxxxxxxxx>
>> Cc: Chunhai Guo <guochunhai@xxxxxxxx>
>> Cc: linux-erofs@xxxxxxxxxxxxxxxx
>> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
> It looks fine as long as PG_private flag will be removed in the
> follow-up patches:
>

Hi Gao,

Sashiko spot an issue in this patch[1]. Basically, ->private can be 0 if
I/O completes without any issue or being dirty and it causes
folio_detach_private() not to folio_put(). My fix is to add a bias, 1,
to the counter, so that ->private stays non NULL throughout online folio
process. The revised patch is below. Let me know your thoughts. Thanks.

[1] https://sashiko.dev/#/patchset/20260731-remove-pg_private-v1-0-142c97ba3562%40nvidia.com?part=8