]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
New flag --no-degraded
authorNeil Brown <neilb@suse.de>
Fri, 19 May 2006 04:53:22 +0000 (04:53 +0000)
committerNeil Brown <neilb@suse.de>
Fri, 19 May 2006 04:53:22 +0000 (04:53 +0000)
Use to avoid starting arrays if there are
fewer devices available than last time the array was started.
This is only needed with --scan, as with --scan, that behaviour
is the default.

Signed-off-by: Neil Brown <neilb@suse.de>
Assemble.c
ChangeLog
ReadMe.c
mdadm.8
mdadm.c

index 897c33f0261762c81fcd7dae133118debd92ff16..d166c8e48dd2ba125513832c5ed49aa9eaf0d04f 100644 (file)
@@ -66,7 +66,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
         *
         * If !uuidset and scan, look in conf-file for uuid
         *       If not found, give up
-        * If !devlist and scan and uuidset, get list of devs from conf-file 
+        * If !devlist and scan and uuidset, get list of devs from conf-file
         *
         * For each device:
         *   Check superblock - discard if bad
@@ -113,7 +113,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
        int chosen_drive;
        int change = 0;
        int inargv = 0;
-       int start_partial_ok = force || devlist==NULL;
+       int start_partial_ok = (runstop >= 0) && (force || devlist==NULL);
        unsigned int num_devs;
        mddev_dev_t tmpdev;
        struct mdinfo info;
@@ -300,7 +300,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        st->ss->update_super(&info, super, update, devname, verbose);
                        
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
-                       if (dfd < 0) 
+                       if (dfd < 0)
                                fprintf(stderr, Name ": Cannot open %s for superblock update\n",
                                        devname);
                        else if (st->ss->store_super(st, dfd, super))
@@ -332,7 +332,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                            > devices[most_recent].events)
                                most_recent = devcnt;
                }
-               if (info.array.level == -4) 
+               if (info.array.level == -4)
                        /* with multipath, the raid_disk from the superblock is meaningless */
                        i = devcnt;
                else
@@ -546,7 +546,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
        }
        if (force && okcnt == info.array.raid_disks-1) {
                /* FIXME check event count */
-               change += st->ss->update_super(&info, super, "force", 
+               change += st->ss->update_super(&info, super, "force",
                                        devices[chosen_drive].devname, verbose);
        }
 
@@ -614,7 +614,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        inf.major_version = st->ss->major;
                        inf.minor_version = st->minor_version;
                        rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
-               } else 
+               } else
                        rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
 
                if (rv) {
@@ -676,7 +676,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                }
                
                if (runstop == 1 ||
-                   (runstop == 0 && 
+                   (runstop <= 0 &&
                     ( enough(info.array.level, info.array.raid_disks, info.array.layout, avail, okcnt) &&
                       (okcnt >= req_cnt || start_partial_ok)
                             ))) {
@@ -684,7 +684,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                                if (verbose >= 0) {
                                        fprintf(stderr, Name ": %s has been started with %d drive%s",
                                                mddev, okcnt, okcnt==1?"":"s");
-                                       if (okcnt < info.array.raid_disks) 
+                                       if (okcnt < info.array.raid_disks)
                                                fprintf(stderr, " (out of %d)", info.array.raid_disks);
                                        if (sparecnt)
                                                fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
@@ -697,8 +697,11 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        return 1;
                }
                if (runstop == -1) {
-                       fprintf(stderr, Name ": %s assembled from %d drive%s, but not started.\n",
+                       fprintf(stderr, Name ": %s assembled from %d drive%s",
                                mddev, okcnt, okcnt==1?"":"s");
+                       if (okcnt != info.array.raid_disks)
+                               fprintf(stderr, " (out of %d)", info.array.raid_disks);
+                       fprintf(stderr, ", but not started.\n");
                        return 0;
                }
                if (verbose >= 0) {
index 79a4322e3ba38d50a2b796147d11dd057d1b4c35..59bd12121875c421dffabfa998dc4ba75c636bde 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,10 @@ Changes Prior to this release
        bitmap's uuid too.
     -   Add a copy of /proc/mdstat to the mail message send by mdadm
         --monitor.
+    -   New flag --no-degraded to avoid starting arrays if there are
+       fewer devices available than last time the array was started.
+       This is only needed with --scan, as with --scan, that behaviour
+       is the default.
 
 Changes Prior to 2.4.1 release
     -   Honour --write-mostly when adding to an array without persistent
@@ -172,10 +176,10 @@ Changes Prior to 1.9.0 release
     -   Change "dirty" status to "active" as it was confusing people.
     -   --assemble --auto recognises 'standard' name and insists on using
         the appropriate major/minor number for them.
-    -   Remove underscore from partition names, so partitions of 
+    -   Remove underscore from partition names, so partitions of
        "foo" are "foo1", "foo2" etc (unchanged) and partitions of
        "f00" are "f00p1", "f00p2" etc rather than "f00_p1"...
-    -   Use "major", "minor", "makedev" macros instead of 
+    -   Use "major", "minor", "makedev" macros instead of
        "MAJOR", "MINOR", "MKDEV" so that large device numbers work
        on 2.6 (providing you have glibc 2.3.3 or later).
     -   Add some missing closes of open file descriptors.
@@ -206,11 +210,11 @@ Changes Prior to 1.7.0 release
     -   Restore support for uclibc which was broken recently.
     -   Several improvements to the output of --detail, including
         reporting "resyncing" or "recovering" in the state.
-    -   Close filedescriptor at end of --detail (exit would have closed it 
+    -   Close filedescriptor at end of --detail (exit would have closed it
        anyway, so this isn't abig deal).
     -   Report "Sync checkpoint" in --examine output if appropriate.
     -   Add --update=resync for --assemble mode to for a resync when the
-        array is assembled.     
+        array is assembled.
     -   Add support for "raid10", which is under development in 2.6.
        Not documented yet.
     -   --monitor now reads spare-group and spares info from config file
@@ -251,7 +255,7 @@ Changes Prior to 1.5.0 release
     -   Support "--monitor --test" which will generate a test alert
        for each array once, to test notification paths.
     -   Generate RebuildFinished event when rebuild finishes.
-    -   Support for raid6 as found in 2.6.2 - thanks to  
+    -   Support for raid6 as found in 2.6.2 - thanks to
        H. Peter Anvin  <hpa@zytor.com>
     -   Support partitioned md arrays with a different major number and
        naming scheme (md_dX in /proc/mdstat, /dev/md/dXpY in /dev).
@@ -303,7 +307,7 @@ Changes Prior to 1.2.0 release
     -   Fix bug introduced when MD_SB_DISKS dependancy removed, and which
         caused spares not be assembled properly.
     -   Print appropriate message if --monitor --scan decides not to
-       monitor anything.  
+       monitor anything.
 Changes Prior to 1.1.0 release
     -   add --deamonise flag for --monitor - forks and prints pid to stdout
     -   Fix bug so we REALLY clear dirty flag with -Af
@@ -311,7 +315,7 @@ Changes Prior to 1.1.0 release
     -   "mdadm -A /dev/md0" will get info from configfile, even without scan
     -   When assembling multipath arrays, ignore devices which are flagged
         as having errors.
-    -   take --super-minor=dev  to mean "use the minor number of the mddev 
+    -   take --super-minor=dev  to mean "use the minor number of the mddev
        being assembled.
     -   take --config=none to mean "completely ignore config file"
     -   Make --monitor require --scan or a device list.
@@ -423,14 +427,14 @@ Changes Prior to 0.6 release
 
     -   Remove the limit on the number of device names that can be
        given on the command line.
-    -   Fix bug in --assemble --force where it would only update a 
+    -   Fix bug in --assemble --force where it would only update a
        single superblock.
     -   Fix bogus printing of big numbers not being block devices
        when given names of devices that don't exist.
     -   When --assemble --force, consider superblocks with an event
        count that is 1 behind as out-of-date.  Normally they are
        considered up-to-date (as the kernel assumes this too).
-    -   When marking drives as not-failed in the superblock, 
+    -   When marking drives as not-failed in the superblock,
        we also mark them as ACTIVE and SYNC.
     -   Don't start arrays for which not all drives are available unless:
         --scan   which implies that all drives were found automatically
@@ -443,11 +447,11 @@ Changes Prior to 0.6 release
        not started yet.
     -   man page update
     -   Taught Examine to handle --scan. It examines all devices listed
-       on DEVICE lines in the config file.  
+       on DEVICE lines in the config file.
     -   Added --brief (-b) flag for Examine and Detail to print out
        and mdctl.conf compatible description with uuid=, level=,
        disks= and  - for Examine - devices=
-       --examine --brief collects all devices the make the one array and 
+       --examine --brief collects all devices the make the one array and
        list them as one entry.
     -   Added level= and disks= options to ARRAY lines in config files
        so --brief output could be used as-is.
@@ -490,7 +494,7 @@ Changes Prior to 0.5 release
       superblock that says the minor number of the array is 4.
       If the blocks with the right minor number do not all have the
       same UUID, an error is flags and no assembly happens.
+
         array /dev/md3  devices=/dev/hd[abc]2
 
       Assembles /dev/md3 drom /dev/hda2 /dev/hdb2 and/dev/hdc2.  All
@@ -501,9 +505,9 @@ Changes Prior to 0.5 release
 
         array /dev/md2 devices=/dev/hd?2 super-minor=2
 
-      will assemble /dev/md2 using all /dev/hd?2 devices which have a 
+      will assemble /dev/md2 using all /dev/hd?2 devices which have a
       raid superblock with minor number 2.
+
   --create:
       When listing devices for --create, the word "missing" can be
       used to indicate that the respective slot does not have a
@@ -520,15 +524,15 @@ Changes Prior to 0.5 release
       and drive listed for the last slot added as a spare.  If a
       "missing" slot is given, or if --force is given, then --create
       does exactly what you ask and doesn't try to be clever.
-   
+
 
    --follow / --monitor:
 
       This is a new mode.  I couldn't stop my self from picking a name
       starting with F (as current modes start A,B,C,D,E) but I
       relented and provided an alternate name that is somewhat more
-      meaningful. 
+      meaningful.
+
       In this mode, mdctl does not exit, but runs continuously and
       periodically polls all the md devices to see if they have had
       any interested state change.
@@ -539,7 +543,7 @@ Changes Prior to 0.5 release
 
       Options:
          --mail mailaddress  - send Email on any Fail* event
-         --program program   - run the program on any event.  
+         --program program   - run the program on any event.
                   Args are: eventname mddevice subdevice(if-known)
          --delay  seconds    - change from the default 60second pause
                               between polls.
@@ -560,7 +564,7 @@ Changes Prior to 0.5 release
 
   There is now a man page and mdctl.spec (for rpm) thanks to
   Danilo Godec <danci@agenda.si>.
-  
+
   Ofcourse, the man page is now out of date and despite being based on
   the --help output, is not wholy correct.  After I get --follow
   working properly, I plan to revise the various documentation and/or
index 930df5c14d1768f31f423f2a04d1048b3262bfda..f7cc1e32036af9e04f2607a983f617ef9c8fcf37 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -157,6 +157,7 @@ struct option long_options[] = {
     {"stop",      0, 0, 'S'},
     {"readonly",  0, 0, 'o'},
     {"readwrite", 0, 0, 'w'},
+    {"no-degraded",0,0,  4 },
 
     /* For Detail/Examine */
     {"brief",    0, 0, 'b'},
@@ -271,6 +272,7 @@ char OptionHelp[] =
 "  --force       -f   : Assemble the array even if some superblocks appear out-of-date\n"
 "  --update=     -U   : Update superblock: one of sparc2.2, super-minor or summaries\n"
 "  --auto(=p)    -a   : Automatically allocate new (partitioned) md array if needed.\n"
+"  --no-degraded      : Do not start any degraded arrays - default unless --scan.\n"
 "\n"
 " For detail or examine:\n"
 "  --brief       -b   : Just print device name and UUID\n"
@@ -389,6 +391,14 @@ char Help_assemble[] =
 " Those devices are md devices that are to be assembled.  Their identity\n"
 " and components are determined from the config file.\n"
 "\n"
+" If mdadm can not find all of the components for an array, it will assemble\n"
+" it but not activate it unless --run or --scan is given.  To preserve this\n"
+" behaviour even with --scan, add --no-degraded.  Note that \"all of the\n"
+" components\" means as many as were present the last time the array was running\n"
+" as recorded in the superblock.  If the array was already degraded, and\n"
+" the missing device is not a new problem, it will still be assembled.  It\n"
+" is only newly missing devices that cause the array not to be started.\n"
+"\n"
 "Options that are valid with --assemble (-A) are:\n"
 "  --bitmap=          : bitmap file to use wit the array\n"
 "  --uuid=       -u   : uuid of array to assemble. Devices which don't\n"
@@ -403,6 +413,7 @@ char Help_assemble[] =
 "  --force       -f   : Assemble the array even if some superblocks appear\n"
 "                     : out-of-date.  This involves modifying the superblocks.\n"
 "  --update=     -U   : Update superblock: one of sparc2.2, super-minor or summaries\n"
+"  --no-degraded      : Assemble but do not start degraded arrays.\n"
 ;
 
 char Help_manage[] =
diff --git a/mdadm.8 b/mdadm.8
index 82f9bad3e2d0ba6e87031377684d1059279c3958..9c113f0e967da738585c81b633a9cc16b932bbc8 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -603,14 +603,25 @@ Assemble the array even if some superblocks appear out-of-date
 
 .TP
 .BR -R ", " --run
-Attempt to start the array even if fewer drives were given than are
-needed for a full array. Normally if not all drives are found and
+Attempt to start the array even if fewer drives were given than were
+present last time the array was active.  Normally if not all the
+expected drives are found and
 .B --scan
 is not used, then the array will be assembled but not started.
 With
 .B --run
 an attempt will be made to start it anyway.
 
+.TP
+.B --no-degraded
+This is the reverse of
+.B --run
+in that it inhibits the started if array unless all expected drives
+are present.  This is only needed with
+.B --scan
+and can be used if you physical connections to devices are
+not as reliable as you would like.
+
 .TP
 .BR -a ", " "--auto{=no,yes,md,mdp,part}"
 See this option under Create and Build options.
diff --git a/mdadm.c b/mdadm.c
index 26a2744b11160f0cff29cde5362734f02e58a619..acae2d7951d66c9e2cb447740b56972c0d89a1fa 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -577,6 +577,10 @@ int main(int argc, char *argv[])
                        fprintf(stderr, Name ": '--update %s' invalid.  Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update);
                        exit(2);
 
+               case O(ASSEMBLE,4): /* --no-degraded */
+                       runstop = -1; /* --stop isn't allowed for --assemble, so we overload slightly */
+                       continue;
+
                case O(ASSEMBLE,'c'): /* config file */
                case O(MISC, 'c'):
                case O(MONITOR,'c'):