Linux RAID subsystem development
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Jes Sorensen <jes.sorensen@gmail.com>
Cc: Linux-RAID <linux-raid@vger.kernel.org>
Subject: [mdadm PATCH 5/5] Detail: handle non-existent arrays better.
Date: Mon, 27 Mar 2017 14:36:56 +1100	[thread overview]
Message-ID: <149058581623.15679.14330532500949622569.stgit@noble> (raw)
In-Reply-To: <149058575542.15679.9804611071393072863.stgit@noble>

If you call "mdadm --detail" with a device file for an array which
doesn't exist, such as by
  mknod /dev/md57 b 9 57
  mdadm --detail /dev/md57

you get an unhelpful message about and inactive RAID0, and return
status is '0'.  This is confusing.

So catch this possibility and print a more useful message, and
return a non-zero status.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 Detail.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Detail.c b/Detail.c
index 509b0d418768..d9d1b7092167 100644
--- a/Detail.c
+++ b/Detail.c
@@ -110,6 +110,14 @@ int Detail(char *dev, struct context *c)
 	if (ioctl(fd, GET_ARRAY_INFO, &array) == 0) {
 		inactive = 0;
 	} else if (errno == ENODEV && sra) {
+		if (sra->array.major_version == -1 &&
+		    sra->array.minor_version == -1 &&
+		    sra->devs == NULL) {
+			pr_err("Array associated with md device %s does not exist.\n", dev);
+			close(fd);
+			sysfs_free(sra);
+			return rv;
+		}
 		array = sra->array;
 		inactive = 1;
 	} else {



  parent reply	other threads:[~2017-03-27  3:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27  3:36 [mdadm PATCH 0/5] Assorted mdadm patch NeilBrown
2017-03-27  3:36 ` [mdadm PATCH 1/5] udev-md-raid-assembly.rules: Skip non-ready devices NeilBrown
2017-03-27  3:36 ` [mdadm PATCH 2/5] Retry HOT_REMOVE_DISK a few times NeilBrown
2017-03-27  7:51   ` 王金浦
2017-03-27  3:36 ` [mdadm PATCH 3/5] Introduce sys_hot_remove_disk() NeilBrown
2017-03-28 18:33   ` jes.sorensen
2017-03-27  3:36 ` NeilBrown [this message]
2017-03-28 18:34   ` [mdadm PATCH 5/5] Detail: handle non-existent arrays better jes.sorensen
2017-03-27  3:36 ` [mdadm PATCH 4/5] Add 'force' flag to *hot_remove_disk() NeilBrown
2017-03-27  8:05   ` 王金浦
2017-03-28 18:33   ` jes.sorensen

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=149058581623.15679.14330532500949622569.stgit@noble \
    --to=neilb@suse.com \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /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