summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2009-11-22 16:56:07 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2009-11-22 16:56:07 +0000
commitdad83ca4add1d4ab78a14af26a8318fb0a86de80 (patch)
tree3c45dc77f5238b309ee1b498b3f47d78d5f6a17f /sys
parent78dee446453950a88e5f8f65b9a0af10a81615ff (diff)
Ensure that chunks are not already in use when creating a volume.
ok marco@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/softraid.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 1a76d4dc50c..c623d64abcd 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.178 2009/11/15 13:32:04 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.179 2009/11/22 16:56:06 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2684,6 +2684,7 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
struct sr_chunk *ch_entry;
struct device *dev, *dev2;
struct scsibus_attach_args saa;
+ char devname[32];
DNPRINTF(SR_D_IOCTL, "%s: sr_ioctl_createraid(%d)\n",
DEVNAME(sc), user);
@@ -2706,6 +2707,16 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
cl = &sd->sd_vol.sv_chunk_list;
SLIST_INIT(cl);
+ /* Ensure that chunks are not already in use. */
+ for (i = 0; i < no_chunk; i++) {
+ if (sr_chunk_in_use(sc, dt[i]) != BIOC_SDINVALID) {
+ sr_meta_getdevname(sc, dt[i], devname, sizeof(devname));
+ printf("%s: chunk %s already in use\n",
+ DEVNAME(sc), devname);
+ goto unwind;
+ }
+ }
+
sd->sd_meta_type = sr_meta_probe(sd, dt, no_chunk);
if (sd->sd_meta_type == SR_META_F_INVALID) {
printf("%s: invalid metadata format\n", DEVNAME(sc));