From: "Yu Kuai" <yukuai@fnnas.com>
To: "Xiao Ni" <xni@redhat.com>, "Li Nan" <linan666@huaweicloud.com>
Cc: <corbet@lwn.net>, <song@kernel.org>, <hare@suse.de>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-raid@vger.kernel.org>, <yangerkun@huawei.com>,
<yi.zhang@huawei.com>
Subject: Re: [PATCH v9 4/5] md: add check_new_feature module parameter
Date: Thu, 6 Nov 2025 11:44:51 +0800 [thread overview]
Message-ID: <2c1ab8fc-99ac-44fd-892c-2eeedb9581f4@fnnas.com> (raw)
In-Reply-To: <CALTww29v7kKgDyWqUZnteNqHDEH9_KBRY+HtSMJoquMv0sTwkg@mail.gmail.com>
Hi,
在 2025/11/4 15:17, Xiao Ni 写道:
> On Tue, Nov 4, 2025 at 10:52 AM Li Nan <linan666@huaweicloud.com> wrote:
>>
>>
>> 在 2025/11/4 9:47, Xiao Ni 写道:
>>> On Mon, Nov 3, 2025 at 9:06 PM <linan666@huaweicloud.com> wrote:
>>>> From: Li Nan <linan122@huawei.com>
>>>>
>>>> Raid checks if pad3 is zero when loading superblock from disk. Arrays
>>>> created with new features may fail to assemble on old kernels as pad3
>>>> is used.
>>>>
>>>> Add module parameter check_new_feature to bypass this check.
>>>>
>>>> Signed-off-by: Li Nan <linan122@huawei.com>
>>>> ---
>>>> drivers/md/md.c | 12 +++++++++---
>>>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>>>> index dffc6a482181..5921fb245bfa 100644
>>>> --- a/drivers/md/md.c
>>>> +++ b/drivers/md/md.c
>>>> @@ -339,6 +339,7 @@ static int start_readonly;
>>>> */
>>>> static bool create_on_open = true;
>>>> static bool legacy_async_del_gendisk = true;
>>>> +static bool check_new_feature = true;
>>>>
>>>> /*
>>>> * We have a system wide 'event count' that is incremented
>>>> @@ -1850,9 +1851,13 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
>>>> }
>>>> if (sb->pad0 ||
>>>> sb->pad3[0] ||
>>>> - memcmp(sb->pad3, sb->pad3+1, sizeof(sb->pad3) - sizeof(sb->pad3[1])))
>>>> - /* Some padding is non-zero, might be a new feature */
>>>> - return -EINVAL;
>>>> + memcmp(sb->pad3, sb->pad3+1, sizeof(sb->pad3) - sizeof(sb->pad3[1]))) {
>>>> + pr_warn("Some padding is non-zero on %pg, might be a new feature\n",
>>>> + rdev->bdev);
>>>> + if (check_new_feature)
>>>> + return -EINVAL;
>>>> + pr_warn("check_new_feature is disabled, data corruption possible\n");
>>>> + }
>>>>
>>>> rdev->preferred_minor = 0xffff;
>>>> rdev->data_offset = le64_to_cpu(sb->data_offset);
>>>> @@ -10704,6 +10709,7 @@ module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR);
>>>> module_param_call(new_array, add_named_array, NULL, NULL, S_IWUSR);
>>>> module_param(create_on_open, bool, S_IRUSR|S_IWUSR);
>>>> module_param(legacy_async_del_gendisk, bool, 0600);
>>>> +module_param(check_new_feature, bool, 0600);
>>>>
>>>> MODULE_LICENSE("GPL");
>>>> MODULE_DESCRIPTION("MD RAID framework");
>>>> --
>>>> 2.39.2
>>>>
>>> Hi
>>>
>>> Thanks for finding this problem in time. The default of this kernel
>>> module is true. I don't think people can check new kernel modules
>>> after updating to a new kernel. They will find the array can't
>>> assemble and report bugs. You already use pad3, is it good to remove
>>> the check about pad3 directly here?
>>>
>>> By the way, have you run the regression tests?
>>>
>>> Regards
>>> Xiao
>>>
>>>
>>> .
>> Hi Xiao.
>>
>> Thanks for your review.
>>
>> Deleting this check directly is risky. For example, in configurable LBS:
>> if user sets LBS to 4K, the LBS of a RAID array assembled on old kernel
>> becomes 512. Forcing use of this array then risks data loss -- the
>> original issue this feature want to solve.
> You're right, we can't delete the check.
> For the old kernel, the array which has specified logical size can't
> be assembled. This patch still can't fix this problem, because it is
> an old kernel and this patch is for a new kernel, right?
> For existing arrays, they don't have such problems. They can be
> assembled after updating to a new kernel.
> So, do we need this patch?
There is a use case for us that user may create the array with old kernel, and
then if something bad happened in the system(may not be related to the array),
user may update to mainline releases and later switch back to our release. We
want a solution that user can still use the array in this case.
>
>> Future features may also have similar risks, so instead of deleting this
>> check directly, I chose to add a module parameter to give users a choice.
>> What do you think?
> Maybe we can add a feature bit to avoid the kernel parameter. This
> feature bit can be set when specifying logical block size.
The situation still stand, for unknown feature bit, we'd better to forbid
assembling the array to prevent data loss by default.
Thanks,
Kuai
>
> Regards
> Xiao
>> --
>> Thanks,
>> Nan
>>
next prev parent reply other threads:[~2025-11-06 3:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 12:57 [PATCH v9 0/5] make logical block size configurable linan666
2025-11-03 12:57 ` [PATCH v9 1/5] md: delete md_redundancy_group when array is becoming inactive linan666
2025-11-03 12:57 ` [PATCH v9 2/5] md: init bioset in mddev_init linan666
2025-11-04 1:24 ` Xiao Ni
2025-11-03 12:57 ` [PATCH v9 3/5] md/raid0: Move queue limit setup before r0conf initialization linan666
2025-11-03 12:57 ` [PATCH v9 4/5] md: add check_new_feature module parameter linan666
2025-11-04 1:47 ` Xiao Ni
2025-11-04 2:52 ` Li Nan
2025-11-04 7:17 ` Xiao Ni
2025-11-06 3:44 ` Yu Kuai [this message]
2025-11-06 12:35 ` Xiao Ni
2025-11-06 12:48 ` Yu Kuai
2025-11-06 13:15 ` Xiao Ni
2025-11-06 13:30 ` Yu Kuai
2025-11-06 14:56 ` Xiao Ni
2025-11-06 17:06 ` Yu Kuai
2025-11-10 2:26 ` Xiao Ni
2025-11-04 7:07 ` Li Nan
2025-11-03 12:57 ` [PATCH v9 5/5] md: allow configuring logical block size linan666
2025-11-10 2:30 ` Xiao Ni
2025-11-11 3:21 ` [PATCH v9 0/5] make logical block size configurable 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=2c1ab8fc-99ac-44fd-892c-2eeedb9581f4@fnnas.com \
--to=yukuai@fnnas.com \
--cc=corbet@lwn.net \
--cc=hare@suse.de \
--cc=linan666@huaweicloud.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=xni@redhat.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@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®