Blame SOURCES/0014-Grow-block-n-on-external-volumes.patch

c0f891
From 20e114e334ed6ed3280c37a9a08fb95578393d1a Mon Sep 17 00:00:00 2001
c0f891
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
c0f891
Date: Thu, 19 May 2022 09:16:08 +0200
37f2b0
Subject: [PATCH 14/83] Grow: block -n on external volumes.
c0f891
c0f891
Performing --raid-devices on external metadata volume should be blocked
c0f891
as it causes unwanted behaviour.
c0f891
c0f891
Eg. Performing
c0f891
mdadm -G /dev/md/volume -l10 -n4
c0f891
on r0_d2 inside 4 disk container, returns
c0f891
mdadm: Need 2 spares to avoid degraded array, only have 0.
c0f891
c0f891
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
c0f891
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
c0f891
---
c0f891
 Grow.c | 8 ++++++++
c0f891
 1 file changed, 8 insertions(+)
c0f891
c0f891
diff --git a/Grow.c b/Grow.c
c0f891
index 8a242b0f..f6efbc48 100644
c0f891
--- a/Grow.c
c0f891
+++ b/Grow.c
c0f891
@@ -1892,6 +1892,14 @@ int Grow_reshape(char *devname, int fd,
c0f891
 
c0f891
 		if (retval) {
c0f891
 			pr_err("Cannot read superblock for %s\n", devname);
c0f891
+			close(cfd);
c0f891
+			free(subarray);
c0f891
+			return 1;
c0f891
+		}
c0f891
+
c0f891
+		if (s->raiddisks && subarray) {
c0f891
+			pr_err("--raid-devices operation can be performed on a container only\n");
c0f891
+			close(cfd);
c0f891
 			free(subarray);
c0f891
 			return 1;
c0f891
 		}
c0f891
-- 
37f2b0
2.38.1
c0f891