Thread (3 messages) 3 messages, 3 authors, 2026-09-07

Re: [PATCH v2] md/raid5: reject raid4/5 arrays with too few disks

flat view

From: yu kuai <yukuai@fygo.io>
Date: 2026-09-07 06:35:48
Also in: sashiko-reviews

Hi,

在 2026/9/5 19:00, sashiko-bot@kernel.org 写道:
quoted
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index b91545ce090de..4d8bb0cf26055 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7657,9 +7657,12 @@ static struct r5conf *setup_conf(struct mddev *mddev)
  			mdname(mddev), mddev->new_layout);
  		return ERR_PTR(-EIO);
  	}
-	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
-		pr_warn("md/raid:%s: not enough configured devices (%d, minimum 4)\n",
-			mdname(mddev), mddev->raid_disks);
+	if ((mddev->new_level == 4 && mddev->raid_disks < 2) ||
+	    (mddev->new_level == 5 && mddev->raid_disks < 3) ||
[Severity: High]
Does this unintentionally break 2-disk RAID5 arrays?

The md driver supports and intentionally creates 2-disk RAID5 arrays during a
RAID1-to-RAID5 reshape. For example, in drivers/md/raid5.c
raid5_takeover_raid1() creates a 2-disk RAID5:

     mddev->new_level = 5;
     mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC;
     mddev->new_chunk_sectors = chunksect;

     ret = setup_conf(mddev);

By unconditionally rejecting mddev->new_level == 5 && mddev->raid_disks < 3
here, doesn't this cause valid reshape operations and assembly of legitimate
2-disk RAID5 arrays to fail with -EINVAL?
This make sense, 2 disks raid1 reshape to raid5 should not be broken.

-- 
Thanks,
Kuai
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help