mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] md: dont warn about sb update on auto read only arrays
@ 2026-11-06 18:20 incharilla via B4 Relay
  2026-11-07 23:50 ` Corey Hickey
  2026-11-08  2:53 ` yu kuai
  0 siblings, 2 replies; 3+ messages in thread
From: incharilla via B4 Relay @ 2026-11-06 18:20 UTC (permalink / raw)
  To: Song Liu, Yu Kuai, Li Nan, Xiao Ni
  Cc: Yu Kuai, Corey Hickey, linux-raid, linux-kernel, incharilla

From: incharilla <incharilla@incharilla.site>

Commit 8c9e376b9d1a ("md: warn about updating super block failure") added
an error when md_update_sb is called on a read only array to help debug io
hangs.

An array that is started auto read only prints this error for no reason.
This happens when it is assembled with start_ro set or when a degraded
array is created with start_ro set. md_update_sb already defers the
update by setting MD_SB_CHANGE_DEVS and the sb is written as soon as the
first write makes the array read write. No io can hang on an array that
has not been written to yet.

Skip the message for MD_AUTO_READ the same way dm raid is already skipped.
It is still printed for arrays that are really read only.

Tested in qemu on loop devices with raid1 and raid5 and raid10. Before
this patch assembling a clean array with start_ro set prints the error
for all three levels. Creating a degraded array with start_ro set prints
it in 5 of 10 tries for raid1 and 8 of 10 for raid5 and 4 of 10 for
raid10. After this patch none of these print it. On raid1 the first write
still makes the array read write and the sb events go from 17 to 19.
Assembling with mdadm --readonly still prints the error.

The fix and the qemu test were made with help from Claude Code.

Fixes: 8c9e376b9d1a ("md: warn about updating super block failure")
Reported-by: Corey Hickey <bugfood-c@fatooh.org>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222162
Signed-off-by: incharilla <incharilla@incharilla.site>
---
Found from bugzilla 222162. The qemu test script used is a busybox
initramfs that creates raid1 and raid5 and raid10 arrays on loop devices
with start_ro set and counts the message in dmesg.
---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 03e35386a80283032e317e037a749eca23ce170e..a0fc6028990530026404f0019a458dfabed02349 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2819,7 +2819,8 @@ void md_update_sb(struct mddev *mddev, int force_change)
 	if (!md_is_rdwr(mddev)) {
 		if (force_change)
 			set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
-		if (!mddev_is_dm(mddev))
+		/* auto read only arrays write the sb once they become writable */
+		if (!mddev_is_dm(mddev) && mddev->ro != MD_AUTO_READ)
 			pr_err_ratelimited("%s: can't update sb for read-only array %s\n",
 					   __func__, mdname(mddev));
 		return;

---
base-commit: a91337fb5e8e0127c8b5be87be9f3027f95b48bc
change-id: 20261106-md-auto-read-only-sb-warn-7c3d66490643

Best regards,
-- 
incharilla <incharilla@incharilla.site>



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

end of thread, other threads:[~2026-11-08  2:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 18:20 [PATCH] md: dont warn about sb update on auto read only arrays incharilla via B4 Relay
2026-11-07 23:50 ` Corey Hickey
2026-11-08  2:53 ` 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®