mdadm: ARRAY <ignore> lines not correctly handled
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
Quoted 89 lines · On Sun, 11 Nov 2012 03:42:35 -0500 Mike Frysinger <[email protected]> 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.2Creation 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 persistentUpdate Time : Sun Nov 11 03:35:26 2012
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0Layout : left-symmetric
Chunk Size : 512KName : vapier:0 (local to host vapier) UUID : 51b812dc:094ea54b:f8f7b331:9982b16c
Events : 112048Number 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/sdethe man page says i should be able to prevent this from being auto-assembled via
mdamd -Asby doing something like:
ARRAY <ignore> uuid=51b812dc:094ea54b:f8f7b331:9982b16cor perhaps:
DEVICE /dev/sd[abce]
ARRAY <ignore> devices=/dev/sda,/dev/sdb,/dev/sde,/dev/sdcunfortunately, 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);
Quoted 6 lines
...
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 <[email protected]>
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()
Assemble.c +16 -1
@@ -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