From: NeilBrown <neilb@suse.de>
To: Lukasz Orlowski <lukasz.orlowski@intel.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] Fixed: Part of output missing during RAID creation
Date: Wed, 21 Sep 2011 14:40:14 +1000 [thread overview]
Message-ID: <20110921144014.4f2aa20f@notabene.brown> (raw)
In-Reply-To: <20110920152127.25886.75665.stgit@gklab-128-192.igk.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4769 bytes --]
On Tue, 20 Sep 2011 17:21:27 +0200 Lukasz Orlowski
<lukasz.orlowski@intel.com> wrote:
> Having a container created consisting of 2 disks, when one tried to create
> two volumes of the same RAID level, after attempt of creating the second
> one, part of the message was missing:
>
> #mdadm -C /dev/md/imsm0 -amd -e imsm -n 2 /dev/sda /dev/sdb -R
> #mdadm -C /dev/md/MyVolume1 -amd -l0 -c128 -n 2 /dev/sda /dev/sdb -R
> #mdadm -C /dev/md/MyVolume2 -amd -l0 -c128 -n 2 /dev/sda /dev/sdb -R
>
> After calling the last command, the output was:
> mdadm: create aborted
>
> Now it's:
> mdadm: device /dev/sdb not suitable for this style of array
> mdadm: create aborted
>
> Removed a piece of code attempting to exclusively open a file just to
> check whether it's possible. The reason is that that check was performed
> when it was already determined that a volume cannot be created. Put
> a prompt about the device not being suitable instead.
>
> Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com>
> ---
> Create.c | 12 ++++--------
> 1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/Create.c b/Create.c
> index baadd9f..b5d35e8 100644
> --- a/Create.c
> +++ b/Create.c
> @@ -349,14 +349,10 @@ int Create(struct supertype *st, char *mddev,
> }
>
> if (!st) {
> - int dfd = open(dname, O_RDONLY|O_EXCL);
> - if (dfd >= 0) {
> - fprintf(stderr,
> - Name ": device %s not suitable"
> - " for any style of array\n",
> - dname);
> - close(dfd);
> - }
> + fprintf(stderr,
> + Name ": device %s not suitable"
> + " for this style of array\n",
> + dname);
> fail = 1;
> break;
> }
>
I think I get what you are trying to do here, but I don't like the approach.
The problem is that validate_geometry should be reporting errors but it is
told not to.
I have just committed the following patch. See if it helps.
NeilBrown
From ecbd9e8160e9de9cc28ad869d303506b1dc69715 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 21 Sep 2011 14:39:01 +1000
Subject: [PATCH] Create: improve messages from validate_geometry.
When validate_geometry finds that we haven't committed to
a metadata yet and that the subdev is a member of 'our'
container, it needs to report any errors it finds as Create()
cannot report them effectively.
So make a slight change to the semantics of the 'verbose' flag
and allow validate_geometry to report if it printed any error
messages.
Signed-off-by: NeilBrown <neilb@suse.de>
diff --git a/Create.c b/Create.c
index 8d88aa1..79564c5 100644
--- a/Create.c
+++ b/Create.c
@@ -332,15 +332,25 @@ int Create(struct supertype *st, char *mddev,
char *name = "default";
for(i=0; !st && superlist[i]; i++) {
st = superlist[i]->match_metadata_desc(name);
+ if (!st)
+ continue;
if (do_default_layout)
layout = default_layout(st, level, verbose);
- if (st && !st->ss->validate_geometry
- (st, level, layout, raiddisks,
- &chunk, size*2, dname, &freesize,
- verbose > 0)) {
+ switch (st->ss->validate_geometry(
+ st, level, layout, raiddisks,
+ &chunk, size*2, dname, &freesize,
+ verbose > 0)) {
+ case -1: /* Not valid, message printed, and not
+ * worth checking any further */
+ exit(2);
+ break;
+ case 0: /* Geometry not valid */
free(st);
st = NULL;
chunk = do_default_chunk ? UnSet : chunk;
+ break;
+ case 1: /* All happy */
+ break;
}
}
diff --git a/mdadm.h b/mdadm.h
index bd3063b..8dd37d9 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -702,6 +702,12 @@ extern struct superswitch {
* inter-device dependencies, it should record sufficient details
* so these can be validated.
* Both 'size' and '*freesize' are in sectors. chunk is KiB.
+ * Return value is:
+ * 1: everything is OK
+ * 0: not OK for some reason - if 'verbose', then error was reported.
+ * -1: st->sb was NULL, 'subdev' is a member of a container of this
+ * types, but array is not acceptable for some reason
+ * message was reported even if verbose is 0.
*/
int (*validate_geometry)(struct supertype *st, int level, int layout,
int raiddisks,
diff --git a/super-intel.c b/super-intel.c
index e57d18f..e9d9af8 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5369,7 +5369,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
return validate_geometry_imsm_volume(st, level, layout,
raiddisks, chunk,
size, dev,
- freesize, verbose);
+ freesize, 1)
+ ? 1 : -1;
}
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
prev parent reply other threads:[~2011-09-21 4:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-20 15:21 [PATCH] Fixed: Part of output missing during RAID creation Lukasz Orlowski
2011-09-20 15:21 ` Lukasz Orlowski
2011-09-21 4:40 ` NeilBrown [this message]
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=20110921144014.4f2aa20f@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=lukasz.orlowski@intel.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;
as well as URLs for NNTP newsgroup(s).