Linux RAID subsystem development
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-raid@vger.kernel.org
Subject: Re: mdadm: ARRAY <ignore> lines not correctly handled
Date: Thu, 22 Nov 2012 17:05:06 +1100	[thread overview]
Message-ID: <20121122170506.1da4303f@notabene.brown> (raw)
In-Reply-To: <201211110342.36095.vapier@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 5129 bytes --]

On Sun, 11 Nov 2012 03:42:35 -0500 Mike Frysinger <vapier@gentoo.org> wrote:

> the mdadm.conf man page states:
> The ARRAY lines identify actual arrays.  The second word on the line may be 
> the name of the device where the array is normally assembled, [...].  
> Alternately the word <ignore> (complete with angle brackets) can be given in 
> which case any array which matches the rest of the line will never be 
> automatically assembled.
> 
> so let's say i have a raid that looks like:
> /dev/md0:
>         Version : 1.2
>   Creation Time : Wed Oct 31 16:05:49 2012
>      Raid Level : raid6
>      Array Size : 1953522688 (1863.02 GiB 2000.41 GB)
>   Used Dev Size : 976761344 (931.51 GiB 1000.20 GB)
>    Raid Devices : 4
>   Total Devices : 4
>     Persistence : Superblock is persistent
> 
>     Update Time : Sun Nov 11 03:35:26 2012
>           State : clean 
>  Active Devices : 4
> Working Devices : 4
>  Failed Devices : 0
>   Spare Devices : 0
> 
>          Layout : left-symmetric
>      Chunk Size : 512K
> 
>            Name : vapier:0  (local to host vapier)
>            UUID : 51b812dc:094ea54b:f8f7b331:9982b16c
>          Events : 112048
> 
>     Number   Major   Minor   RaidDevice State
>        0       8       32        0      active sync   /dev/sdc
>        1       8        0        1      active sync   /dev/sda
>        4       8       16        2      active sync   /dev/sdb
>        5       8       64        3      active sync   /dev/sde
> 
> the man page says i should be able to prevent this from being auto-assembled 
> via `mdamd -As` by doing something like:
> ARRAY <ignore> uuid=51b812dc:094ea54b:f8f7b331:9982b16c
> 
> or perhaps:
> DEVICE /dev/sd[abce]
> ARRAY <ignore> devices=/dev/sda,/dev/sdb,/dev/sde,/dev/sdc
> 
> unfortunately, this turns out to not be the case.  mdadm goes ahead and auto-
> assembles things anyways.  looking at the code, it seems that it's due to the 
> code falling back if nothing was detected:
> mdadm.c
> ...
>     do {
>         failures = 0;
>         successes = 0;
>         rv = 0;
>         for (a = array_list; a ; a = a->next) {
>             int r;
>             if (a->assembled)
>                 continue;
>             if (a->devname &&   
>                 strcasecmp(a->devname, "<ignore>") == 0)
>                 continue;
> 
>             r = Assemble(ss, a->devname,
>                      a, NULL, c);
>             if (r == 0) {
>                 a->assembled = 1;
>                 successes++;
>             } else
>                 failures++;
>             rv |= r;
>             cnt++;
>         }
>     } while (failures && successes);
>     if (c->homehost && cnt == 0) {
>         /* Maybe we can auto-assemble something.
>          * Repeatedly call Assemble in auto-assemble mode
>          * until it fails
>          */
>         int rv2;
>         int acnt;
>         ident->autof = c->autof;
>         do {
>             struct mddev_dev *devlist = conf_get_devs();
>             acnt = 0;
>             do {
>                 rv2 = Assemble(ss, NULL,
>                            ident,
>                            devlist, c);
> ...
> 
> the idea is to be able to have a system with multiple raids (some of which are 
> dormant/backups), blacklist the ones that you want to keep idle, and bring 
> online all the rest.
> -mike

Thanks for the report.
Fixed by the following patch.

Thanks,
NeilBrown

From 66eb2c93a619eb1d79dc653fd91add159aa3d1ff Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Thu, 22 Nov 2012 17:04:20 +1100
Subject: [PATCH] Assemble: ensure that <ignore>d arrays are not
 auto-assembled.

It isn't enough to simply not assemble arrays found to be called
<ignore>, as the final stage of auto-assemble doesn't check for names
in mdadm.conf.

So add a check to Assemble, similar to the check in Incremental()

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/Assemble.c b/Assemble.c
index c2fa096..9ef1bf0 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -362,6 +362,8 @@ static int select_devices(struct mddev_dev *devlist,
 			tmpdev = NULL;
 			goto loop;
 		} else {
+			int rv = 0;
+			struct mddev_ident *match;
 
 			content = *contentp;
 			tst->ss->getinfo_super(tst, content, NULL);
@@ -370,7 +372,20 @@ static int select_devices(struct mddev_dev *devlist,
 					   c->homehost, c->update,
 					   report_missmatch ? devname : NULL))
 				goto loop;
-				
+
+			match = conf_match(tst, content, devname,
+					   report_missmatch ? c->verbose : -1,
+					   &rv);
+			if (!match && rv == 2)
+				goto loop;
+			if (match && match->devname &&
+			    strcasecmp(match->devname, "<ignore>") == 0) {
+				if (report_missmatch)
+					pr_err("%s is a member of an explicitly ignored array\n",
+					       devname);
+				goto loop;
+			}
+
 			/* should be safe to try an exclusive open now, we
 			 * have rejected anything that some other mdadm might
 			 * be looking at

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2012-11-22  6:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-11  8:42 mdadm: ARRAY <ignore> lines not correctly handled Mike Frysinger
2012-11-22  6:05 ` 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=20121122170506.1da4303f@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=vapier@gentoo.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