summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2009-12-07 14:27:13 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2009-12-07 14:27:13 +0000
commit42321b3620be40357f505baa65d4708c7cef5bdf (patch)
tree3bc215090eb6e4dc8da078393f0bdb5664cca79c /sys
parent4b91ffe23be5b8782f30cc0dddd0593da1548ac5 (diff)
Define discipline capabilities using a set of flags.
"shiny!!" marco@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/softraid.c8
-rw-r--r--sys/dev/softraid_aoe.c7
-rw-r--r--sys/dev/softraid_crypto.c4
-rw-r--r--sys/dev/softraid_raid0.c3
-rw-r--r--sys/dev/softraid_raid1.c5
-rw-r--r--sys/dev/softraid_raid6.c5
-rw-r--r--sys/dev/softraid_raidp.c4
-rw-r--r--sys/dev/softraidvar.h8
8 files changed, 26 insertions, 18 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index bc61449e7ed..a7a96e83985 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.182 2009/11/24 02:19:35 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.183 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2519,7 +2519,7 @@ sr_rebuild_init(struct sr_discipline *sd, dev_t dev)
* Attempt to initiate a rebuild onto the specified device.
*/
- if (!sd->sd_rebuild) {
+ if (!(sd->sd_capabilities & SR_CAP_REBUILD)) {
printf("%s: discipline does not support rebuild\n",
DEVNAME(sc));
goto done;
@@ -2680,7 +2680,7 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
{
dev_t *dt;
int i, s, no_chunk, rv = EINVAL, vol;
- int no_meta, updatemeta = 0, disk = 1;
+ int no_meta, updatemeta = 0;
u_int64_t vol_size;
int32_t strip_size = 0;
struct sr_chunk_head *cl;
@@ -2962,7 +2962,7 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
if ((rv = sd->sd_alloc_resources(sd)))
goto unwind;
- if (disk) {
+ if (sd->sd_capabilities & SR_CAP_SYSTEM_DISK) {
/* set volume status */
sd->sd_set_vol_state(sd);
if (sd->sd_vol_status == BIOC_SVOFFLINE) {
diff --git a/sys/dev/softraid_aoe.c b/sys/dev/softraid_aoe.c
index e5e57ab866a..58991f14905 100644
--- a/sys/dev/softraid_aoe.c
+++ b/sys/dev/softraid_aoe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_aoe.c,v 1.10 2009/11/26 23:06:49 jasper Exp $ */
+/* $OpenBSD: softraid_aoe.c,v 1.11 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2008 Ted Unangst <tedu@openbsd.org>
* Copyright (c) 2008 Marco Peereboom <marco@openbsd.org>
@@ -75,6 +75,7 @@ sr_aoe_discipline_init(struct sr_discipline *sd)
/* Fill out discipline members. */
sd->sd_type = SR_MD_AOE_INIT;
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK;
sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no;
sd->sd_max_wu = SR_RAIDAOE_NOWU;
@@ -100,6 +101,7 @@ sr_aoe_server_discipline_init(struct sr_discipline *sd)
/* Fill out discipline members. */
sd->sd_type = SR_MD_AOE_TARG;
+ sd->sd_capabilities = 0;
sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no;
sd->sd_max_wu = SR_RAIDAOE_NOWU;
@@ -116,9 +118,6 @@ sr_aoe_server_discipline_init(struct sr_discipline *sd)
sd->sd_scsi_rw = NULL;
sd->sd_set_chunk_state = NULL;
sd->sd_set_vol_state = NULL;
-#if 0
- disk = 0; /* we are not a disk */
-#endif
}
/* AOE initiator */
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index c209f726b7f..8b0d7f03729 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.42 2009/11/24 02:19:35 jsing Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.43 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -86,8 +86,10 @@ void sr_crypto_dumpkeys(struct sr_discipline *);
void
sr_crypto_discipline_init(struct sr_discipline *sd)
{
+
/* Fill out discipline members. */
sd->sd_type = SR_MD_CRYPTO;
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK;
sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no;
sd->sd_max_wu = SR_CRYPTO_NOWU;
diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c
index 1a36e3e3ba0..a772849d556 100644
--- a/sys/dev/softraid_raid0.c
+++ b/sys/dev/softraid_raid0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid0.c,v 1.16 2009/08/09 14:12:25 marco Exp $ */
+/* $OpenBSD: softraid_raid0.c,v 1.17 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2008 Marco Peereboom <marco@peereboom.us>
*
@@ -58,6 +58,7 @@ sr_raid0_discipline_init(struct sr_discipline *sd)
/* Fill out discipline members. */
sd->sd_type = SR_MD_RAID0;
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK | SR_CAP_AUTO_ASSEMBLE;
sd->sd_max_ccb_per_wu =
(MAXPHYS / sd->sd_meta->ssdi.ssd_strip_size + 1) *
SR_RAID0_NOWU * sd->sd_meta->ssdi.ssd_chunk_no;
diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c
index dd655c2f35a..939afa3f602 100644
--- a/sys/dev/softraid_raid1.c
+++ b/sys/dev/softraid_raid1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid1.c,v 1.19 2009/08/09 14:12:25 marco Exp $ */
+/* $OpenBSD: softraid_raid1.c,v 1.20 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -57,9 +57,10 @@ sr_raid1_discipline_init(struct sr_discipline *sd)
/* Fill out discipline members. */
sd->sd_type = SR_MD_RAID1;
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK | SR_CAP_AUTO_ASSEMBLE |
+ SR_CAP_REBUILD;
sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no;
sd->sd_max_wu = SR_RAID1_NOWU;
- sd->sd_rebuild = 1;
/* Setup discipline pointers. */
sd->sd_alloc_resources = sr_raid1_alloc_resources;
diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c
index 46eff9f9691..1d01c4f78e8 100644
--- a/sys/dev/softraid_raid6.c
+++ b/sys/dev/softraid_raid6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid6.c,v 1.7 2009/11/13 23:34:24 jordan Exp $ */
+/* $OpenBSD: softraid_raid6.c,v 1.8 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -124,13 +124,14 @@ struct sr_raid6_opaque {
void
sr_raid6_discipline_init(struct sr_discipline *sd)
{
+
/* Initialize GF256 tables */
gf_init();
/* fill out discipline members. */
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK | SR_CAP_AUTO_ASSEMBLE;
sd->sd_max_ccb_per_wu = max(6, 2 * sd->sd_meta->ssdi.ssd_chunk_no); /* only if stripsize <= MAXPHYS */
sd->sd_max_wu = SR_RAID6_NOWU;
- sd->sd_rebuild = 0;
/* setup discipline pointers. */
sd->sd_alloc_resources = sr_raid6_alloc_resources;
diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c
index 3e5a22f5167..a8b6ea386ca 100644
--- a/sys/dev/softraid_raidp.c
+++ b/sys/dev/softraid_raidp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raidp.c,v 1.10 2009/08/09 14:12:25 marco Exp $ */
+/* $OpenBSD: softraid_raidp.c,v 1.11 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org>
@@ -69,9 +69,9 @@ sr_raidp_discipline_init(struct sr_discipline *sd)
{
/* fill out discipline members. */
+ sd->sd_capabilities = SR_CAP_SYSTEM_DISK | SR_CAP_AUTO_ASSEMBLE;
sd->sd_max_ccb_per_wu = 4; /* only if stripsize <= MAXPHYS */
sd->sd_max_wu = SR_RAIDP_NOWU;
- sd->sd_rebuild = 0;
/* setup discipline pointers. */
sd->sd_alloc_resources = sr_raidp_alloc_resources;
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index da5569b8085..76303ed59c1 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.84 2009/11/24 02:19:35 jsing Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.85 2009/12/07 14:27:12 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -420,6 +420,11 @@ struct sr_discipline {
u_int8_t sd_scsibus; /* scsibus discipline uses */
struct scsi_link sd_link; /* link to midlayer */
+ u_int32_t sd_capabilities;
+#define SR_CAP_SYSTEM_DISK 0x00000001
+#define SR_CAP_AUTO_ASSEMBLE 0x00000002
+#define SR_CAP_REBUILD 0x00000004
+
union {
struct sr_raid0 mdd_raid0;
struct sr_raid1 mdd_raid1;
@@ -456,7 +461,6 @@ struct sr_discipline {
struct sr_workunit *sd_wu; /* all workunits */
u_int32_t sd_max_wu;
- int sd_rebuild; /* can we rebuild? */
int sd_reb_active; /* rebuild in progress */
int sd_reb_abort; /* abort rebuild */
int sd_ready; /* fully operational */