diff options
author | NeilBrown <neilb@suse.de> | 2009-05-11 15:17:05 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-05-11 15:17:05 +1000 |
commit | 112cace627b02a7bc918e857cce03b2cc5fc3d52 (patch) | |
tree | 0cb29269fa3c3f625e6666ccf9ad26cb94ef7dc6 | |
parent | 745f72f61ab363dbc1c19fd00cc29edc42571f62 (diff) |
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>
-rw-r--r-- | Incremental.c | 20 | ||||
-rw-r--r-- | Monitor.c | 2 | ||||
-rw-r--r-- | config.c | 2 | ||||
-rw-r--r-- | mdadm.c | 3 | ||||
-rw-r--r-- | mdadm.conf.5 | 4 | ||||
-rw-r--r-- | mdassemble.c | 2 |
6 files changed, 31 insertions, 2 deletions
diff --git a/Incremental.c b/Incremental.c index c13ea43f..5849d39a 100644 --- a/Incremental.c +++ b/Incremental.c @@ -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, @@ -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; @@ -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); @@ -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; diff --git a/mdadm.conf.5 b/mdadm.conf.5 index 0cea47cf..7654f5f9 100644 --- a/mdadm.conf.5 +++ b/mdadm.conf.5 @@ -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. diff --git a/mdassemble.c b/mdassemble.c index 2b955c5b..e2baf055 100644 --- a/mdassemble.c +++ b/mdassemble.c @@ -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 */ |