diff options
author | 2021-02-08 11:20:03 +0000 | |
---|---|---|
committer | 2021-02-08 11:20:03 +0000 | |
commit | 01de20b5d7746d27bbd8c656e80c96759d46494b (patch) | |
tree | 1e4d57f2ada6ef4c695d6622bd832cbf526eab3f /sys/dev/softraid.c | |
parent | Revert the convertion of per-process thread into a SMR_TAILQ. (diff) | |
download | wireguard-openbsd-01de20b5d7746d27bbd8c656e80c96759d46494b.tar.xz wireguard-openbsd-01de20b5d7746d27bbd8c656e80c96759d46494b.zip |
Add a RAID1C (raid1 + crypto) softraid(8) discipline.
The RAID1C discipline encrypts data like the CRYPTO discipline, and accepts
multiple chunks during creation and assembly like the RAID1 discipline.
To deal with failing disks a RAID1C volume may be assembled with a smaller
number of chunks than the volume was created with. The volume will then come
up in degraded state. If the volume is now detached and assembled again with
the correct number of chunks, any re-added chunks will require a rebuild.
Consequently, assembling RAID1C volumes requires careful attention to the
chunks passed via 'bioctl -l'. If a chunk is accidentally omitted from the
command line during volume assembly, then this chunk will need to be rebuilt.
At least one known-good chunk is required in order to assemble the volume.
Like CRYPTO, RAID1C supports passphrase and key-disk authentication.
Key-disk based volumes are assembled automatically if the key disk is present
while the system is booting up.
Unlike CRYPTO and RAID1, there is no boot support for RAID1C yet.
RAID1C largely reuses existing code of RAID1 and CRYPTO disciplines.
At present RAID1C's discipline-specific data structure is shared with that
of the CRYPTO discipline to allow re-use of existing CRYPTO code. A custom
RAID1C data structure would require CRYPTO code to access struct sr_crypto
via a pointer instead of via a member field of struct sr_discipline.
ok jsing@
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r-- | sys/dev/softraid.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 2aac992921c..0ffaeb86ca0 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.417 2020/12/16 18:16:34 cheloha Exp $ */ +/* $OpenBSD: softraid.c,v 1.418 2021/02/08 11:20:03 stsp Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -1397,7 +1397,7 @@ sr_boot_assembly(struct sr_softc *sc) * key disk... */ bcr.bc_key_disk = NODEV; - if (bv->sbv_level == 'C') { + if (bv->sbv_level == 'C' || bv->sbv_level == 0x1C) { SLIST_FOREACH(bc, &kdh, sbc_link) { if (bcmp(&bc->sbc_metadata->ssdi.ssd_uuid, &bv->sbv_uuid, @@ -1447,7 +1447,7 @@ sr_boot_assembly(struct sr_softc *sc) bcr.bc_flags = BIOC_SCDEVT | (bv->sbv_flags & BIOC_SCNOAUTOASSEMBLE); - if (bv->sbv_level == 'C' && + if ((bv->sbv_level == 'C' || bv->sbv_level == 0x1C) && bcmp(&sr_bootuuid, &bv->sbv_uuid, sizeof(sr_bootuuid)) == 0) data = sr_bootkey; @@ -2585,7 +2585,8 @@ 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' && + if ((sd->sd_meta->ssdi.ssd_level == 'C' || + sd->sd_meta->ssdi.ssd_level == 0x1C) && sd->mds.mdd_crypto.key_disk != NULL) bv->bv_nodisk++; #endif @@ -2641,7 +2642,8 @@ 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 == 'C' || + sd->sd_meta->ssdi.ssd_level == 0x1C) && sd->mds.mdd_crypto.key_disk != NULL) src = sd->mds.mdd_crypto.key_disk; #endif @@ -3398,7 +3400,11 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, } else { /* Ensure we are assembling the correct # of chunks. */ - if (sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) { + if (bc->bc_level == 0x1C && + sd->sd_meta->ssdi.ssd_chunk_no > no_chunk) { + sr_warn(sc, "trying to bring up %s degraded", + sd->sd_meta->ssd_devname); + } else if (sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) { sr_error(sc, "volume chunk count does not match metadata " "chunk count"); goto unwind; @@ -3977,6 +3983,9 @@ sr_discipline_init(struct sr_discipline *sd, int level) case 'C': sr_crypto_discipline_init(sd); break; + case 0x1C: + sr_raid1c_discipline_init(sd); + break; #endif case 'c': sr_concat_discipline_init(sd); |