[PATCH v5 14/17] md: Use folio APIs in free_page()
From: Zi Yan
Date: Sun Sep 20 2026 - 22:33:21 EST
From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
Convert the page to a folio. This removes some of the last uses of a
few page APIs (detach_page_private(), page_buffers()). Replaces two
calls to compound_head() with one.
Remove the early return in free_buffers() to avoid memory leak and
uninitialized file bitmap pages.[1][2]
Link: https://sashiko.dev/#/patchset/20260913-remove-pg_private-v4-0-848550f7574e%40nvidia.com?part=2 [1]
Link: https://lore.kernel.org/all/aqgfA0QFi98gXYG2@xxxxxxxxxxxxxxxxxxxx/ [2]
Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
[dropped the early return]
Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
---
drivers/md/md-bitmap.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 5f1637f974c15..02a126968ad40 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -533,19 +533,15 @@ static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
static void free_buffers(struct page *page)
{
- struct buffer_head *bh;
-
- if (!PagePrivate(page))
- return;
+ struct folio *folio = page_folio(page);
+ struct buffer_head *bh = folio_detach_private(folio);
- bh = page_buffers(page);
while (bh) {
struct buffer_head *next = bh->b_this_page;
free_buffer_head(bh);
bh = next;
}
- detach_page_private(page);
- put_page(page);
+ folio_put(folio);
}
/* read a page from a file.
--
2.53.0