linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Print concrete error when creating mddev
@ 2022-04-25 13:27 Marius Kittler
  2022-04-26 14:38 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 2+ messages in thread
From: Marius Kittler @ 2022-04-25 13:27 UTC (permalink / raw)
  To: linux-raid; +Cc: Marius Kittler

Example from my testing:
```
mdadm: unexpected failure opening /dev/md127: No such device or address
```

Before it would just print:
```
mdadm: unexpected failure opening /dev/md127
```
---
 mdopen.c | 4 ++--
 util.c   | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mdopen.c b/mdopen.c
index 245be537..c8e5cb9d 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -444,8 +444,8 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 	}
 	mdfd = open_dev_excl(devnm);
 	if (mdfd < 0)
-		pr_err("unexpected failure opening %s\n",
-			devname);
+		pr_err("unexpected failure opening %s: %s\n",
+			devname, strerror(errno));
 	return mdfd;
 }

diff --git a/util.c b/util.c
index cc94f96e..7c8c0bb1 100644
--- a/util.c
+++ b/util.c
@@ -1088,8 +1088,9 @@ int open_dev_excl(char *devnm)
 	long delay = 1000;

 	sprintf(buf, "%d:%d", major(devid), minor(devid));
+	int fd = -1;
 	for (i = 0; i < 25; i++) {
-		int fd = dev_open(buf, flags|O_EXCL);
+		fd = dev_open(buf, flags|O_EXCL);
 		if (fd >= 0)
 			return fd;
 		if (errno == EACCES && flags == O_RDWR) {
@@ -1102,7 +1103,7 @@ int open_dev_excl(char *devnm)
 		if (delay < 200000)
 			delay *= 2;
 	}
-	return -1;
+	return fd;
 }

 int same_dev(char *one, char *two)
--
2.35.3


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

* Re: [PATCH] Print concrete error when creating mddev
  2022-04-25 13:27 [PATCH] Print concrete error when creating mddev Marius Kittler
@ 2022-04-26 14:38 ` Mariusz Tkaczyk
  0 siblings, 0 replies; 2+ messages in thread
From: Mariusz Tkaczyk @ 2022-04-26 14:38 UTC (permalink / raw)
  To: Marius Kittler; +Cc: linux-raid

On Mon, 25 Apr 2022 15:27:45 +0200
Marius Kittler <mariuskittler@gmx.de> wrote:

> Example from my testing:
> ```
> mdadm: unexpected failure opening /dev/md127: No such device or address
> ```
> 
> Before it would just print:
> ```
> mdadm: unexpected failure opening /dev/md127

Hi Marius,
Thanks for the patch. Could you provide reproduction steps?

> diff --git a/util.c b/util.c
> index cc94f96e..7c8c0bb1 100644
> --- a/util.c
> +++ b/util.c
> @@ -1088,8 +1088,9 @@ int open_dev_excl(char *devnm)
>  	long delay = 1000;
> 
>  	sprintf(buf, "%d:%d", major(devid), minor(devid));
> +	int fd = -1;
>  	for (i = 0; i < 25; i++) {
> -		int fd = dev_open(buf, flags|O_EXCL);
> +		fd = dev_open(buf, flags|O_EXCL);
>  		if (fd >= 0)
>  			return fd;
>  		if (errno == EACCES && flags == O_RDWR) {
> @@ -1102,7 +1103,7 @@ int open_dev_excl(char *devnm)
>  		if (delay < 200000)
>  			delay *= 2;
>  	}
> -	return -1;
> +	return fd;

There is no change, it is just a refactor. If you really want to change that,
then please follow kernel coding style guide. Please also run checkpatch script
from kernel source.

Could you add Jes and Coly to CC in v2?

Thanks,
Mariusz

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

end of thread, other threads:[~2022-04-26 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-25 13:27 [PATCH] Print concrete error when creating mddev Marius Kittler
2022-04-26 14:38 ` 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).