diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2021-02-08 11:20:05 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2021-02-08 11:20:05 +0000 |
commit | a733f9a4a40d77e5a21edccaffc0228499806350 (patch) | |
tree | 05f6a9fd428271961c35026dd4a96115175e5caf /sbin | |
parent | b2724c03b5425168dcc83218f4c41d6713283d87 (diff) |
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 'sbin')
-rw-r--r-- | sbin/bioctl/bioctl.8 | 12 | ||||
-rw-r--r-- | sbin/bioctl/bioctl.c | 16 |
2 files changed, 22 insertions, 6 deletions
diff --git a/sbin/bioctl/bioctl.8 b/sbin/bioctl/bioctl.8 index 38b59584a74..5b324fdbb2e 100644 --- a/sbin/bioctl/bioctl.8 +++ b/sbin/bioctl/bioctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bioctl.8,v 1.108 2020/10/30 13:55:48 schwarze Exp $ +.\" $OpenBSD: bioctl.8,v 1.109 2021/02/08 11:20:03 stsp Exp $ .\" .\" Copyright (c) 2004, 2005 Marco Peereboom .\" @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: October 30 2020 $ +.Dd $Mdocdate: February 8 2021 $ .Dt BIOCTL 8 .Os .Sh NAME @@ -227,6 +227,9 @@ An encrypting discipline. .It Cm c CONCAT: A concatenating discipline. +.It Cm 1C +RAID 1 + CRYPTO: +An encrypting and mirroring discipline. .El .Pp The CONCAT discipline requires a minimum of one chunk, RAID 0 and RAID 1 @@ -234,6 +237,11 @@ disciplines require a minimum of two chunks, RAID 5 requires a minimum of three chunks and the CRYPTO discipline requires exactly one chunk to be provided via .Fl l . +.Pp +The RAID 1C discipline requires a minimum of two chunks when a new volume +is created, and a minimum of one chunk when an existing volume is assembled. +Missing RAID 1C chunks will be marked as offline and must be rebuilt before +they become part of the array again. .It Fl d Detach volume specified by .Ar device . diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index 4cfc7698392..2d2146bb30f 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.145 2020/10/30 13:55:48 schwarze Exp $ */ +/* $OpenBSD: bioctl.c,v 1.146 2021/02/08 11:20:03 stsp Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -131,7 +131,9 @@ main(int argc, char *argv[]) break; case 'c': /* create */ func |= BIOC_CREATERAID; - if (isdigit((unsigned char)*optarg)) { + if (strcmp(optarg, "1C") == 0) { + cr_level = 0x1C; + } else if (isdigit((unsigned char)*optarg)) { cr_level = strtonum(optarg, 0, 10, &errstr); if (errstr != NULL) errx(1, "Invalid RAID level"); @@ -498,6 +500,11 @@ bio_inq(char *name) volname, status, size, bv.bv_dev, percent, seconds); break; + case 0x1C: + printf("%11s %-10s %14s %-7s RAID%X%s%s %s\n", + volname, status, size, bv.bv_dev, + bv.bv_level, percent, seconds, cache); + break; default: printf("%11s %-10s %14s %-7s RAID%u%s%s %s\n", volname, status, size, bv.bv_dev, @@ -847,6 +854,7 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) min_disks = 3; break; case 'C': + case 0x1C: min_disks = 1; break; case 'c': @@ -871,7 +879,7 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) create.bc_flags = BIOC_SCDEVT | cflags; create.bc_key_disk = NODEV; - if (level == 'C' && key_disk == NULL) { + if ((level == 'C' || level == 0x1C) && key_disk == NULL) { memset(&kdfinfo, 0, sizeof(kdfinfo)); memset(&kdfhint, 0, sizeof(kdfhint)); @@ -899,7 +907,7 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) create.bc_opaque_size = sizeof(kdfinfo); create.bc_opaque_flags = BIOC_SOIN; - } else if (level == 'C' && key_disk != NULL) { + } else if ((level == 'C' || level == 0x1C) && key_disk != NULL) { /* Get device number for key disk. */ fd = opendev(key_disk, O_RDONLY, OPENDEV_BLCK, NULL); |