All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Detail: differentiate between container and inactive arrays
@ 2017-08-18 10:00 Mariusz Tkaczyk
  2017-08-23 17:43 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: Mariusz Tkaczyk @ 2017-08-18 10:00 UTC (permalink / raw)
  To: jes.sorensen; +Cc: linux-raid, Mariusz Tkaczyk

Containers used to be handled as active arrays because GET_ARRAY_INFO 
ioctl returns valid structure for them. As containers appear as inactive 
in sysfs, the output for detail command has changed.

Stop relying on inactive state for containers. Make the output look the 
same as in mdadm 4.0.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
---
 Detail.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/Detail.c b/Detail.c
index 2c9fb24..4dcf81d 100644
--- a/Detail.c
+++ b/Detail.c
@@ -80,6 +80,7 @@ int Detail(char *dev, struct context *c)
 	char *avail = NULL;
 	int external;
 	int inactive;
+	int is_container = 0;
 
 	if (fd < 0) {
 		pr_err("cannot open %s: %s\n",
@@ -119,6 +120,8 @@ int Detail(char *dev, struct context *c)
 		}
 	}
 
+	if (array.raid_disks == 0 && external)
+		is_container = 1;
 	if (fstat(fd, &stb) != 0 && !S_ISBLK(stb.st_mode))
 		stb.st_rdev = 0;
 	rv = 0;
@@ -228,7 +231,7 @@ int Detail(char *dev, struct context *c)
 				printf("MD_LEVEL=%s\n", str);
 			printf("MD_DEVICES=%d\n", array.raid_disks);
 		} else {
-			if (!inactive)
+			if (is_container)
 				printf("MD_LEVEL=container\n");
 			printf("MD_DEVICES=%d\n", array.nr_disks);
 		}
@@ -357,13 +360,16 @@ int Detail(char *dev, struct context *c)
 
 	if (c->brief) {
 		mdu_bitmap_file_t bmf;
-		printf("%sARRAY %s", inactive ? "INACTIVE-":"", dev);
+		if (inactive && !is_container)
+			printf("INACTIVE-ARRAY %s", dev);
+		else
+			printf("ARRAY %s", dev);
 		if (c->verbose > 0) {
 			if (array.raid_disks)
 				printf(" level=%s num-devices=%d",
 				       str ? str : "-unknown-",
 				       array.raid_disks);
-			else if (!inactive)
+			else if (is_container)
 				printf(" level=container num-devices=%d",
 				       array.nr_disks);
 			else
@@ -416,7 +422,7 @@ int Detail(char *dev, struct context *c)
 		atime = array.ctime;
 		if (atime)
 			printf("     Creation Time : %.24s\n", ctime(&atime));
-		if (array.raid_disks == 0 && external)
+		if (is_container)
 			str = "container";
 		if (str)
 			printf("        Raid Level : %s\n", str);
@@ -489,7 +495,7 @@ int Detail(char *dev, struct context *c)
 			       " (DELAYED)": "",
 			       (e && e->percent == RESYNC_PENDING) ?
 			       " (PENDING)": "");
-		} else if (inactive) {
+		} else if (inactive && !is_container) {
 			printf("             State : inactive\n");
 		}
 		if (array.raid_disks)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Detail: differentiate between container and inactive arrays
  2017-08-18 10:00 [PATCH] Detail: differentiate between container and inactive arrays Mariusz Tkaczyk
@ 2017-08-23 17:43 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2017-08-23 17:43 UTC (permalink / raw)
  To: Mariusz Tkaczyk; +Cc: linux-raid

On 08/18/2017 06:00 AM, Mariusz Tkaczyk wrote:
> Containers used to be handled as active arrays because GET_ARRAY_INFO
> ioctl returns valid structure for them. As containers appear as inactive
> in sysfs, the output for detail command has changed.
> 
> Stop relying on inactive state for containers. Make the output look the
> same as in mdadm 4.0.
> 
> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>

Applied!

Thanks,
Jes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-23 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 10:00 [PATCH] Detail: differentiate between container and inactive arrays Mariusz Tkaczyk
2017-08-23 17:43 ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.