]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm.c: Fix error handling for --zero-superblock
authorMariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Mon, 3 Sep 2018 11:52:55 +0000 (13:52 +0200)
committerJes Sorensen <jsorensen@fb.com>
Thu, 27 Sep 2018 14:25:06 +0000 (10:25 -0400)
When Kill() cannot open device or find superblock it return the same
error and mdadm ignores it.
Change error handling in Kill() function. Return error if device is
busy, ignore it only when superblock doesn't exist- assume that metadata
is zeroed.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Kill.c
mdadm.c

diff --git a/Kill.c b/Kill.c
index ff52561d0cbb988c7e3977b2f939ba2e7670c6f2..d4767e29d15007038b3e4910438c24184aec63ed 100644 (file)
--- a/Kill.c
+++ b/Kill.c
@@ -37,7 +37,8 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
         * 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.
+        *  2 - failed to open the device.
+        *  4 - failed to find a superblock.
         */
 
        int fd, rv = 0;
@@ -57,7 +58,7 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
                if (verbose >= 0)
                        pr_err("Unrecognised md component device - %s\n", dev);
                close(fd);
-               return 2;
+               return 4;
        }
        st->ignore_hw_compat = 1;
        rv = st->ss->load_super(st, fd, dev);
diff --git a/mdadm.c b/mdadm.c
index 1cf5c189a0061f8d326e7ffd5b9f01ffb1b07081..25a1abd27615c079b2b805dacfb36628d6ade725 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1959,7 +1959,7 @@ static int misc_list(struct mddev_dev *devlist,
                                        rv |= Kill(dv->devname, NULL, c->force, v, 0);
                                        v = -1;
                                } while (rv == 0);
-                               rv &= ~2;
+                               rv &= ~4;
                        }
                        continue;
                case 'Q':