From: NeilBrown Date: Mon, 11 May 2009 05:17:05 +0000 (+1000) Subject: config: support "ARRAY ..." lines in mdadm.conf X-Git-Tag: mdadm-3.0-rc1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=112cace627b02a7bc918e857cce03b2cc5fc3d52;p=thirdparty%2Fmdadm.git config: support "ARRAY ..." 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 --- 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, "") == 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, "") == 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, diff --git a/Monitor.c b/Monitor.c index 2677f7bf..4b660e49 100644 --- a/Monitor.c +++ b/Monitor.c @@ -168,6 +168,8 @@ int Monitor(mddev_dev_t devlist, struct state *st; if (mdlist->devname == NULL) continue; + if (strcasecmp(mdlist->devname, "") == 0) + continue; st = malloc(sizeof *st); if (st == NULL) continue; diff --git a/config.c b/config.c index 24fbfcf9..66c3964f 100644 --- a/config.c +++ b/config.c @@ -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, "") == 0) { if (mis.devname) fprintf(stderr, Name ": only give one device per ARRAY line: %s and %s\n", mis.devname, w); diff --git a/mdadm.c b/mdadm.c index 4402eba8..3245f0f7 100644 --- a/mdadm.c +++ b/mdadm.c @@ -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, "") == 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 +(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, "") == 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 */