# \[PATCH 1/1\] It should be FAILED when raid has not enough active disks

- Subsystems: THE REST
- Maintainers: Linus Torvalds
- List: linux-raid
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linux-raid/2021/02/6639892/t

## \[PATCH 1/1\] It should be FAILED when raid has not enough active disks

- From: Xiao Ni \<hidden\>
- Date: 2021-02-09 09:43:27 
- Message: https://ratatoskr.run/linux-raid/2021/02/6639892.md

```text
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 <redacted>
---
 Detail.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Detail.c b/Detail.c
index f8dea6f..cd26fb0 100644
--- 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");
 	}
-- 
2.7.5

```

## Re: \[PATCH 1/1\] It should be FAILED when raid has not enough active disks

- From: Jes Sorensen \<hidden\>
- Date: 2021-03-08 15:51:58 
- Message: https://ratatoskr.run/linux-raid/2021/03/6639961.md

```text
On 2/9/21 4:39 AM, Xiao Ni wrote:
> 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 <redacted>
> ---
>  Detail.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Applied!

Thanks,
Jes

```
