[PATCH RFC 08/14] fs/erofs: use folio_attach/detach_private() instead of direct assignment
Zi Yan <[email protected]> Fri, 31 Jul 2026 22:13:31 -0400
| Newsgroups | org.ozlabs.lists.linux-erofs,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> To: Gao Xiang <[email protected]> To: Chao Yu <[email protected]> Cc: Yue Hu <[email protected]> Cc: Jeffle Xu <[email protected]> Cc: Sandeep Dhavale <[email protected]> Cc: Hongbo Li <[email protected]> Cc: Chunhai Guo <[email protected]> Cc: [email protected] Cc: [email protected] --- fs/erofs/data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 9aa48c8d67d12..356665f025fb9 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -263,7 +263,8 @@ void erofs_onlinefolio_init(struct folio *folio) void *v; } u = { .o = ATOMIC_INIT(1) }; - folio->private = u.v; /* valid only if file-backed folio is locked */ + /* valid only if file-backed folio is locked */ + folio_attach_private(folio, u.v); } void erofs_onlinefolio_split(struct folio *folio) @@ -284,7 +285,7 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty) if (v & (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1)) return; - folio->private = 0; + folio_detach_private(folio); if (v & BIT(EROFS_ONLINEFOLIO_DIRTY)) flush_dcache_folio(folio); folio_end_read(folio, !(v & BIT(EROFS_ONLINEFOLIO_EIO))); -- 2.53.0