summaryrefslogtreecommitdiffstats
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2012-01-17 13:53:02 +0000
committerjsing <jsing@openbsd.org>2012-01-17 13:53:02 +0000
commitbe27325bd6df0b6ec0103e044ef124d23c3d04dd (patch)
tree44b7729ae3ec18af9a214c0f24fd7f38e64e384f /sys/dev/softraid.c
parentAdd missing ioctl DNPRINTFs and nuke some rogue commas. (diff)
downloadwireguard-openbsd-be27325bd6df0b6ec0103e044ef124d23c3d04dd.tar.xz
wireguard-openbsd-be27325bd6df0b6ec0103e044ef124d23c3d04dd.zip
Check the metadata level against the assembly level before proceeding with
any assembly. This avoids a panic when attempting to assemble a RAID 1 (or other) volume as a RAID 0 volume. Also reorder some of the other checks and diagnostics performed during assembly.
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r--sys/dev/softraid.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index b95a3a869e8..dbe3ef16ff3 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.266 2012/01/17 12:56:38 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.267 2012/01/17 13:53:02 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -3122,17 +3122,10 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
} else {
- if (no_meta != no_chunk)
- printf("%s: trying to bring up %s degraded\n",
- DEVNAME(sc), sd->sd_meta->ssd_devname);
-
- if (sd->sd_meta->ssd_meta_flags & SR_META_DIRTY)
- printf("%s: %s was not shutdown properly\n",
- DEVNAME(sc), sd->sd_meta->ssd_devname);
-
- if (user == 0 && sd->sd_meta_flags & BIOC_SCNOAUTOASSEMBLE) {
- DNPRINTF(SR_D_META, "%s: disk not auto assembled from "
- "metadata\n", DEVNAME(sc));
+ /* Ensure metadata level matches requested assembly level. */
+ if (sd->sd_meta->ssdi.ssd_level != bc->bc_level) {
+ printf("%s: volume level does not match metadata "
+ "level!\n", DEVNAME(sc));
goto unwind;
}
@@ -3143,6 +3136,20 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
goto unwind;
}
+ if (user == 0 && sd->sd_meta_flags & BIOC_SCNOAUTOASSEMBLE) {
+ DNPRINTF(SR_D_META, "%s: disk not auto assembled from "
+ "metadata\n", DEVNAME(sc));
+ goto unwind;
+ }
+
+ if (no_meta != no_chunk)
+ printf("%s: trying to bring up %s degraded\n",
+ DEVNAME(sc), sd->sd_meta->ssd_devname);
+
+ if (sd->sd_meta->ssd_meta_flags & SR_META_DIRTY)
+ printf("%s: %s was not shutdown properly\n",
+ DEVNAME(sc), sd->sd_meta->ssd_devname);
+
SLIST_FOREACH(omi, &sd->sd_meta_opt, omi_link)
if (sd->sd_meta_opt_handler == NULL ||
sd->sd_meta_opt_handler(sd, omi->omi_som) != 0)
@@ -3162,13 +3169,6 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
/* Metadata MUST be fully populated by this point. */
- /* Make sure that metadata level matches requested assembly level. */
- if (sd->sd_meta->ssdi.ssd_level != bc->bc_level) {
- printf("%s: volume level does not match metadata level!\n",
- DEVNAME(sc));
- goto unwind;
- }
-
/* Allocate all resources. */
if ((rv = sd->sd_alloc_resources(sd)))
goto unwind;