mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] md: superblock page cleanups
@ 2026-11-20 18:42 Tal Zussman
  2026-11-20 18:42 ` [PATCH 1/2] md: remove ClearPageUptodate() from read_rdev() Tal Zussman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tal Zussman @ 2026-11-20 18:42 UTC (permalink / raw)
  To: Song Liu, Yu Kuai, Li Nan, Xiao Ni; +Cc: linux-raid, linux-kernel, Tal Zussman

read_rdev() clears PG_uptodate on a superblock page it has just
allocated, which does nothing. Patch 1 removes the call, which is one of
the last users of ClearPageUptodate(). Patch 2 frees the rdev superblock
and bad block pages with __free_page() instead of put_page(), as md
holds the only reference to them.

These buffers don't need to be pages at all and could be plain kmalloc()
allocations, but that is a larger change, so I left it out for now.

No functional change intended.

---
Tal Zussman (2):
      md: remove ClearPageUptodate() from read_rdev()
      md: free the superblock and bad block pages with __free_page()

 drivers/md/md.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
base-commit: c526b7cd32f75fea6021ffdab287b81cf38ddeb7
change-id: 20261119-md-sb-page-cleanup-e9dbb79b2cf9

Best regards,
--  
Tal Zussman <tz2294@columbia.edu>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] md: remove ClearPageUptodate() from read_rdev()
  2026-11-20 18:42 [PATCH 0/2] md: superblock page cleanups Tal Zussman
@ 2026-11-20 18:42 ` Tal Zussman
  2026-11-20 18:42 ` [PATCH 2/2] md: free the superblock and bad block pages with __free_page() Tal Zussman
  2026-11-29  1:37 ` [PATCH 0/2] md: superblock page cleanups yu kuai
  2 siblings, 0 replies; 4+ messages in thread
From: Tal Zussman @ 2026-11-20 18:42 UTC (permalink / raw)
  To: Song Liu, Yu Kuai, Li Nan, Xiao Ni; +Cc: linux-raid, linux-kernel, Tal Zussman

read_rdev() clears PG_uptodate on the superblock page it has just
allocated with alloc_page(), before reading the superblock into it. The
flag is never set on a newly allocated page, and nothing in md tests it.

Remove the call.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 drivers/md/md.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c71c3b043496..c5a7f0697f7d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -10953,7 +10953,6 @@ static int read_rdev(struct mddev *mddev, struct md_rdev *rdev)
 	rdev->sb_page = NULL;
 	err = alloc_disk_sb(rdev);
 	if (err == 0) {
-		ClearPageUptodate(rdev->sb_page);
 		rdev->sb_loaded = 0;
 		err = super_types[mddev->major_version].
 			load_super(rdev, NULL, mddev->minor_version);

-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] md: free the superblock and bad block pages with __free_page()
  2026-11-20 18:42 [PATCH 0/2] md: superblock page cleanups Tal Zussman
  2026-11-20 18:42 ` [PATCH 1/2] md: remove ClearPageUptodate() from read_rdev() Tal Zussman
@ 2026-11-20 18:42 ` Tal Zussman
  2026-11-29  1:37 ` [PATCH 0/2] md: superblock page cleanups yu kuai
  2 siblings, 0 replies; 4+ messages in thread
From: Tal Zussman @ 2026-11-20 18:42 UTC (permalink / raw)
  To: Song Liu, Yu Kuai, Li Nan, Xiao Ni; +Cc: linux-raid, linux-kernel, Tal Zussman

rdev->sb_page and rdev->bb_page come from alloc_page(), and md never
takes another reference on them, so put_page() only ever frees them.
put_page() treats the page as a folio, which these buffers are not. Use
__free_page() instead.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 drivers/md/md.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c5a7f0697f7d..ef4a1141d8be 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1089,14 +1089,14 @@ static int alloc_disk_sb(struct md_rdev *rdev)
 void md_rdev_clear(struct md_rdev *rdev)
 {
 	if (rdev->sb_page) {
-		put_page(rdev->sb_page);
+		__free_page(rdev->sb_page);
 		rdev->sb_loaded = 0;
 		rdev->sb_page = NULL;
 		rdev->sb_start = 0;
 		rdev->sectors = 0;
 	}
 	if (rdev->bb_page) {
-		put_page(rdev->bb_page);
+		__free_page(rdev->bb_page);
 		rdev->bb_page = NULL;
 	}
 	badblocks_exit(&rdev->badblocks);
@@ -10961,7 +10961,7 @@ static int read_rdev(struct mddev *mddev, struct md_rdev *rdev)
 		pr_warn("%s: %d Could not reload rdev(%d) err: %d. Restoring old values\n",
 				__func__, __LINE__, rdev->desc_nr, err);
 		if (rdev->sb_page)
-			put_page(rdev->sb_page);
+			__free_page(rdev->sb_page);
 		rdev->sb_page = swapout;
 		rdev->sb_loaded = 1;
 		return err;
@@ -10983,7 +10983,7 @@ static int read_rdev(struct mddev *mddev, struct md_rdev *rdev)
 	    mddev->pers->spare_active(mddev))
 		sysfs_notify_dirent_safe(mddev->sysfs_degraded);
 
-	put_page(swapout);
+	__free_page(swapout);
 	return 0;
 }
 

-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] md: superblock page cleanups
  2026-11-20 18:42 [PATCH 0/2] md: superblock page cleanups Tal Zussman
  2026-11-20 18:42 ` [PATCH 1/2] md: remove ClearPageUptodate() from read_rdev() Tal Zussman
  2026-11-20 18:42 ` [PATCH 2/2] md: free the superblock and bad block pages with __free_page() Tal Zussman
@ 2026-11-29  1:37 ` yu kuai
  2 siblings, 0 replies; 4+ messages in thread
From: yu kuai @ 2026-11-29  1:37 UTC (permalink / raw)
  To: Tal Zussman, Song Liu, Li Nan, Xiao Ni, yu kuai; +Cc: linux-raid, linux-kernel

在 2026/11/21 2:42, Tal Zussman 写道:

> read_rdev() clears PG_uptodate on a superblock page it has just
> allocated, which does nothing. Patch 1 removes the call, which is one of
> the last users of ClearPageUptodate(). Patch 2 frees the rdev superblock
> and bad block pages with __free_page() instead of put_page(), as md
> holds the only reference to them.
>
> These buffers don't need to be pages at all and could be plain kmalloc()
> allocations, but that is a larger change, so I left it out for now.
>
> No functional change intended.
>
> ---
> Tal Zussman (2):
>        md: remove ClearPageUptodate() from read_rdev()
>        md: free the superblock and bad block pages with __free_page()
>
>   drivers/md/md.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
Applied
> ---
> base-commit: c526b7cd32f75fea6021ffdab287b81cf38ddeb7
> change-id: 20261119-md-sb-page-cleanup-e9dbb79b2cf9
>
> Best regards,
> --
> Tal Zussman <tz2294@columbia.edu>

-- 
Thanks,
Kuai

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-29  1:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 18:42 [PATCH 0/2] md: superblock page cleanups Tal Zussman
2026-11-20 18:42 ` [PATCH 1/2] md: remove ClearPageUptodate() from read_rdev() Tal Zussman
2026-11-20 18:42 ` [PATCH 2/2] md: free the superblock and bad block pages with __free_page() Tal Zussman
2026-11-29  1:37 ` [PATCH 0/2] md: superblock page cleanups yu kuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®