[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f54f4915-956b-895b-0e14-02c41b7b633e@huaweicloud.com>
Date: Thu, 25 Sep 2025 16:38:33 +0800
From: Li Nan <linan666@...weicloud.com>
To: Xiao Ni <xni@...hat.com>, Li Nan <linan666@...weicloud.com>
Cc: corbet@....net, song@...nel.org, yukuai3@...wei.com, hare@...e.de,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org, martin.petersen@...cle.com,
yangerkun@...wei.com, yi.zhang@...wei.com
Subject: Re: [PATCH v5 2/2] md: allow configuring logical block size
在 2025/9/23 22:06, Xiao Ni 写道:
> On Tue, Sep 23, 2025 at 9:37 PM Li Nan <linan666@...weicloud.com> wrote:
>>
>>
>>
>> 在 2025/9/23 19:36, Xiao Ni 写道:
>>> Hi Li Nan
>>>
>>> On Thu, Sep 18, 2025 at 8:08 PM <linan666@...weicloud.com> wrote:
>>>>
>>>> From: Li Nan <linan122@...wei.com>
>>>>
>>>> Previously, raid array used the maximum logical block size (LBS)
>>>> of all member disks. Adding a larger LBS disk at runtime could
>>>> unexpectedly increase RAID's LBS, risking corruption of existing
>>>> partitions. This can be reproduced by:
>>>>
>>>> ```
>>>> # LBS of sd[de] is 512 bytes, sdf is 4096 bytes.
>>>> mdadm -CRq /dev/md0 -l1 -n3 /dev/sd[de] missing --assume-clean
>>>>
>>>> # LBS is 512
>>>> cat /sys/block/md0/queue/logical_block_size
>>>>
>>>> # create partition md0p1
>>>> parted -s /dev/md0 mklabel gpt mkpart primary 1MiB 100%
>>>> lsblk | grep md0p1
>>>>
>>>> # LBS becomes 4096 after adding sdf
>>>> mdadm --add -q /dev/md0 /dev/sdf
>>>> cat /sys/block/md0/queue/logical_block_size
>>>>
>>>> # partition lost
>>>> partprobe /dev/md0
>>>> lsblk | grep md0p1
>>>> ```
>>>
>>> Thanks for the reproducer. I can reproduce it myself.
>>>
>>>>
>>>> Simply restricting larger-LBS disks is inflexible. In some scenarios,
>>>> only disks with 512 bytes LBS are available currently, but later, disks
>>>> with 4KB LBS may be added to the array.
>>>
>>> If we add a disk with 4KB LBS and configure it to 4KB by the sysfs
>>> interface, how can we make the partition table readable and avoid the
>>> problem mentioned above?
>>>
>>
>
> Hi
>
>> Thanks for your review.
>>
>> The main cause of partition loss is LBS changes. Therefore, we should
>> specify a 4K LBS at creation time, instead of modifying LBS after the RAID
>> is already in use. For example:
>>
>> mdadm -C --logical-block-size=4096 ...
>>
>> In this way, even if all underlying disks are 512-byte, the RAID will be
>> created with a 4096 LBS. Adding 4096-byte disks later will not cause any
>> issues.
>
> It can work. But it looks strange to me to set LBS to 4096 but all
> devices' LBS is 512 bytes. I don't reject it anyway :)
>
In this scenario, there doesn't seem to be a better way. Do you have any
suggestions?
--
Thanks,
Nan
Powered by blists - more mailing lists