Re: [PATCH v2 1/2] md: Fix logical_block_size configuration being overwritten

Xiao Ni <[email protected]>
Newsgroups gmane.linux.raid,gmane.linux.kernel
Message-ID <CALTww29hq7t5SZ4gtprJN_9msW58qs6DaSsdLQ2CQWTZ=k7Lng@mail.gmail.com>
On Thu, Dec 25, 2025 at 8:24 PM <[email protected]> wrote:
>
> From: Li Nan <[email protected]>
>
> In super_1_validate(), mddev->logical_block_size is directly overwritten
> with the value from metadata. This causes the previously configured lbs
> to be lost, making the configuration ineffective. Fix it.
>
> Fixes: 62ed1b582246 ("md: allow configuring logical block size")
> Signed-off-by: Li Nan <[email protected]>
> Reviewed-by: Yu Kuai <[email protected]>
> ---
>  drivers/md/md.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e5922a682953..7c0dd94a4d25 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1999,7 +1999,6 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
>                 mddev->layout = le32_to_cpu(sb->layout);
>                 mddev->raid_disks = le32_to_cpu(sb->raid_disks);
>                 mddev->dev_sectors = le64_to_cpu(sb->size);
> -               mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);
>                 mddev->events = ev1;
>                 mddev->bitmap_info.offset = 0;
>                 mddev->bitmap_info.space = 0;
> @@ -2015,6 +2014,9 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
>
>                 mddev->max_disks =  (4096-256)/2;
>
> +               if (!mddev->logical_block_size)
> +                       mddev->logical_block_size = le32_to_cpu(sb->logical_block_size);
> +
>                 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) &&
>                     mddev->bitmap_info.file == NULL) {
>                         mddev->bitmap_info.offset =
> --
> 2.39.2
>

This patch looks good to me.
Reviewed-by: Xiao Ni <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.