summaryrefslogtreecommitdiff
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2011-09-18 13:11:09 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2011-09-18 13:11:09 +0000
commite7f8f575542232e5c4a5a8577700b19f9395d0ed (patch)
tree9bbe23645acdc780b101ec209749be151834c35c /sys/dev/softraid.c
parent04c5a644d24771f1f8416fa68b5af993c5cffd89 (diff)
Rename the optional metadata handler function and factor out the optional
metadata handling code. This will simplify upcoming changes.
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r--sys/dev/softraid.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 5ccbb58592e..de95e4460db 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.246 2011/08/08 18:18:22 marco Exp $ */
+/* $OpenBSD: softraid.c,v 1.247 2011/09/18 13:11:08 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -149,7 +149,7 @@ void sr_meta_chunks_create(struct sr_softc *,
struct sr_chunk_head *);
void sr_meta_init(struct sr_discipline *,
struct sr_chunk_head *);
-void sr_meta_opt_load(struct sr_discipline *,
+void sr_meta_opt_handler(struct sr_discipline *,
struct sr_meta_opt *);
/* hotplug magic */
@@ -605,12 +605,9 @@ sr_meta_init(struct sr_discipline *sd, struct sr_chunk_head *cl)
}
void
-sr_meta_opt_load(struct sr_discipline *sd, struct sr_meta_opt *om)
+sr_meta_opt_handler(struct sr_discipline *sd, struct sr_meta_opt *om)
{
- if (om->somi.som_type == SR_OPT_BOOT) {
-
-
- } else
+ if (om->somi.som_type != SR_OPT_BOOT)
panic("unknown optional metadata type");
}
@@ -734,18 +731,15 @@ bad:
int
sr_meta_read(struct sr_discipline *sd)
{
-#ifdef SR_DEBUG
struct sr_softc *sc = sd->sd_sc;
-#endif
struct sr_chunk_head *cl = &sd->sd_vol.sv_chunk_list;
struct sr_metadata *sm;
struct sr_chunk *ch_entry;
struct sr_meta_chunk *cp;
struct sr_meta_driver *s;
struct sr_meta_opt_item *omi;
- struct sr_meta_opt *om;
void *fm = NULL;
- int i, no_disk = 0, got_meta = 0;
+ int no_disk = 0, got_meta = 0;
DNPRINTF(SR_D_META, "%s: sr_meta_read\n", DEVNAME(sc));
@@ -795,25 +789,12 @@ sr_meta_read(struct sr_discipline *sd)
bcopy(cp, &ch_entry->src_meta, sizeof(ch_entry->src_meta));
- /* Process optional metadata. */
- om = (struct sr_meta_opt *) ((u_int8_t *)(sm + 1) +
- sizeof(struct sr_meta_chunk) * sm->ssdi.ssd_chunk_no);
- for (i = 0; i < sm->ssdi.ssd_opt_no; i++) {
-
- omi = malloc(sizeof(struct sr_meta_opt_item),
- M_DEVBUF, M_WAITOK | M_ZERO);
- bcopy(om, &omi->omi_om, sizeof(struct sr_meta_opt));
- SLIST_INSERT_HEAD(&sd->sd_meta_opt, omi, omi_link);
-
- /* See if discipline wants to handle it. */
- if (sd->sd_meta_opt_load &&
- sd->sd_meta_opt_load(sd, &omi->omi_om) == 0)
- continue;
- else
- sr_meta_opt_load(sd, &omi->omi_om);
-
- om++;
- }
+ /* Load and process optional metadata. */
+ sr_meta_opt_load(sc, sm, &sd->sd_meta_opt);
+ SLIST_FOREACH(omi, &sd->sd_meta_opt, omi_link)
+ if (sd->sd_meta_opt_handler == NULL ||
+ sd->sd_meta_opt_handler(sd, &omi->omi_om) != 0)
+ sr_meta_opt_handler(sd, &omi->omi_om);
cp++;
no_disk++;
@@ -829,6 +810,28 @@ done:
return (no_disk);
}
+void
+sr_meta_opt_load(struct sr_softc *sc, struct sr_metadata *sm,
+ struct sr_meta_opt_head *som)
+{
+ struct sr_meta_opt_item *omi;
+ struct sr_meta_opt *om;
+ int i;
+
+ /* Process optional metadata. */
+ om = (struct sr_meta_opt *)((u_int8_t *)(sm + 1) +
+ sizeof(struct sr_meta_chunk) * sm->ssdi.ssd_chunk_no);
+ for (i = 0; i < sm->ssdi.ssd_opt_no; i++) {
+
+ omi = malloc(sizeof(struct sr_meta_opt_item),
+ M_DEVBUF, M_WAITOK | M_ZERO);
+ bcopy(om, &omi->omi_om, sizeof(struct sr_meta_opt));
+ SLIST_INSERT_HEAD(som, omi, omi_link);
+
+ om++;
+ }
+}
+
int
sr_meta_validate(struct sr_discipline *sd, dev_t dev, struct sr_metadata *sm,
void *fm)