NeilBrown: Grow: do not allow size changes with other changes.

Martin F. Krafft madduck at alioth.debian.org
Wed Jan 27 02:03:27 UTC 2010


Module: mdadm
Branch: upstream
Commit: 9ce510be9c71bae002a3b68ad138b164c908150a
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=9ce510be9c71bae002a3b68ad138b164c908150a

Author: NeilBrown <neilb at suse.de>
Date:   Fri Nov  6 17:26:47 2009 +1100

Grow: do not allow size changes with other changes.

A change the reduces the size of an array always happens
before any other change.  So it can cause data to be lost.
By themselves these changes are reversible.  But once another
change has started, the data would be permanently lost.
So recommend data integrity be checked between a size change
and any other change.

Signed-off-by: NeilBrown <neilb at suse.de>

---

 Grow.c  |    9 +++++++++
 mdadm.c |    9 +++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Grow.c b/Grow.c
index 75af6f3..27e0d70 100644
--- a/Grow.c
+++ b/Grow.c
@@ -524,6 +524,15 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 		return 1;
 	}
 
+	if (size >= 0 &&
+	    (chunksize || level!= UnSet || layout_str || raid_disks)) {
+		fprintf(stderr, Name ": cannot change component size at the same time "
+			"as other changes.\n"
+			"   Change size first, then check data is intact before "
+			"making other changes.\n");
+		return 1;
+	}
+
 	if (raid_disks && raid_disks < array.raid_disks && array.level > 1 &&
 	    get_linux_version() < 2006032 &&
 	    !check_env("MDADM_FORCE_FEWER")) {
diff --git a/mdadm.c b/mdadm.c
index 0c51d63..3dc8be9 100644
--- 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");




More information about the pkg-mdadm-commits mailing list