]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.c
Grow: do not allow size changes with other changes.
[thirdparty/mdadm.git] / mdadm.c
diff --git a/mdadm.c b/mdadm.c
index 0c51d63867840749861342b4e9f64fede2be53a2..3dc8be950121cadb279498d787c653c70be91d76 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1417,9 +1417,18 @@ int main(int argc, char *argv[])
                if (array_size >= 0) {
                        /* alway impose array size first, independent of
                         * anything else
+                        * Do not allow level or raid_disks changes at the
+                        * same time as that can be irreversibly destructive.
                         */
                        struct mdinfo sra;
                        int err;
+                       if (raiddisks || level != UnSet) {
+                               fprintf(stderr, Name ": cannot change array size in same operation "
+                                       "as changing raiddisks or level.\n"
+                                       "    Change size first, then check that data is still intact.\n");
+                               rv = 1;
+                               break;
+                       }
                        sysfs_init(&sra, mdfd, 0);
                        if (array_size == 0)
                                err = sysfs_set_str(&sra, NULL, "array_size", "default");