config: support "ARRAY <ignore> ..." lines in mdadm.conf

Sometimes we want to ensure particular arrays are never
assembled automatically.  This might include an array made of
devices that are shared between hosts.

To support this, allow ARRAY lines in mdadm.conf to use the word
"ignore" rather than a device name.  Arrays which match such lines
are never automatically assembled (though they can still be assembled
by explicitly giving identification information on the mdadm command
line.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2009-05-11 15:17:05 +10:00
parent 745f72f61a
commit 112cace627
6 changed files with 31 additions and 2 deletions

View File

@ -211,6 +211,15 @@ int Incremental(char *devname, int verbose, int runstop,
match = array_list;
}
if (match && match->devname
&& strcasecmp(match->devname, "<ignore>") == 0) {
if (verbose >= 0)
fprintf(stderr, Name ": array containing %s is explicitly"
" ignored by mdadm.conf\n",
devname);
return 1;
}
/* 3a/ if not, check for homehost match. If no match, continue
* but don't trust the 'name' in the array. Thus a 'random' minor
* number will be assigned, and the device name will be based
@ -746,7 +755,7 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
strcpy(chosen_name, mp->path);
} else {
/* Check in mdadm.conf for devices == devname and
/* Check in mdadm.conf for container == devname and
* member == ra->text_version after second slash.
*/
char *sub = strchr(ra->text_version+1, '/');
@ -784,6 +793,15 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
break;
}
if (match && match->devname &&
strcasecmp(match->devname, "<ignore>") == 0) {
if (verbose > 0)
fprintf(stderr, Name ": array %s/%s is "
"explicitly ignored by mdadm.conf\n",
match->container, match->member);
return 2;
}
mdfd = create_mddev(match ? match->devname : NULL,
ra->name,
autof,

View File

@ -168,6 +168,8 @@ int Monitor(mddev_dev_t devlist,
struct state *st;
if (mdlist->devname == NULL)
continue;
if (strcasecmp(mdlist->devname, "<ignore>") == 0)
continue;
st = malloc(sizeof *st);
if (st == NULL)
continue;

View File

@ -471,7 +471,7 @@ void arrayline(char *line)
mis.member = NULL;
for (w=dl_next(line); w!=line; w=dl_next(w)) {
if (w[0] == '/') {
if (w[0] == '/' || strcasecmp(w, "<ignore>") == 0) {
if (mis.devname)
fprintf(stderr, Name ": only give one device per ARRAY line: %s and %s\n",
mis.devname, w);

View File

@ -1095,6 +1095,9 @@ int main(int argc, char *argv[])
exit(1);
}
for (; array_list; array_list = array_list->next) {
if (array_list->devname &&
strcasecmp(array_list->devname, "<ignore>") == 0)
continue;
if (array_list->autof == 0)
array_list->autof = autof;

View File

@ -96,6 +96,10 @@ 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, such as
.BR /dev/md1 .
Alternately the word
.B <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.
If no device name is given,
.I mdadm
will use various heuristic to determine an appropriate name.

View File

@ -100,6 +100,8 @@ int main(int argc, char *argv[]) {
} else
for (; array_list; array_list = array_list->next) {
mdu_array_info_t array;
if (strcasecmp(array_list->devname, "<ignore>") == 0)
continue;
mdfd = open_mddev(array_list->devname, 0);
if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */