Re: [PATCH v5 08/17] erofs: mm/pagemap: add readahead_folio_last() to avoid folio->private
From: Lance Yang
Date: Mon Sep 21 2026 - 04:20:47 EST
On 2026/9/21 10:28, Zi Yan wrote:
erofs needs to traverse readahead folios in reverse order to achieve
maximum performance by
1. reading all folios from readahead_folio();
2. storing the prior folio pointer in folio->private;
3. traverse from the last folio to the first one.
Add readahead_folio_last() to achieve the same function without using
folio->private. __readahead_advance() helper shares readahead_control
adjustment code among __readahead_folio(), readahead_folio_last(), and
__readahead_batch() by checking new private member, _forward, of
readahead_control.
It prepares for a future commit that replaces PG_private checks with
!folio->private checks. After switching the checks, erofs's use of
folio->private without bumping folio refcount can cause unexpected
outcomes, e.g., in filemap_release_folio(), try_to_free_buffers() becomes
reachable.
No functional change intended.
Assisted-by: LLM
To: Gao Xiang <xiang@xxxxxxxxxx>
To: Chao Yu <chao@xxxxxxxxxx>
To: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
To: Jan Kara <jack@xxxxxxx>
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
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
---
Nothing jumped out at me, feel free to add:
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>