[PATCH 09/14] FIX: Detect error and rollback metadata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux