Examine RAID-1C-specific softraid(4) meta-data when checking for
authorstsp <stsp@openbsd.org>
Mon, 29 Aug 2022 19:01:52 +0000 (19:01 +0000)
committerstsp <stsp@openbsd.org>
Mon, 29 Aug 2022 19:01:52 +0000 (19:01 +0000)
a key disk which is associated with a RAID-1C volume.

ok jsing@, style tweak + ok kn@

sys/dev/softraid.c

index 762f6ee..ebf092a 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.425 2022/04/16 19:19:58 naddy Exp $ */
+/* $OpenBSD: softraid.c,v 1.426 2022/08/29 19:01:52 stsp Exp $ */
 /*
  * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
  * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2593,10 +2593,12 @@ sr_ioctl_vol(struct sr_softc *sc, struct bioc_vol *bv)
                bv->bv_nodisk = sd->sd_meta->ssdi.ssd_chunk_no;
 
 #ifdef CRYPTO
-               if ((sd->sd_meta->ssdi.ssd_level == 'C' ||
-                   sd->sd_meta->ssdi.ssd_level == 0x1C) &&
+               if (sd->sd_meta->ssdi.ssd_level == 'C' &&
                    sd->mds.mdd_crypto.key_disk != NULL)
                        bv->bv_nodisk++;
+               else if (sd->sd_meta->ssdi.ssd_level == 0x1C &&
+                   sd->mds.mdd_raid1c.sr1c_crypto.key_disk != NULL)
+                       bv->bv_nodisk++;
 #endif
                if (bv->bv_status == BIOC_SVREBUILD)
                        bv->bv_percent = sr_rebuild_percent(sd);
@@ -2650,10 +2652,13 @@ sr_ioctl_disk(struct sr_softc *sc, struct bioc_disk *bd)
                        src = sd->sd_vol.sv_chunks[bd->bd_diskid];
 #ifdef CRYPTO
                else if (bd->bd_diskid == sd->sd_meta->ssdi.ssd_chunk_no &&
-                   (sd->sd_meta->ssdi.ssd_level == 'C' ||
-                   sd->sd_meta->ssdi.ssd_level == 0x1C) &&
+                   sd->sd_meta->ssdi.ssd_level == 'C' &&
                    sd->mds.mdd_crypto.key_disk != NULL)
                        src = sd->mds.mdd_crypto.key_disk;
+               else if (bd->bd_diskid == sd->sd_meta->ssdi.ssd_chunk_no &&
+                   sd->sd_meta->ssdi.ssd_level == 0x1C &&
+                   sd->mds.mdd_raid1c.sr1c_crypto.key_disk != NULL)
+                       src = sd->mds.mdd_crypto.key_disk;
 #endif
                else
                        break;