]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Support --wait-clean --scan
authorDan Williams <dan.j.williams@intel.com>
Wed, 26 Nov 2008 22:39:50 +0000 (15:39 -0700)
committerNeilBrown <neilb@suse.de>
Thu, 27 Nov 2008 04:30:21 +0000 (15:30 +1100)
Its cumbersome to determine which devices to wait for in a system shutdown
script, so hook up --scan.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
mdadm.8
mdadm.c

diff --git a/mdadm.8 b/mdadm.8
index 432241958a4fb219b0f4b3c0623da891d1034fc0..539d499f467f1cc5ac02dadd11b5c3de175377ed 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -1081,10 +1081,11 @@ listed, otherwise it will return failure.
 
 .TP
 .BR \-\-wait\-clean
-For each md device given, arrange for the array to be marked clean as
-soon as possible.  Also, quiesce resync so that the monitor for external
-metadata arrays (mdmon) has an opportunity to checkpoint the resync
-position.
+For each md device given, or each device in /proc/mdstat if
+.B \-\-scan
+is given, arrange for the array to be marked clean as soon as possible.
+Also, quiesce resync so that the monitor for external metadata arrays
+(mdmon) has an opportunity to checkpoint the resync position.
 .I mdadm
 will return with success if the array uses external metadata and we
 successfully waited.  For native arrays this returns immediately as the
diff --git a/mdadm.c b/mdadm.c
index e0f51b7fc87469365935fe7e6a95bb1de451fe86..4101c5b68de74528d6ca972ecce93a9b7ee9de02 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1213,10 +1213,14 @@ int main(int argc, char *argv[])
                                     SparcAdjust, ss, homehost);
                } else {
                        if (devlist == NULL) {
-                               if (devmode=='D' && scan) {
-                                       /* apply --detail to all devices in /proc/mdstat */
+                               if ((devmode=='D' || devmode == Waitclean) && scan) {
+                                       /* apply --detail or --wait-clean to
+                                        * all devices in /proc/mdstat
+                                        */
                                        struct mdstat_ent *ms = mdstat_read(0, 1);
                                        struct mdstat_ent *e;
+                                       int v = verbose>1?0:verbose+1;
+
                                        for (e=ms ; e ; e=e->next) {
                                                char *name = get_md_name(e->devnum);
 
@@ -1225,8 +1229,12 @@ int main(int argc, char *argv[])
                                                                e->dev);
                                                        continue;
                                                }
-                                               rv |= Detail(name, verbose>1?0:verbose+1,
-                                                            export, test, homehost);
+                                               if (devmode == 'D')
+                                                       rv |= Detail(name, v,
+                                                                    export, test,
+                                                                    homehost);
+                                               else
+                                                       rv |= WaitClean(name, v);
                                                put_md_name(name);
                                        }
                                } else  if (devmode == 'S' && scan) {