Linux RAID subsystem development
 help / color / mirror / Atom feed
* mdadm: ARRAY <ignore> lines not correctly handled
@ 2012-11-11  8:42 Mike Frysinger
  2012-11-22  6:05 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2012-11-11  8:42 UTC (permalink / raw)
  To: linux-raid

[-- Attachment #1: Type: Text/Plain, Size: 3168 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: mdadm: ARRAY <ignore> lines not correctly handled
  2012-11-11  8:42 mdadm: ARRAY <ignore> lines not correctly handled Mike Frysinger
@ 2012-11-22  6:05 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2012-11-22  6:05 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-raid

[-- 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 --]

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

end of thread, other threads:[~2012-11-22  6:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-11  8:42 mdadm: ARRAY <ignore> lines not correctly handled Mike Frysinger
2012-11-22  6:05 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox