Hello,
I couldn't but notice that the requirements on softraid level 1 in
base OpenBSD are actually lower than what the current user interface
returns.
The proposed patch does two things :
- It relaxes the check for number of chunks for raid level 1 in the kernel
- it allows building a level 1 array with only one disk.
This patch allows for the following workflow :
- Install OpenBSD on one disk
- format another disk as a single chunk RAID1
- copy the OpenBSD installation on the RAID1 disk
- check that you can boot on RAID1
- boot on bsd.rd and copy the single chunk RAID1 disk to the OpenBSD disk
- reassemble the RAID1 with two disks
It also allows reassembling a RAID1 array with a different number of
chunks, which is terribly useful I think.
-----------------------------
Index: sbin/bioctl/bioctl.c
===================================================================
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.144
diff -u -p -r1.144 bioctl.c
--- sbin/bioctl/bioctl.c 25 Apr 2020 14:37:43 -0000 1.144
+++ sbin/bioctl/bioctl.c 21 Sep 2020 16:38:41 -0000
@@ -841,7 +841,7 @@ bio_createraid(u_int16_t level, char *de
min_disks = 2;
break;
case 1:
- min_disks = 2;
+ min_disks = 1;
break;
case 5:
min_disks = 3;
Index: sys/dev/softraid.c
===================================================================
RCS file: /cvs/src/sys/dev/softraid.c,v
retrieving revision 1.401
diff -u -p -r1.401 softraid.c
--- sys/dev/softraid.c 14 Apr 2020 07:38:21 -0000 1.401
+++ sys/dev/softraid.c 21 Sep 2020 16:38:42 -0000
@@ -3413,7 +3413,7 @@ sr_ioctl_createraid(struct sr_softc *sc,
} else {
/* Ensure we are assembling the correct # of chunks. */
- if (sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) {
+ if (bc->bc_level != 1 &&
sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) {
sr_error(sc, "volume chunk count does not
match metadata "
"chunk count");
goto unwind;
Index: sys/dev/softraid_raid1.c
===================================================================
RCS file: /cvs/src/sys/dev/softraid_raid1.c,v
retrieving revision 1.65
diff -u -p -r1.65 softraid_raid1.c
--- sys/dev/softraid_raid1.c 12 Apr 2016 16:26:54 -0000 1.65
+++ sys/dev/softraid_raid1.c 21 Sep 2020 16:38:42 -0000
@@ -76,8 +76,8 @@ int
sr_raid1_create(struct sr_discipline *sd, struct bioc_createraid *bc,
int no_chunk, int64_t coerced_size)
{
- if (no_chunk < 2) {
- sr_error(sd->sd_sc, "%s requires two or more chunks",
+ if (no_chunk < 1) {
+ sr_error(sd->sd_sc, "%s requires one or more chunks",
sd->sd_name);
return EINVAL;
}
--
Thomas de Grivel
kmx.io
Index: sbin/bioctl/bioctl.c
===================================================================
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.144
diff -u -p -r1.144 bioctl.c
--- sbin/bioctl/bioctl.c 25 Apr 2020 14:37:43 -0000 1.144
+++ sbin/bioctl/bioctl.c 21 Sep 2020 16:38:41 -0000
@@ -841,7 +841,7 @@ bio_createraid(u_int16_t level, char *de
min_disks = 2;
break;
case 1:
- min_disks = 2;
+ min_disks = 1;
break;
case 5:
min_disks = 3;
Index: sys/dev/softraid.c
===================================================================
RCS file: /cvs/src/sys/dev/softraid.c,v
retrieving revision 1.401
diff -u -p -r1.401 softraid.c
--- sys/dev/softraid.c 14 Apr 2020 07:38:21 -0000 1.401
+++ sys/dev/softraid.c 21 Sep 2020 16:38:42 -0000
@@ -3413,7 +3413,7 @@ sr_ioctl_createraid(struct sr_softc *sc,
} else {
/* Ensure we are assembling the correct # of chunks. */
- if (sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) {
+ if (bc->bc_level != 1 && sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) {
sr_error(sc, "volume chunk count does not match metadata "
"chunk count");
goto unwind;
Index: sys/dev/softraid_raid1.c
===================================================================
RCS file: /cvs/src/sys/dev/softraid_raid1.c,v
retrieving revision 1.65
diff -u -p -r1.65 softraid_raid1.c
--- sys/dev/softraid_raid1.c 12 Apr 2016 16:26:54 -0000 1.65
+++ sys/dev/softraid_raid1.c 21 Sep 2020 16:38:42 -0000
@@ -76,8 +76,8 @@ int
sr_raid1_create(struct sr_discipline *sd, struct bioc_createraid *bc,
int no_chunk, int64_t coerced_size)
{
- if (no_chunk < 2) {
- sr_error(sd->sd_sc, "%s requires two or more chunks",
+ if (no_chunk < 1) {
+ sr_error(sd->sd_sc, "%s requires one or more chunks",
sd->sd_name);
return EINVAL;
}