|
|
3c4af5 |
From 64bf4dff34301a4b44883a8bc03f7835faef121e Mon Sep 17 00:00:00 2001
|
|
|
3c4af5 |
From: Lidong Zhong <lidong.zhong@suse.com>
|
|
|
3c4af5 |
Date: Mon, 14 Sep 2020 10:52:18 +0800
|
|
|
3c4af5 |
Subject: [PATCH 090/108] Detail: show correct raid level when the array is
|
|
|
3c4af5 |
inactive
|
|
|
3c4af5 |
|
|
|
3c4af5 |
Sometimes the raid level in the output of `mdadm -D /dev/mdX` is
|
|
|
3c4af5 |
misleading when the array is in inactive state. Here is a testcase for
|
|
|
3c4af5 |
introduction.
|
|
|
3c4af5 |
1\ creating a raid1 device with two disks. Specify a different hostname
|
|
|
3c4af5 |
rather than the real one for later verfication.
|
|
|
3c4af5 |
|
|
|
3c4af5 |
node1:~ # mdadm --create /dev/md0 --homehost TESTARRAY -o -l 1 -n 2 /dev/sdb
|
|
|
3c4af5 |
/dev/sdc
|
|
|
3c4af5 |
2\ remove one of the devices and reboot
|
|
|
3c4af5 |
3\ show the detail of raid1 device
|
|
|
3c4af5 |
|
|
|
3c4af5 |
node1:~ # mdadm -D /dev/md127
|
|
|
3c4af5 |
/dev/md127:
|
|
|
3c4af5 |
Version : 1.2
|
|
|
3c4af5 |
Raid Level : raid0
|
|
|
3c4af5 |
Total Devices : 1
|
|
|
3c4af5 |
Persistence : Superblock is persistent
|
|
|
3c4af5 |
State : inactive
|
|
|
3c4af5 |
Working Devices : 1
|
|
|
3c4af5 |
|
|
|
3c4af5 |
You can see that the "Raid Level" in /dev/md127 is raid0 now.
|
|
|
3c4af5 |
After step 2\ is done, the degraded raid1 device is recognized
|
|
|
3c4af5 |
as a "foreign" array in 64-md-raid-assembly.rules. And thus the
|
|
|
3c4af5 |
timer to activate the raid1 device is not triggered. The array
|
|
|
3c4af5 |
level returned from GET_ARRAY_INFO ioctl is 0. And the string
|
|
|
3c4af5 |
shown for "Raid Level" is
|
|
|
3c4af5 |
str = map_num(pers, array.level);
|
|
|
3c4af5 |
And the definition of pers is
|
|
|
3c4af5 |
mapping_t pers[] = {
|
|
|
3c4af5 |
{ "linear", LEVEL_LINEAR},
|
|
|
3c4af5 |
{ "raid0", 0},
|
|
|
3c4af5 |
{ "0", 0}
|
|
|
3c4af5 |
...
|
|
|
3c4af5 |
So the misleading "raid0" is shown in this testcase.
|
|
|
3c4af5 |
|
|
|
3c4af5 |
Changelog:
|
|
|
3c4af5 |
v1: don't show "Raid Level" when array is inactive
|
|
|
3c4af5 |
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
|
|
|
3c4af5 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
3c4af5 |
---
|
|
|
3c4af5 |
Detail.c | 5 ++++-
|
|
|
3c4af5 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
3c4af5 |
|
|
|
3c4af5 |
diff --git a/Detail.c b/Detail.c
|
|
|
3c4af5 |
index 24eeba0..b6587c8 100644
|
|
|
3c4af5 |
--- a/Detail.c
|
|
|
3c4af5 |
+++ b/Detail.c
|
|
|
3c4af5 |
@@ -224,7 +224,10 @@ int Detail(char *dev, struct context *c)
|
|
|
3c4af5 |
}
|
|
|
3c4af5 |
|
|
|
3c4af5 |
/* Ok, we have some info to print... */
|
|
|
3c4af5 |
- str = map_num(pers, array.level);
|
|
|
3c4af5 |
+ if (inactive)
|
|
|
3c4af5 |
+ str = map_num(pers, info->array.level);
|
|
|
3c4af5 |
+ else
|
|
|
3c4af5 |
+ str = map_num(pers, array.level);
|
|
|
3c4af5 |
|
|
|
3c4af5 |
if (c->export) {
|
|
|
3c4af5 |
if (array.raid_disks) {
|
|
|
3c4af5 |
--
|
|
|
3c4af5 |
2.7.5
|
|
|
3c4af5 |
|