mdadm/mdadm-3.2.3-FIX-Detect-error-and-rollback-metadata.patch

63 lines
1.8 KiB
Diff
Raw Normal View History

From 65a9798b58b4e4de0157043e2b30a738c27eff43 Mon Sep 17 00:00:00 2001
From: Adam Kwolek <adam.kwolek@intel.com>
Date: Fri, 13 Apr 2012 16:52:03 +0200
Subject: [PATCH 09/14] FIX: Detect error and rollback metadata
Some setting size error cases were not detected.
When error occurs, stop setting new size action and rollback metadata
changes.
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
---
Grow.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Grow.c b/Grow.c
index 86d1020..1b45199 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1665,9 +1665,12 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
* understands '0' to mean 'max'.
*/
min_csize = 0;
+ rv = 0;
for (mdi = sra->devs; mdi; mdi = mdi->next) {
- if (sysfs_set_num(sra, mdi, "size", size) < 0)
+ if (sysfs_set_num(sra, mdi, "size", size) < 0) {
+ rv = 1;
break;
+ }
if (array.not_persistent == 0 &&
array.major_version == 0 &&
get_linux_version() < 3001000) {
@@ -1682,11 +1685,16 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
}
}
}
+ if (rv) {
+ fprintf(stderr, Name ": Cannot set size on "
+ "array members.\n");
+ goto size_change_error;
+ }
if (min_csize && size > min_csize) {
fprintf(stderr, Name ": Cannot safely make this array "
"use more than 2TB per device on this kernel.\n");
rv = 1;
- goto release;
+ goto size_change_error;
}
if (min_csize && size == 0) {
/* Don't let the kernel choose a size - it will get
@@ -1748,6 +1756,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
ioctl(fd, GET_ARRAY_INFO, &array);
}
+size_change_error:
if (rv != 0) {
int err = errno;
--
1.7.7.6