[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <358b8933-952e-0e4b-e708-c40ca98ae7d7@huaweicloud.com>
Date: Mon, 3 Nov 2025 21:09:04 +0800
From: Li Nan <linan666@...weicloud.com>
To: Xiao Ni <xni@...hat.com>, linan666@...weicloud.com
Cc: corbet@....net, song@...nel.org, yukuai@...as.com, hare@...e.de,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org, yangerkun@...wei.com, yi.zhang@...wei.com
Subject: Re: [PATCH v8 4/4] md: allow configuring logical block size
在 2025/11/3 11:11, Xiao Ni 写道:
> On Thu, Oct 30, 2025 at 2:36 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
>> ```
>>
>> 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.
>>
>> Making LBS configurable is the best way to solve this scenario.
>> After this patch, the raid will:
>> - store LBS in disk metadata
>> - add a read-write sysfs 'mdX/logical_block_size'
>>
>> Future mdadm should support setting LBS via metadata field during RAID
>> creation and the new sysfs. Though the kernel allows runtime LBS changes,
>> users should avoid modifying it after creating partitions or filesystems
>> to prevent compatibility issues.
>>
>> Only 1.x metadata supports configurable LBS. 0.90 metadata inits all
>> fields to default values at auto-detect. Supporting 0.90 would require
>> more extensive changes and no such use case has been observed.
>>
>> Note that many RAID paths rely on PAGE_SIZE alignment, including for
>> metadata I/O. A larger LBS than PAGE_SIZE will result in metadata
>> read/write failures. So this config should be prevented.
>>
>> Signed-off-by: Li Nan <linan122@...wei.com >
> Hi Li Nan
>
Hi Xiao,
Thanks for your review.
> The problem can't be fixed if there is no user space (mdadm) patch, right?
>
Yeah, mdadm should update same time. And Guanghao will send a mdadm patch
later.
> The patch Looks good to me.
> Reviewed-by: Xiao Ni <xni@...hat.com>
>
Sorry for the trouble. I sent the v9 with some changes to the
Documentation. Could you please review v9 patch when you have time?
>
> .
--
Thanks,
Nan
Powered by blists - more mailing lists