]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Kill: fix when zeroing busy devices.
authorArtur Wojcik <artur.wojcik@intel.com>
Thu, 28 Jan 2010 15:48:44 +0000 (16:48 +0100)
committerNeilBrown <neilb@suse.de>
Fri, 29 Jan 2010 09:53:24 +0000 (20:53 +1100)
mdadm should not wait indefinitely when it trys to reset
superblock on device which is busy (cannot be opened).

Acked-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Kill.c
mdadm.c

diff --git a/Kill.c b/Kill.c
index 63442a628313b5dce794455c9a17220c2435b34d..e73897857dd15df767f8975fb841664ad74d964d 100644 (file)
--- a/Kill.c
+++ b/Kill.c
@@ -34,6 +34,10 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
        /*
         * Nothing fancy about Kill.  It just zeroes out a superblock
         * Definitely not safe.
        /*
         * Nothing fancy about Kill.  It just zeroes out a superblock
         * Definitely not safe.
+        * Returns:
+        *  0 - a zero superblock was successfully written out
+        *  1 - failed to write the zero superblock
+        *  2 - failed to open the device or find a superblock.
         */
 
        int fd, rv = 0;
         */
 
        int fd, rv = 0;
@@ -45,8 +49,7 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
                if (!quiet)
                        fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
                                dev);
                if (!quiet)
                        fprintf(stderr, Name ": Couldn't open %s for write - not zeroing\n",
                                dev);
-               close(fd);
-               return 1;
+               return 2;
        }
        if (st == NULL)
                st = guess_super(fd);
        }
        if (st == NULL)
                st = guess_super(fd);
diff --git a/mdadm.c b/mdadm.c
index d235b2a97e3bf069de30d91790c3adfea750dbc4..be4fbf6dc29519b726a22adf8a733e7a818aae1c 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1367,7 +1367,7 @@ int main(int argc, char *argv[])
                                                do {
                                                        rv |= Kill(dv->devname, NULL, force, q, 0);
                                                        q = 1;
                                                do {
                                                        rv |= Kill(dv->devname, NULL, force, q, 0);
                                                        q = 1;
-                                               } while ((rv & 2) == 0);
+                                               } while (rv == 0);
                                                rv &= ~2;
                                        }
                                        continue;
                                                rv &= ~2;
                                        }
                                        continue;