summaryrefslogtreecommitdiff
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
parent04c5a644d24771f1f8416fa68b5af993c5cffd89 (diff)
Rename the optional metadata handler function and factor out the optional
metadata handling code. This will simplify upcoming changes.
-rw-r--r--sys/dev/softraid.c63
-rw-r--r--sys/dev/softraid_crypto.c8
-rw-r--r--sys/dev/softraidvar.h6
3 files changed, 41 insertions, 36 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)
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 5990897894d..73ae5efc3da 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.71 2011/07/07 00:17:14 tedu Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.72 2011/09/18 13:11:08 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -91,7 +91,7 @@ int sr_crypto_alloc_resources(struct sr_discipline *);
int sr_crypto_free_resources(struct sr_discipline *);
int sr_crypto_ioctl(struct sr_discipline *,
struct bioc_discipline *);
-int sr_crypto_meta_opt_load(struct sr_discipline *,
+int sr_crypto_meta_opt_handler(struct sr_discipline *,
struct sr_meta_opt *);
int sr_crypto_write(struct cryptop *);
int sr_crypto_rw(struct sr_workunit *);
@@ -128,7 +128,7 @@ sr_crypto_discipline_init(struct sr_discipline *sd)
sd->sd_free_resources = sr_crypto_free_resources;
sd->sd_start_discipline = NULL;
sd->sd_ioctl_handler = sr_crypto_ioctl;
- sd->sd_meta_opt_load = sr_crypto_meta_opt_load;
+ sd->sd_meta_opt_handler = sr_crypto_meta_opt_handler;
sd->sd_scsi_inquiry = sr_raid_inquiry;
sd->sd_scsi_read_cap = sr_raid_read_cap;
sd->sd_scsi_tur = sr_raid_tur;
@@ -1150,7 +1150,7 @@ bad:
}
int
-sr_crypto_meta_opt_load(struct sr_discipline *sd, struct sr_meta_opt *om)
+sr_crypto_meta_opt_handler(struct sr_discipline *sd, struct sr_meta_opt *om)
{
int rv = EINVAL;
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 06c370b117a..0b27906da56 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.106 2011/07/07 03:50:00 tedu Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.107 2011/09/18 13:11:08 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -559,7 +559,7 @@ struct sr_discipline {
int, int);
void (*sd_set_vol_state)(struct sr_discipline *);
int (*sd_openings)(struct sr_discipline *);
- int (*sd_meta_opt_load)(struct sr_discipline *,
+ int (*sd_meta_opt_handler)(struct sr_discipline *,
struct sr_meta_opt *);
/* SCSI emulation */
@@ -630,6 +630,8 @@ void sr_meta_save_callback(void *, void *);
int sr_meta_save(struct sr_discipline *, u_int32_t);
void sr_meta_getdevname(struct sr_softc *, dev_t, char *,
int);
+void sr_meta_opt_load(struct sr_softc *,
+ struct sr_metadata *, struct sr_meta_opt_head *);
void sr_checksum(struct sr_softc *, void *, void *,
u_int32_t);
int sr_validate_io(struct sr_workunit *, daddr64_t *,