dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/Detail-differentiate-between-container-and-inactive-.patch

2c1b57
From bb8354598676428af01f23bfb1876c7356d61147 Mon Sep 17 00:00:00 2001
2c1b57
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
2c1b57
Date: Fri, 18 Aug 2017 12:00:23 +0200
2c1b57
Subject: [RHEL7.5 PATCH 01/13] Detail: differentiate between container and
2c1b57
 inactive arrays
2c1b57
2c1b57
Containers used to be handled as active arrays because GET_ARRAY_INFO
2c1b57
ioctl returns valid structure for them. As containers appear as inactive
2c1b57
in sysfs, the output for detail command has changed.
2c1b57
2c1b57
Stop relying on inactive state for containers. Make the output look the
2c1b57
same as in mdadm 4.0.
2c1b57
2c1b57
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 Detail.c | 16 +++++++++++-----
2c1b57
 1 file changed, 11 insertions(+), 5 deletions(-)
2c1b57
2c1b57
diff --git a/Detail.c b/Detail.c
2c1b57
index 2c9fb24..4dcf81d 100644
2c1b57
--- a/Detail.c
2c1b57
+++ b/Detail.c
2c1b57
@@ -80,6 +80,7 @@ int Detail(char *dev, struct context *c)
2c1b57
 	char *avail = NULL;
2c1b57
 	int external;
2c1b57
 	int inactive;
2c1b57
+	int is_container = 0;
2c1b57
 
2c1b57
 	if (fd < 0) {
2c1b57
 		pr_err("cannot open %s: %s\n",
2c1b57
@@ -119,6 +120,8 @@ int Detail(char *dev, struct context *c)
2c1b57
 		}
2c1b57
 	}
2c1b57
 
2c1b57
+	if (array.raid_disks == 0 && external)
2c1b57
+		is_container = 1;
2c1b57
 	if (fstat(fd, &stb) != 0 && !S_ISBLK(stb.st_mode))
2c1b57
 		stb.st_rdev = 0;
2c1b57
 	rv = 0;
2c1b57
@@ -228,7 +231,7 @@ int Detail(char *dev, struct context *c)
2c1b57
 				printf("MD_LEVEL=%s\n", str);
2c1b57
 			printf("MD_DEVICES=%d\n", array.raid_disks);
2c1b57
 		} else {
2c1b57
-			if (!inactive)
2c1b57
+			if (is_container)
2c1b57
 				printf("MD_LEVEL=container\n");
2c1b57
 			printf("MD_DEVICES=%d\n", array.nr_disks);
2c1b57
 		}
2c1b57
@@ -357,13 +360,16 @@ int Detail(char *dev, struct context *c)
2c1b57
 
2c1b57
 	if (c->brief) {
2c1b57
 		mdu_bitmap_file_t bmf;
2c1b57
-		printf("%sARRAY %s", inactive ? "INACTIVE-":"", dev);
2c1b57
+		if (inactive && !is_container)
2c1b57
+			printf("INACTIVE-ARRAY %s", dev);
2c1b57
+		else
2c1b57
+			printf("ARRAY %s", dev);
2c1b57
 		if (c->verbose > 0) {
2c1b57
 			if (array.raid_disks)
2c1b57
 				printf(" level=%s num-devices=%d",
2c1b57
 				       str ? str : "-unknown-",
2c1b57
 				       array.raid_disks);
2c1b57
-			else if (!inactive)
2c1b57
+			else if (is_container)
2c1b57
 				printf(" level=container num-devices=%d",
2c1b57
 				       array.nr_disks);
2c1b57
 			else
2c1b57
@@ -416,7 +422,7 @@ int Detail(char *dev, struct context *c)
2c1b57
 		atime = array.ctime;
2c1b57
 		if (atime)
2c1b57
 			printf("     Creation Time : %.24s\n", ctime(&atime));
2c1b57
-		if (array.raid_disks == 0 && external)
2c1b57
+		if (is_container)
2c1b57
 			str = "container";
2c1b57
 		if (str)
2c1b57
 			printf("        Raid Level : %s\n", str);
2c1b57
@@ -489,7 +495,7 @@ int Detail(char *dev, struct context *c)
2c1b57
 			       " (DELAYED)": "",
2c1b57
 			       (e && e->percent == RESYNC_PENDING) ?
2c1b57
 			       " (PENDING)": "");
2c1b57
-		} else if (inactive) {
2c1b57
+		} else if (inactive && !is_container) {
2c1b57
 			printf("             State : inactive\n");
2c1b57
 		}
2c1b57
 		if (array.raid_disks)
2c1b57
-- 
2c1b57
2.7.4
2c1b57