linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Create /dev/md/x link when md device is created
@ 2023-03-09 14:47 miaoguanqin
  2023-03-09 15:57 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 2+ messages in thread
From: miaoguanqin @ 2023-03-09 14:47 UTC (permalink / raw)
  To: Jes Sorensen, Mariusz Tkaczyk, Paul Menzel, linux-raid
  Cc: linfeilong, liuzhiqiang (I), Wu Guanghao, lixiaokeng

After the /dev/mdx is created,we can see that /dev/mdx file is
created.When we reboot machines,we found /dev/md/x will be created,
and map file will be rebuild and changed.

During RAID rebuild after the reboot, we found /dev/md/x is created
with high priority. To consistent behavior, we think that /dev/md/x
should also be created when creating devices.

We modified the logic for creating /dev/mdx,creating /dev/md/x at
the same time.

Signed-off-by: miaoguanqin <miaoguanqin@huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
---
  mdopen.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mdopen.c b/mdopen.c
index 98c54e4..d128396 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -373,11 +373,12 @@ int create_mddev(char *dev, char *name, int autof, 
int trustworthy,

  	sprintf(devname, "/dev/%s", devnm);

-	if (dev && dev[0] == '/')
-		strcpy(chosen, dev);
-	else if (cname[0] == 0)
-		strcpy(chosen, devname);
-
+	if (strncmp(chosen, "/dev/md/", 8) != 0) {
+		if (dev && dev[0] == '/')
+			strcpy(chosen, dev);
+		else if (cname[0] == 0)
+			strcpy(chosen, devname);
+	}
  	/* We have a device number and name.
  	 * If we cannot detect udev, we need to make
  	 * devices and links ourselves.
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Create /dev/md/x link when md device is created
  2023-03-09 14:47 [PATCH] Create /dev/md/x link when md device is created miaoguanqin
@ 2023-03-09 15:57 ` Mariusz Tkaczyk
  0 siblings, 0 replies; 2+ messages in thread
From: Mariusz Tkaczyk @ 2023-03-09 15:57 UTC (permalink / raw)
  To: miaoguanqin
  Cc: Jes Sorensen, Paul Menzel, linux-raid, linfeilong,
	liuzhiqiang (I), Wu Guanghao, lixiaokeng

On Thu, 9 Mar 2023 22:47:27 +0800
miaoguanqin <miaoguanqin@huawei.com> wrote:

> After the /dev/mdx is created,we can see that /dev/mdx file is
> created.When we reboot machines,we found /dev/md/x will be created,
> and map file will be rebuild and changed.
> 
> During RAID rebuild after the reboot, we found /dev/md/x is created
> with high priority. To consistent behavior, we think that /dev/md/x
> should also be created when creating devices.
> 
> We modified the logic for creating /dev/mdx,creating /dev/md/x at
> the same time.
> 
> Signed-off-by: miaoguanqin <miaoguanqin@huawei.com>
> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com>
> ---
>   mdopen.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/mdopen.c b/mdopen.c
> index 98c54e4..d128396 100644
> --- a/mdopen.c
> +++ b/mdopen.c
> @@ -373,11 +373,12 @@ int create_mddev(char *dev, char *name, int autof, 
> int trustworthy,
> 
>   	sprintf(devname, "/dev/%s", devnm);
> 
> -	if (dev && dev[0] == '/')
> -		strcpy(chosen, dev);
> -	else if (cname[0] == 0)
> -		strcpy(chosen, devname);
> -
> +	if (strncmp(chosen, "/dev/md/", 8) != 0) {
> +		if (dev && dev[0] == '/')
> +			strcpy(chosen, dev);
> +		else if (cname[0] == 0)
> +			strcpy(chosen, devname);
> +	}
>   	/* We have a device number and name.
>   	 * If we cannot detect udev, we need to make
>   	 * devices and links ourselves.

Hi miaoguanqin,

Could you please share command used to create? If you are using:
#mdadm --create /dev/mdX

Then it is know issue (at least for me). Please use:
#mdadm --create /dev/md/X

I know that the interface is not consistent but I don't see you solution are
good fix. The create_mddev() is over complicated. Did you run this test:
https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/tree/tests/00createnames

I think that it didn't passed- so we could have a regression.

BTW. I believe that "miaoguanqin" it is your real name, why lowercase?

Thanks,
Mariusz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-09 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 14:47 [PATCH] Create /dev/md/x link when md device is created miaoguanqin
2023-03-09 15:57 ` Mariusz Tkaczyk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).