]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
It should be FAILED when raid has not enough active disks
authorXiao Ni <xni@redhat.com>
Tue, 9 Feb 2021 09:39:51 +0000 (17:39 +0800)
committerJes Sorensen <jsorensen@fb.com>
Mon, 8 Mar 2021 15:50:37 +0000 (10:50 -0500)
It can't remove the disk if there are not enough disks. For example, raid5 can't remove the
second disk. If the second disk is unplug from machine, it's better show missing and the raid
should be FAILED. It's better for administrator to monitor the raid.

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Detail.c

index f8dea6fdf715320d679d1ccf28eba210ba7a4d41..cd26fb0f6271efd4f91e82cecaba27bd9f4e9263 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -355,9 +355,14 @@ int Detail(char *dev, struct context *c)
        avail = xcalloc(array.raid_disks, 1);
 
        for (d = 0; d < array.raid_disks; d++) {
-
-               if ((disks[d*2].state & (1<<MD_DISK_SYNC)) ||
-                   (disks[d*2+1].state & (1<<MD_DISK_SYNC))) {
+               char *dv, *dv_rep;
+               dv = map_dev_preferred(disks[d*2].major,
+                               disks[d*2].minor, 0, c->prefer);
+               dv_rep = map_dev_preferred(disks[d*2+1].major,
+                               disks[d*2+1].minor, 0, c->prefer);
+
+               if ((dv && (disks[d*2].state & (1<<MD_DISK_SYNC))) ||
+                   (dv_rep && (disks[d*2+1].state & (1<<MD_DISK_SYNC)))) {
                        avail_disks ++;
                        avail[d] = 1;
                } else
@@ -789,7 +794,8 @@ This is pretty boring
                                                       &max_devices, n_devices);
                        else
                                printf("   %s", dv);
-               }
+               } else if (disk.major | disk.minor)
+                       printf("   missing");
                if (!c->brief)
                        printf("\n");
        }