dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/mdadm-check-the-nodes-when-operate-clustered1-array.patch

2c1b57
From 9d67f6496c71efbc68b33aea663dbcc1597a0828 Mon Sep 17 00:00:00 2001
2c1b57
From: Zhilong Liu <zlliu@suse.com>
2c1b57
Date: Wed, 1 Mar 2017 18:42:33 +0800
2c1b57
Subject: [RHEL7.5 PATCH 005/169] mdadm:check the nodes when operate
2c1b57
 clustered array
2c1b57
2c1b57
It doesn't make sense to write_bitmap with less than 2 nodes,
2c1b57
in order to avoid 'write_bitmap' received invalid nodes number,
2c1b57
it would be better to do checking nodes in getopt operations.
2c1b57
2c1b57
Signed-off-by: Zhilong Liu <zlliu@suse.com>
2c1b57
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
---
2c1b57
 mdadm.c  | 4 ++--
2c1b57
 super1.c | 9 +--------
2c1b57
 2 files changed, 3 insertions(+), 10 deletions(-)
2c1b57
2c1b57
diff --git a/mdadm.c b/mdadm.c
2c1b57
index 16fd49a..b5ac061 100644
2c1b57
--- a/mdadm.c
2c1b57
+++ b/mdadm.c
2c1b57
@@ -603,8 +603,8 @@ int main(int argc, char *argv[])
2c1b57
 		case O(GROW, Nodes):
2c1b57
 		case O(CREATE, Nodes):
2c1b57
 			c.nodes = parse_num(optarg);
2c1b57
-			if (c.nodes <= 0) {
2c1b57
-				pr_err("invalid number for the number of cluster nodes: %s\n",
2c1b57
+			if (c.nodes < 2) {
2c1b57
+				pr_err("clustered array needs two nodes at least: %s\n",
2c1b57
 					optarg);
2c1b57
 				exit(2);
2c1b57
 			}
2c1b57
diff --git a/super1.c b/super1.c
2c1b57
index 87a74cb..882cd61 100644
2c1b57
--- a/super1.c
2c1b57
+++ b/super1.c
2c1b57
@@ -2380,14 +2380,7 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
2c1b57
 		}
2c1b57
 
2c1b57
 		if (bms->version == BITMAP_MAJOR_CLUSTERED) {
2c1b57
-			if (st->nodes == 1) {
2c1b57
-				/* the parameter for nodes is not valid */
2c1b57
-				pr_err("Warning: cluster-md at least needs two nodes\n");
2c1b57
-				return -EINVAL;
2c1b57
-			} else if (st->nodes == 0)
2c1b57
-				/* --nodes is not specified */
2c1b57
-				break;
2c1b57
-			else if (__cpu_to_le32(st->nodes) < bms->nodes) {
2c1b57
+			if (__cpu_to_le32(st->nodes) < bms->nodes) {
2c1b57
 				/* Since the nodes num is not increased, no need to check the space
2c1b57
 				 * is enough or not, just update bms->nodes */
2c1b57
 				bms->nodes = __cpu_to_le32(st->nodes);
2c1b57
-- 
2c1b57
2.7.4
2c1b57