Message ID | 167875238571.8008.9808655454439667586@noble.neil.brown.name |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1483913wrd; Mon, 13 Mar 2023 17:33:57 -0700 (PDT) X-Google-Smtp-Source: AK7set+AGvtUZP25r5cI+vLQtDFMiY7+kIM5FTBAQ48Xf2WYPG53xi3ScPiiAPoKmD0Ff4J0UEEp X-Received: by 2002:a05:6122:d8b:b0:3e9:e7cc:7e8b with SMTP id bc11-20020a0561220d8b00b003e9e7cc7e8bmr22676467vkb.4.1678754037046; Mon, 13 Mar 2023 17:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678754037; cv=none; d=google.com; s=arc-20160816; b=C5kKVx0RF3OBhBbvJEwBDh7t/AFTdEugenrUv1UPkHZUIb2Hpnr/oqv38aPmWa3GdY MZ7czHuH6TWFurOTNrX24/i8/AJOIiuR+v0Bobs1ipdbooh+QfRGojn/RhaFuOiwGvV4 fxDgT0pTAz8NLy9lcRb15uvXtroC0zp8Rq9WBqFI8yTqnjbACyI/rJtfuIqSygLy/GKt IF9AKVYa1gbUdhfT62q0m/wMEmvvi9GpuCX+XxNKTUVUTtCmm5Mkv7lcbrlCbY0p2C4B SUEvzgZLvmOipHspwalqmaAW3DTVL6RzHjnKGU08vyHAa1IOj3TB2qgkHEJBrfOIZV6n 8KPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:cc:from:mime-version :content-transfer-encoding:dkim-signature:dkim-signature; bh=IPlAhnHZI1/4kHDq0dvU4vpeu5ilx6uAt/un6KbOR/s=; b=a7UCygxcJTHe9P74uAF3V0Dx/a9FYXVpJlE+KNVbvIyok8aSefeC7Zfh+kEhGm5HZA RbGXikjFjJLhHnfBjdPaUxenwA9DtpM9h/SxneVEcVGNIP4/HzjcXxe8gPwR7uC/PnLx iEDh+Pk2pyfDBGPT69fdaJEB329W5hNTEqA7LNhAEI4eoyvnWRfONoXIkdN5zFOQaNu8 z3RB7Tx+KnUaufKoLK9sytyXAk8ZNbQiGcxOohTefGjhePuEXhC2s2Nk2/cH1cVAWRU1 oFCb75ObJnp+XjQyozBmxZ3Wggtsm3joR/xxwZSxXJzrKCa8rkkvgWt2j36iOOCm5f7b ZGSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=nRdCMirl; dkim=neutral (no key) header.i=@suse.de header.b=QB8GmDsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h141-20020a1f2193000000b00400fc2313e4si582183vkh.51.2023.03.13.17.33.42; Mon, 13 Mar 2023 17:33:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=nRdCMirl; dkim=neutral (no key) header.i=@suse.de header.b=QB8GmDsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjCNAGf (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Mon, 13 Mar 2023 20:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjCNAGd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Mar 2023 20:06:33 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 193518ABF5; Mon, 13 Mar 2023 17:06:33 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B2F19229D2; Tue, 14 Mar 2023 00:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678752391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IPlAhnHZI1/4kHDq0dvU4vpeu5ilx6uAt/un6KbOR/s=; b=nRdCMirlRiU+GSor//GA1fKYBhQAGJJ05d6LvtCuznLaMnPHwNfzIp/cQVXaLTuqi04vjG AspOnM1iNVObgSwv6CJJCnZvSHsNSiBgYKFSMFXYvpNGBCiIndwzgcvvKkUkVk/Zuw7UjV x/0Ct9VhL7pYbnBtbu81zEDi2F5cjIk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678752391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IPlAhnHZI1/4kHDq0dvU4vpeu5ilx6uAt/un6KbOR/s=; b=QB8GmDsmLLVzTdUVS6UkHXLoaDRFha5HvjKOIXSDq8tgrkBdygpmgcUgGZCTHtk3Sm+Frn /0pDHH9mJlG6xfCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6481613A1B; Tue, 14 Mar 2023 00:06:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wsN0B4W6D2SOagAAMHmgww (envelope-from <neilb@suse.de>); Tue, 14 Mar 2023 00:06:29 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" <neilb@suse.de> Cc: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>, "Song Liu" <song@kernel.org>, "Linux regressions mailing list" <regressions@lists.linux.dev>, "linux-raid" <linux-raid@vger.kernel.org>, "LKML" <linux-kernel@vger.kernel.org>, "Nikolay Kichukov" <hijacker@oldum.net> To: Jes Sorensen <jes@trained-monkey.org> Subject: [PATCH - mdadm] mdopen: always try create_named_array() Date: Tue, 14 Mar 2023 11:06:25 +1100 Message-id: <167875238571.8008.9808655454439667586@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760301193311937087?= X-GMAIL-MSGID: =?utf-8?q?1760301193311937087?= |
Series |
[-,mdadm] mdopen: always try create_named_array()
|
|
Commit Message
NeilBrown
March 14, 2023, 12:06 a.m. UTC
mdopen() will use create_named_array() to ask the kernel to create the
given md array, but only if it is given a number or name.
If it is NOT given a name and is required to choose one itself using
find_free_devnm() it does NOT use create_named_array().
On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in
failure to assemble an array. This can particularly seen when the
"name" of the array begins with a host name different to the name of the
host running the command.
So add the missing call to create_named_array().
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074
Signed-off-by: NeilBrown <neilb@suse.de>
---
mdopen.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Tue, 14 Mar 2023 11:06:25 +1100 "NeilBrown" <neilb@suse.de> wrote: > mdopen() will use create_named_array() to ask the kernel to create the > given md array, but only if it is given a number or name. > If it is NOT given a name and is required to choose one itself using > find_free_devnm() it does NOT use create_named_array(). > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > failure to assemble an array. This can particularly seen when the > "name" of the array begins with a host name different to the name of the > host running the command. > > So add the missing call to create_named_array(). > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > Signed-off-by: NeilBrown <neilb@suse.de> > --- > mdopen.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mdopen.c b/mdopen.c > index d18c931996d2..810f79a3d19a 100644 > --- a/mdopen.c > +++ b/mdopen.c > @@ -370,6 +370,7 @@ int create_mddev(char *dev, char *name, int autof, int > trustworthy, } > if (block_udev) > udev_block(devnm); > + create_named_array(devnm); > } > > sprintf(devname, "/dev/%s", devnm); Hi Neil, Thanks for handling that. I didn't have time to get into this topic yet. I trust you and I believe that it is a good fix but I cannot verify it by standard code review- the code is to complex. Could you please add test for it to prove it works this way at least for following cases? - mdadm -CR /dev/md/name - mdadm -CR name - mdadm -CR /dev/md_name - mdadm -CR /dev/mdX, where X is a number. You can disable creation via open temporarily by changing value in /sys/module/md_mod/parameters/new_array that should be enough for verification. For code: Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Thanks, Mariusz
On 3/13/23 20:06, NeilBrown wrote: > > mdopen() will use create_named_array() to ask the kernel to create the > given md array, but only if it is given a number or name. > If it is NOT given a name and is required to choose one itself using > find_free_devnm() it does NOT use create_named_array(). > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > failure to assemble an array. This can particularly seen when the > "name" of the array begins with a host name different to the name of the > host running the command. > > So add the missing call to create_named_array(). > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > Signed-off-by: NeilBrown <neilb@suse.de> Applied! Thanks, Jes
On Mon, 20 Mar 2023, Jes Sorensen wrote: > On 3/13/23 20:06, NeilBrown wrote: > > > > mdopen() will use create_named_array() to ask the kernel to create the > > given md array, but only if it is given a number or name. > > If it is NOT given a name and is required to choose one itself using > > find_free_devnm() it does NOT use create_named_array(). > > > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > > failure to assemble an array. This can particularly seen when the > > "name" of the array begins with a host name different to the name of the > > host running the command. > > > > So add the missing call to create_named_array(). > > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > > Signed-off-by: NeilBrown <neilb@suse.de> > > Applied! Thanks. Do you have plans for releasing 4.3? I'd like this patch to be in a numbered release for at least a few months before we change the kernel Kconfig to allow md to be built without CONFIG_BLOCK_LEGACY_AUTOLOAD. Thanks, NeilBrown
On 3/19/23 18:09, NeilBrown wrote: > On Mon, 20 Mar 2023, Jes Sorensen wrote: >> On 3/13/23 20:06, NeilBrown wrote: >>> >>> mdopen() will use create_named_array() to ask the kernel to create the >>> given md array, but only if it is given a number or name. >>> If it is NOT given a name and is required to choose one itself using >>> find_free_devnm() it does NOT use create_named_array(). >>> >>> On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in >>> failure to assemble an array. This can particularly seen when the >>> "name" of the array begins with a host name different to the name of the >>> host running the command. >>> >>> So add the missing call to create_named_array(). >>> >>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 >>> Signed-off-by: NeilBrown <neilb@suse.de> >> >> Applied! > > Thanks. > > Do you have plans for releasing 4.3? I'd like this patch to be in a > numbered release for at least a few months before we change the kernel > Kconfig to allow md to be built without CONFIG_BLOCK_LEGACY_AUTOLOAD. No immediate plans, but no reason why we shouldn't do it. I think Mariusz has some pending changes he wants to get in as well, like the error number stuff. So lets make this a call for submitting changes for mdadm that are needed for the next release. Thanks, Jes
On Mon, 20 Mar 2023 13:15:35 -0400 Jes Sorensen <jes@trained-monkey.org> wrote: > On 3/19/23 18:09, NeilBrown wrote: > > On Mon, 20 Mar 2023, Jes Sorensen wrote: > >> On 3/13/23 20:06, NeilBrown wrote: > >>> > >>> mdopen() will use create_named_array() to ask the kernel to create the > >>> given md array, but only if it is given a number or name. > >>> If it is NOT given a name and is required to choose one itself using > >>> find_free_devnm() it does NOT use create_named_array(). > >>> > >>> On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > >>> failure to assemble an array. This can particularly seen when the > >>> "name" of the array begins with a host name different to the name of the > >>> host running the command. > >>> > >>> So add the missing call to create_named_array(). > >>> > >>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > >>> Signed-off-by: NeilBrown <neilb@suse.de> > >> > >> Applied! > > > > Thanks. > > > > Do you have plans for releasing 4.3? I'd like this patch to be in a > > numbered release for at least a few months before we change the kernel > > Kconfig to allow md to be built without CONFIG_BLOCK_LEGACY_AUTOLOAD. > > No immediate plans, but no reason why we shouldn't do it. I think > Mariusz has some pending changes he wants to get in as well, like the > error number stuff. > > So lets make this a call for submitting changes for mdadm that are > needed for the next release. > Hi Jes, My patches around names (where I added those errors) will be too risky to be merged and released in short period. I'm going to limit the supported characters for names- it could bring regressions in some non obvious cases and I would like to give user time to accept it and adopt their solutions to new naming policy. Let me see if the patches recently merged doesn't bring any critical regression, and we are free to go I think :) I will back with a results soon. Thanks, Mariusz
On Tue, Mar 14, 2023 at 8:08 AM NeilBrown <neilb@suse.de> wrote: > > > mdopen() will use create_named_array() to ask the kernel to create the > given md array, but only if it is given a number or name. > If it is NOT given a name and is required to choose one itself using > find_free_devnm() it does NOT use create_named_array(). > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > failure to assemble an array. This can particularly seen when the > "name" of the array begins with a host name different to the name of the > host running the command. > > So add the missing call to create_named_array(). > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 Hi Neil I have two questions, hope you can help to understand the function create_mddev better. Frist, from the comment7 of the bug you mentioned: There are two different sorts names. Note that you almost acknowledged this by writing "name for my md device node" while the documentation only talks about names for "md devices", not for "md device nodes". There are 1/ there are names in /dev or /dev/md/ (device nodes) 2/ there are names that appear in /proc/mdstat and in /sys/block/ (devices) Thanks for the clarification. But it looks like it doesn't work like what you said. For example: mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc --name=test cat /proc/mdstat Personalities : [raid0] md127 : active raid0 sdc[1] sda[0] 3906764800 blocks super 1.2 512k chunks cd /sys/block/md127/md/ In /proc/mdstat and /sys/block, they all use md127 rather than the name(root) Before this patch, it creates a symbol link with the name root rather than test ll /dev/md/root lrwxrwxrwx. 1 root root 8 Mar 21 22:35 /dev/md/root -> ../md127 So "test" which is specified by --name looks like it has little usage. By the way, after this patch, the symbol link /dev/md/root can't be created anymore. Is it a regression problem? Second, are there possibilities that the arguments "dev" and "name" of function create_mddev are null at the same time? After some tests, I found dev can't be null when creating a raid device. It can be checked before calling create_mddev. And we must get a name after creating a raid device. So when assembling a raid device, the name must not be null. So the dev and name can't be null at the same time, right? Best Regards Xiao > Signed-off-by: NeilBrown <neilb@suse.de> > --- > mdopen.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mdopen.c b/mdopen.c > index d18c931996d2..810f79a3d19a 100644 > --- a/mdopen.c > +++ b/mdopen.c > @@ -370,6 +370,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, > } > if (block_udev) > udev_block(devnm); > + create_named_array(devnm); > } > > sprintf(devname, "/dev/%s", devnm); > -- > 2.39.2 >
On Wed, 22 Mar 2023, Xiao Ni wrote: > On Tue, Mar 14, 2023 at 8:08 AM NeilBrown <neilb@suse.de> wrote: > > > > > > mdopen() will use create_named_array() to ask the kernel to create the > > given md array, but only if it is given a number or name. > > If it is NOT given a name and is required to choose one itself using > > find_free_devnm() it does NOT use create_named_array(). > > > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > > failure to assemble an array. This can particularly seen when the > > "name" of the array begins with a host name different to the name of the > > host running the command. > > > > So add the missing call to create_named_array(). > > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > > Hi Neil > > I have two questions, hope you can help to understand the function > create_mddev better. > > Frist, from the comment7 of the bug you mentioned: > > There are two different sorts names. Note that you almost > acknowledged this by writing "name for my md device node" while the > documentation only talks about names for "md devices", not for "md > device nodes". > > There are > 1/ there are names in /dev or /dev/md/ (device nodes) > 2/ there are names that appear in /proc/mdstat and in /sys/block/ (devices) > > Thanks for the clarification. But it looks like it doesn't work like > what you said. > For example: > mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc --name=test > cat /proc/mdstat > Personalities : [raid0] > md127 : active raid0 sdc[1] sda[0] > 3906764800 blocks super 1.2 512k chunks > cd /sys/block/md127/md/ > > In /proc/mdstat and /sys/block, they all use md127 rather than the name(root) Try again with "CREATE names=yes" in /etc/mdadm.conf. mdadm generally tries to keep: - the names in /dev/ - the names in /dev/md/ - the names in /proc/mdstat - the names stored in the metadata in sync. It can only do this when: - you enabled "names=yes" - you don't confuse it by specifying a device name (/dev/md/root) that is different from the metadata names "test". If you don't have "names=yes" then the name in /proc/mdstat and the name in /dev/md* will be numeric. The name in /dev/md/ and the name in the metadata can be different and will usually be the same. If you explicitly give a different name with --name= than the device name then obviously they will be different. If you then stop the array and restart with "mdadm -As" or "mdadm -I /dev/sda; mdadm -I /dev/sdb" then mdadm will create a name in /dev/md/ that matches the name in the metadata. > > Before this patch, it creates a symbol link with the name root rather than test > ll /dev/md/root > lrwxrwxrwx. 1 root root 8 Mar 21 22:35 /dev/md/root -> ../md127 That is what you asked it to do. > > So "test" which is specified by --name looks like it has little usage. > It is stored in the metadata. You can see it in --examine output. If you reassemble the array without specifying a device name, it will use the name "test". > > By the way, after this patch, the symbol link /dev/md/root can't be > created anymore. > Is it a regression problem? I cannot reproduce any problem like that. Please provide a sequence of steps so that I can try to duplicate it. > > Second, are there possibilities that the arguments "dev" and "name" of > function create_mddev > are null at the same time? No. For Build or Create, dev is never NULL. For Assemble and Incremental, name is never NULL. > After some tests, I found dev can't be null when creating a raid > device. It can be checked before > calling create_mddev. And we must get a name after creating a raid > device. So when assembling > a raid device, the name must not be null. So the dev and name can't be > null at the same time, right? Correct. NeilBrown > > Best Regards > Xiao > > > > Signed-off-by: NeilBrown <neilb@suse.de> > > --- > > mdopen.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/mdopen.c b/mdopen.c > > index d18c931996d2..810f79a3d19a 100644 > > --- a/mdopen.c > > +++ b/mdopen.c > > @@ -370,6 +370,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, > > } > > if (block_udev) > > udev_block(devnm); > > + create_named_array(devnm); > > } > > > > sprintf(devname, "/dev/%s", devnm); > > -- > > 2.39.2 > > > >
On Wed, 22 Mar 2023 14:24:49 +1100 "NeilBrown" <neilb@suse.de> wrote: > On Wed, 22 Mar 2023, Xiao Ni wrote: > > On Tue, Mar 14, 2023 at 8:08 AM NeilBrown <neilb@suse.de> wrote: > > > > > > > > > mdopen() will use create_named_array() to ask the kernel to create the > > > given md array, but only if it is given a number or name. > > > If it is NOT given a name and is required to choose one itself using > > > find_free_devnm() it does NOT use create_named_array(). > > > > > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > > > failure to assemble an array. This can particularly seen when the > > > "name" of the array begins with a host name different to the name of the > > > host running the command. > > > > > > So add the missing call to create_named_array(). > > > > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > > > > Hi Neil > > > > I have two questions, hope you can help to understand the function > > create_mddev better. > > > > Frist, from the comment7 of the bug you mentioned: > > > > There are two different sorts names. Note that you almost > > acknowledged this by writing "name for my md device node" while the > > documentation only talks about names for "md devices", not for "md > > device nodes". > > > > There are > > 1/ there are names in /dev or /dev/md/ (device nodes) > > 2/ there are names that appear in /proc/mdstat and in /sys/block/ (devices) > > > > Thanks for the clarification. But it looks like it doesn't work like > > what you said. > > For example: > > mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc --name=test > > cat /proc/mdstat > > Personalities : [raid0] > > md127 : active raid0 sdc[1] sda[0] > > 3906764800 blocks super 1.2 512k chunks > > cd /sys/block/md127/md/ > > > > In /proc/mdstat and /sys/block, they all use md127 rather than the > > name(root) > > Try again with "CREATE names=yes" in /etc/mdadm.conf. > > mdadm generally tries to keep: > - the names in /dev/ > - the names in /dev/md/ > - the names in /proc/mdstat > - the names stored in the metadata > > in sync. It can only do this when: > - you enabled "names=yes" > - you don't confuse it by specifying a device name (/dev/md/root) that > is different from the metadata names "test". > > If you don't have "names=yes" then the name in /proc/mdstat and the name > in /dev/md* will be numeric. The name in /dev/md/ and the name in the > metadata can be different and will usually be the same. > > If you explicitly give a different name with --name= than the device > name then obviously they will be different. If you then stop the array > and restart with "mdadm -As" or "mdadm -I /dev/sda; mdadm -I /dev/sdb" > then mdadm will create a name in /dev/md/ that matches the name in the > metadata. > > > > > Before this patch, it creates a symbol link with the name root rather than > > test ll /dev/md/root > > lrwxrwxrwx. 1 root root 8 Mar 21 22:35 /dev/md/root -> ../md127 > > That is what you asked it to do. > > > > > So "test" which is specified by --name looks like it has little usage. > > > > It is stored in the metadata. You can see it in --examine output. If > you reassemble the array without specifying a device name, it will use > the name "test". > > > > > By the way, after this patch, the symbol link /dev/md/root can't be > > created anymore. > > Is it a regression problem? > > I cannot reproduce any problem like that. Please provide a sequence of > steps so that I can try to duplicate it. Hi, It is not caused by this patch. Regression is caused by: https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=8a4ce2c053866ac97feb436c4c85a54446ee0016 We noticed that yesterday. In our case, udev fails to create link, timeout happens. This is caused by missing MD_DEVNAME property in --detail --export. At that is all I know for now. Work in progress. Steps: #mdadm -CR imsm -e imsm -n4 /dev/nvme[0-3]n1 #mdadm -CR vol -l5 -n4 /dev/nvme[0-3]n1 --assume-clean Thanks, Mariusz > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > function create_mddev > > are null at the same time? > > No. For Build or Create, dev is never NULL. For Assemble and > Incremental, name is never NULL. > > > > After some tests, I found dev can't be null when creating a raid > > device. It can be checked before > > calling create_mddev. And we must get a name after creating a raid > > device. So when assembling > > a raid device, the name must not be null. So the dev and name can't be > > null at the same time, right? > > Correct. > > NeilBrown > > > > > > Best Regards > > Xiao > > > > > > > Signed-off-by: NeilBrown <neilb@suse.de> > > > --- > > > mdopen.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/mdopen.c b/mdopen.c > > > index d18c931996d2..810f79a3d19a 100644 > > > --- a/mdopen.c > > > +++ b/mdopen.c > > > @@ -370,6 +370,7 @@ int create_mddev(char *dev, char *name, int autof, > > > int trustworthy, } > > > if (block_udev) > > > udev_block(devnm); > > > + create_named_array(devnm); > > > } > > > > > > sprintf(devname, "/dev/%s", devnm); > > > -- > > > 2.39.2 > > > > > > > >
On Wed, Mar 22, 2023 at 11:25 AM NeilBrown <neilb@suse.de> wrote: > > On Wed, 22 Mar 2023, Xiao Ni wrote: > > On Tue, Mar 14, 2023 at 8:08 AM NeilBrown <neilb@suse.de> wrote: > > > > > > > > > mdopen() will use create_named_array() to ask the kernel to create the > > > given md array, but only if it is given a number or name. > > > If it is NOT given a name and is required to choose one itself using > > > find_free_devnm() it does NOT use create_named_array(). > > > > > > On kernels with CONFIG_BLOCK_LEGACY_AUTOLOAD not set, this can result in > > > failure to assemble an array. This can particularly seen when the > > > "name" of the array begins with a host name different to the name of the > > > host running the command. > > > > > > So add the missing call to create_named_array(). > > > > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217074 > > > > Hi Neil > > > > I have two questions, hope you can help to understand the function > > create_mddev better. > > > > Frist, from the comment7 of the bug you mentioned: > > > > There are two different sorts names. Note that you almost > > acknowledged this by writing "name for my md device node" while the > > documentation only talks about names for "md devices", not for "md > > device nodes". > > > > There are > > 1/ there are names in /dev or /dev/md/ (device nodes) > > 2/ there are names that appear in /proc/mdstat and in /sys/block/ (devices) > > > > Thanks for the clarification. But it looks like it doesn't work like > > what you said. > > For example: > > mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc --name=test > > cat /proc/mdstat > > Personalities : [raid0] > > md127 : active raid0 sdc[1] sda[0] > > 3906764800 blocks super 1.2 512k chunks > > cd /sys/block/md127/md/ > > > > In /proc/mdstat and /sys/block, they all use md127 rather than the name(root) > > Try again with "CREATE names=yes" in /etc/mdadm.conf. > > mdadm generally tries to keep: > - the names in /dev/ > - the names in /dev/md/ > - the names in /proc/mdstat > - the names stored in the metadata > > in sync. It can only do this when: > - you enabled "names=yes" > - you don't confuse it by specifying a device name (/dev/md/root) that > is different from the metadata names "test". > > If you don't have "names=yes" then the name in /proc/mdstat and the name > in /dev/md* will be numeric. The name in /dev/md/ and the name in the > metadata can be different and will usually be the same. > > If you explicitly give a different name with --name= than the device > name then obviously they will be different. If you then stop the array > and restart with "mdadm -As" or "mdadm -I /dev/sda; mdadm -I /dev/sdb" > then mdadm will create a name in /dev/md/ that matches the name in the > metadata. Hi Neil My last email uses non plain text mode. So many people can't see it. I send this again with plain text mode. Thanks for your explanation. It looks like I understand it. In the function create_mddev, it tries to extract the number and name from dev(device node name) or name(metadata name). If it doesn't use --name when creating a raid device, it gets the number and name from dev. 1. If it can get a number, we use the mdNN as the raid name. So the device node name and raid name are the same(.e.g md0). 2. If it can't get a number and doesn't set 'Create names=yes', it automatically chooses a number. In this case the device node name and the raid name are different. For example: mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc The device node name is md127, the raid name is root. Because it doesn't specify --name, so the metadata name is root too. mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc --name=test The device node name is md127, the raid name is root, the metadata name is test. When assembling raid device, it'll use md127 as the device node name too. But the raid name will change to md_test. So it's not a good command to create the raid device. If you want to specify the raid name in /dev/md/root, it's better not to use --name. 3. If it can't get a number and sets 'Create names=yes' in mdadm.conf, it can use the raid name as the device node name. For example: mdadm -CR /dev/md/root -l0 -n2 /dev/sda /dev/sdc The device node name is root, the raid name is root and the metadata name is root too. > > > > > Before this patch, it creates a symbol link with the name root rather than test > > ll /dev/md/root > > lrwxrwxrwx. 1 root root 8 Mar 21 22:35 /dev/md/root -> ../md127 > > That is what you asked it to do. > > > > > So "test" which is specified by --name looks like it has little usage. > > > > It is stored in the metadata. You can see it in --examine output. If > you reassemble the array without specifying a device name, it will use > the name "test". So we can call it metadata name :) > > > > > By the way, after this patch, the symbol link /dev/md/root can't be > > created anymore. > > Is it a regression problem? > > I cannot reproduce any problem like that. Please provide a sequence of > steps so that I can try to duplicate it. In the next email, Mariusz has given the reproduction steps. And it's another patch that causes the regression. > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > function create_mddev > > are null at the same time? > > No. For Build or Create, dev is never NULL. For Assemble and > Incremental, name is never NULL. > > > > After some tests, I found dev can't be null when creating a raid > > device. It can be checked before > > calling create_mddev. And we must get a name after creating a raid > > device. So when assembling > > a raid device, the name must not be null. So the dev and name can't be > > null at the same time, right? > > Correct. Thanks for the confirmation. Now there is a comment like this: "If both name and dev are NULL, we choose a name 'mdXX' or 'mdpXX'". I'll try to write some patches to optimize the function mddev_create and those comments. Best Regards Xiao
On Wed, 22 Mar 2023, NeilBrown wrote: > On Wed, 22 Mar 2023, Xiao Ni wrote: > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > function create_mddev > > are null at the same time? > > No. For Build or Create, dev is never NULL. For Assemble and > Incremental, name is never NULL. > I should clarify this a bit. For Assemble and Incremental, "name" is never NULL *but* it might be an empty string. So: if (name && name[0] == 0) name = NULL; might cause it to become NULL. So you cannot assume there is always either a valid "dev" or a valid "name". "dev" might be NULL, and "name" might be "". NeilBrown
On Thu, Mar 30, 2023 at 5:52 AM NeilBrown <neilb@suse.de> wrote: > > On Wed, 22 Mar 2023, NeilBrown wrote: > > On Wed, 22 Mar 2023, Xiao Ni wrote: > > > > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > > function create_mddev > > > are null at the same time? > > > > No. For Build or Create, dev is never NULL. For Assemble and > > Incremental, name is never NULL. > > > > I should clarify this a bit. For Assemble and Incremental, "name" is > never NULL *but* it might be an empty string. > So: > if (name && name[0] == 0) > name = NULL; > > might cause it to become NULL. So you cannot assume there is always > either a valid "dev" or a valid "name". "dev" might be NULL, and "name" > might be "". > > NeilBrown > Hi Neil The input argument name should be the metadata name. For incremental and assemble, why are there possibilities that the metadata name is invalid? A raid device should have a valid metadata name, right?
On Thu, 30 Mar 2023, Xiao Ni wrote: > On Thu, Mar 30, 2023 at 5:52 AM NeilBrown <neilb@suse.de> wrote: > > > > On Wed, 22 Mar 2023, NeilBrown wrote: > > > On Wed, 22 Mar 2023, Xiao Ni wrote: > > > > > > > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > > > function create_mddev > > > > are null at the same time? > > > > > > No. For Build or Create, dev is never NULL. For Assemble and > > > Incremental, name is never NULL. > > > > > > > I should clarify this a bit. For Assemble and Incremental, "name" is > > never NULL *but* it might be an empty string. > > So: > > if (name && name[0] == 0) > > name = NULL; > > > > might cause it to become NULL. So you cannot assume there is always > > either a valid "dev" or a valid "name". "dev" might be NULL, and "name" > > might be "". > > > > NeilBrown > > > > Hi Neil > > The input argument name should be the metadata name. For incremental > and assemble, why are there possibilities that the metadata name is > invalid? A raid device should have a valid metadata name, right? "should" do, yes. But you can never completely trust data on disk. It is safest to be prepared for "name" being "". NeilBrown
On Thu, Mar 30, 2023 at 11:15 AM NeilBrown <neilb@suse.de> wrote: > > On Thu, 30 Mar 2023, Xiao Ni wrote: > > On Thu, Mar 30, 2023 at 5:52 AM NeilBrown <neilb@suse.de> wrote: > > > > > > On Wed, 22 Mar 2023, NeilBrown wrote: > > > > On Wed, 22 Mar 2023, Xiao Ni wrote: > > > > > > > > > > > > > > Second, are there possibilities that the arguments "dev" and "name" of > > > > > function create_mddev > > > > > are null at the same time? > > > > > > > > No. For Build or Create, dev is never NULL. For Assemble and > > > > Incremental, name is never NULL. > > > > > > > > > > I should clarify this a bit. For Assemble and Incremental, "name" is > > > never NULL *but* it might be an empty string. > > > So: > > > if (name && name[0] == 0) > > > name = NULL; > > > > > > might cause it to become NULL. So you cannot assume there is always > > > either a valid "dev" or a valid "name". "dev" might be NULL, and "name" > > > might be "". > > > > > > NeilBrown > > > > > > > Hi Neil > > > > The input argument name should be the metadata name. For incremental > > and assemble, why are there possibilities that the metadata name is > > invalid? A raid device should have a valid metadata name, right? > > "should" do, yes. But you can never completely trust data on disk. It > is safest to be prepared for "name" being "". > > NeilBrown > That's right, thanks for this explanation :)
diff --git a/mdopen.c b/mdopen.c index d18c931996d2..810f79a3d19a 100644 --- a/mdopen.c +++ b/mdopen.c @@ -370,6 +370,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, } if (block_udev) udev_block(devnm); + create_named_array(devnm); } sprintf(devname, "/dev/%s", devnm);