]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
config: support "ARRAY <ignore> ..." lines in mdadm.conf
authorNeilBrown <neilb@suse.de>
Mon, 11 May 2009 05:17:05 +0000 (15:17 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 11 May 2009 05:17:05 +0000 (15:17 +1000)
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>
Incremental.c
Monitor.c
config.c
mdadm.c
mdadm.conf.5
mdassemble.c

index c13ea43fb385f7acbc0c8ae2b1baca376e05cfa7..5849d39aa4d9e03ae4d1def8e8d17669464b1be5 100644 (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,
index 2677f7bf9d9c5f14243776c48237a945847104e7..4b660e492cb596a77cc131fabd11cd30b6e74bdd 100644 (file)
--- 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, "<ignore>") == 0)
+                               continue;
                        st = malloc(sizeof *st);
                        if (st == NULL)
                                continue;
index 24fbfcf92ee0524b7c392ce4db400e14e1bab90a..66c3964ff3e7c579d6f9eba5e33b3b04dfbbe83d 100644 (file)
--- 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, "<ignore>") == 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 4402eba846762325cc206c330af6e144d257c5ca..3245f0f7483ae722d162f026aa0709663e5fb800 100644 (file)
--- 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, "<ignore>") == 0)
+                                       continue;
                                if (array_list->autof == 0)
                                        array_list->autof = autof;
                                
index 0cea47cf9f35fcb8b5d84eee1c11469b126f05b4..7654f5f95b3e16567f79033df304e4b667071c06 100644 (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.
index 2b955c5bb718e22610d012cd85f2905f7169af24..e2baf055b558e00881b4be83e3aa467879be1a12 100644 (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 */