From: Li Nan <linan666@huaweicloud.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>, Li Nan <linan666@huaweicloud.com>
Cc: song@kernel.org, yukuai3@huawei.com, linux-raid@vger.kernel.org,
linux-kernel@vger.kernel.org, martin.petersen@oracle.com,
bvanassche@acm.org, hch@infradead.org, filipe.c.maia@gmail.com,
yangerkun@huawei.com, yi.zhang@huawei.com
Subject: Re: [PATCH v3 1/2] md: prevent adding disks with larger logical_block_size to active arrays
Date: Mon, 25 Aug 2025 16:43:13 +0800 [thread overview]
Message-ID: <3e26e8a3-e0c1-cd40-af79-06424fb2d54b@huaweicloud.com> (raw)
In-Reply-To: <76d66b0b-afaa-4835-9d55-9e61be83ce01@molgen.mpg.de>
在 2025/8/25 16:10, Paul Menzel 写道:
> Dear Li,
>
>
> Thank you for your patch.
>
> Am 25.08.25 um 09:59 schrieb linan666@huaweicloud.com:
>> From: Li Nan <linan122@huawei.com>
>>
>> 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.
>
> Do you have a reproducer to test this?
Please try the following script:
```
#sd[de] lbs is 512, sdf is 4096
mdadm -CR /dev/md0 -l1 -n2 /dev/sd[de] --assume-clean
#512
cat /sys/block/md0/queue/logical_block_size
#create md0p1
printf "g\nn\n\n\n\nw\n" | fdisk /dev/md0
lsblk | grep md0
mdadm --fail /dev/md0 /dev/sdd
mdadm --add /dev/md0 /dev/sdf
#4096
cat /sys/block/md0/queue/logical_block_size
#partition loss
partprobe /dev/md0
lsblk | grep md0
```
>
>> The later patch will introduce a way to configure the array's
>> logical_block_size.
>>
>> Signed-off-by: Li Nan <linan122@huawei.com>
>> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
>> ---
>> drivers/md/md.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> index cea8fc96abd3..206434591b97 100644
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
>> @@ -6064,6 +6064,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);
>
>
> Kind regards,
>
> Paul
>
>
> .
--
Thanks,
Nan
next prev parent reply other threads:[~2025-08-25 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 7:59 [PATCH v3 0/2] make logical_block_size configurable linan666
2025-08-25 7:59 ` [PATCH v3 1/2] md: prevent adding disks with larger logical_block_size to active arrays linan666
2025-08-25 8:10 ` Paul Menzel
2025-08-25 8:43 ` Li Nan [this message]
2025-08-27 9:29 ` Yu Kuai
2025-08-25 7:59 ` [PATCH v3 2/2] md: allow configuring logical_block_size linan666
2025-08-25 19:51 ` Martin K. Petersen
2025-08-27 9:39 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e26e8a3-e0c1-cd40-af79-06424fb2d54b@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=bvanassche@acm.org \
--cc=filipe.c.maia@gmail.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=pmenzel@molgen.mpg.de \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®