[PATCH 0/2] Check node nums for cluster raid

STALE3741d

3 messages, 1 author, 2016-05-04 · open the first message on its own page

[PATCH 0/2] Check node nums for cluster raid

From: Guoqing Jiang <hidden>
Date: 2016-05-04 08:33:42

For cluster raid, we do need at least two nodes for it,
the two patches add the checks before create and change
bitmap.

Thanks,
Guoqing    

Guoqing Jiang (2):
  Create: check the node nums when create clustered raid
  super1: don't update node nums if it is not more than 1

 Create.c | 7 ++++++-
 super1.c | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.6.2

[PATCH 1/2] Create: check the node nums when create clustered raid

From: Guoqing Jiang <hidden>
Date: 2016-05-04 08:33:43

It doesn't make sense to create a clustered raid
with only 1 node.

Reported-by: Zhilong Liu <redacted>
Signed-off-by: Guoqing Jiang <redacted>
---
 Create.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Create.c b/Create.c
index 1e4a6ee..717086b 100644
--- a/Create.c
+++ b/Create.c
@@ -114,8 +114,13 @@ int Create(struct supertype *st, char *mddev,
 	unsigned long long newsize;
 
 	int major_num = BITMAP_MAJOR_HI;
-	if (s->bitmap_file && strcmp(s->bitmap_file, "clustered") == 0)
+	if (s->bitmap_file && strcmp(s->bitmap_file, "clustered") == 0) {
 		major_num = BITMAP_MAJOR_CLUSTERED;
+		if (c->nodes <= 1) {
+			pr_err("At least 2 nodes are needed for cluster-md\n");
+			return 1;
+		}
+	}
 
 	memset(&info, 0, sizeof(info));
 	if (s->level == UnSet && st && st->ss->default_geometry)
-- 
2.6.2

[PATCH 2/2] super1: don't update node nums if it is not more than 1

From: Guoqing Jiang <hidden>
Date: 2016-05-04 08:33:44

We at least need two nodes for cluster raid so make the
check before update node nums.

Reported-by: Zhilong Liu <redacted>
Signed-off-by: Guoqing Jiang <redacted>
---
 super1.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/super1.c b/super1.c
index 8d5543f..972b470 100644
--- a/super1.c
+++ b/super1.c
@@ -2394,6 +2394,11 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
 			return -EINVAL;
 		}
 
+		if (bms->version == BITMAP_MAJOR_CLUSTERED && st->nodes <= 1) {
+			pr_err("Warning: cluster-md at least needs two nodes\n");
+			return -EINVAL;
+		}
+
 		/* Each node has an independent bitmap, it is necessary to calculate the
 		 * space is enough or not, first get how many bytes for the total bitmap */
 		bm_space_per_node = calc_bitmap_size(bms, 4096);
-- 
2.6.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help