Commit 6c6b66f6 authored by Li Nan's avatar Li Nan Committed by Yu Kuai
Browse files

md: prevent adding disks with larger logical_block_size to active arrays

When adding a disk to a md array, avoid updating the array's
logical_block_size to match the new disk. This prevents accidental
partition table loss that renders the array unusable.

The later patch will introduce a way to configure the array's
logical_block_size.

The issue was introduced before Linux 2.6.12-rc2.

Link: https://lore.kernel.org/linux-raid/20250918115759.334067-2-linan666@huaweicloud.com/


Fixes: d2e45eace8 ("[PATCH] Fix raid "bio too big" failures")
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarYu Kuai <yukuai@fnnas.com>
parent a811db39
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -6067,6 +6067,13 @@ int mddev_stack_new_rdev(struct mddev *mddev, struct md_rdev *rdev)
	if (mddev_is_dm(mddev))
		return 0;

	if (queue_logical_block_size(rdev->bdev->bd_disk->queue) >
	    queue_logical_block_size(mddev->gendisk->queue)) {
		pr_err("%s: incompatible logical_block_size, can not add\n",
		       mdname(mddev));
		return -EINVAL;
	}

	lim = queue_limits_start_update(mddev->gendisk->queue);
	queue_limits_stack_bdev(&lim, rdev->bdev, rdev->data_offset,
				mddev->gendisk->disk_name);