mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] md: Fix logical_block_size configuration being overwritten
@ 2025-12-19  9:21 linan666
  2025-12-19  9:21 ` [PATCH 2/2] md: Fix forward incompatibility from configurable logical block size linan666
  2025-12-25  8:30 ` [PATCH 1/2] md: Fix logical_block_size configuration being overwritten Yu Kuai
  0 siblings, 2 replies; 4+ messages in thread
From: linan666 @ 2025-12-19  9:21 UTC (permalink / raw)
  To: song, yukuai, xni, linan122
  Cc: linux-raid, linux-kernel, linan666, yangerkun, yi.zhang, bugreports61

From: Li Nan <linan122@huawei.com>

In super_1_validate(), mddev->logical_block_size is directly overwritten
with the value from metadata. This causes the previously configured lbs
to be lost, making the configuration ineffective. Fix it.

Fixes: 62ed1b582246 ("md: allow configuring logical block size")
Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index e5922a682953..7c0dd94a4d25 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1999,7 +1999,6 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
 		mddev->layout = le32_to_cpu(sb->layout);
 		mddev->raid_disks = le32_to_cpu(sb->raid_disks);
 		mddev->dev_sectors = le64_to_cpu(sb->size);
-		mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);
 		mddev->events = ev1;
 		mddev->bitmap_info.offset = 0;
 		mddev->bitmap_info.space = 0;
@@ -2015,6 +2014,9 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
 
 		mddev->max_disks =  (4096-256)/2;
 
+		if (!mddev->logical_block_size)
+			mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);
+
 		if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) &&
 		    mddev->bitmap_info.file == NULL) {
 			mddev->bitmap_info.offset =
-- 
2.39.2


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

end of thread, other threads:[~2025-12-25  8:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-19  9:21 [PATCH 1/2] md: Fix logical_block_size configuration being overwritten linan666
2025-12-19  9:21 ` [PATCH 2/2] md: Fix forward incompatibility from configurable logical block size linan666
2025-12-25  8:39   ` Yu Kuai
2025-12-25  8:30 ` [PATCH 1/2] md: Fix logical_block_size configuration being overwritten 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®