diff options
author | 2011-12-26 14:54:52 +0000 | |
---|---|---|
committer | 2011-12-26 14:54:52 +0000 | |
commit | 97a7a5348b4951f2204bfffa509a4c9e3e963cdf (patch) | |
tree | 1002b3a3692b10cf429f1daadaadea8ae28025eb /sys/dev/softraid_raid0.c | |
parent | Document whatis(1) -S and -s; leading, trailing, and double colons (diff) | |
download | wireguard-openbsd-97a7a5348b4951f2204bfffa509a4c9e3e963cdf.tar.xz wireguard-openbsd-97a7a5348b4951f2204bfffa509a4c9e3e963cdf.zip |
Provide default set chunk state and set volume state functions which
cover the no redundancy/no rebuild case. Use these for the AOE, crypto and
RAID 0 disciplines.
Diffstat (limited to 'sys/dev/softraid_raid0.c')
-rw-r--r-- | sys/dev/softraid_raid0.c | 112 |
1 files changed, 1 insertions, 111 deletions
diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c index b36303eb73e..a9c7e5a7d60 100644 --- a/sys/dev/softraid_raid0.c +++ b/sys/dev/softraid_raid0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid0.c,v 1.24 2011/12/25 15:28:17 jsing Exp $ */ +/* $OpenBSD: softraid_raid0.c,v 1.25 2011/12/26 14:54:52 jsing Exp $ */ /* * Copyright (c) 2008 Marco Peereboom <marco@peereboom.us> * @@ -52,8 +52,6 @@ int sr_raid0_alloc_resources(struct sr_discipline *); int sr_raid0_free_resources(struct sr_discipline *); int sr_raid0_rw(struct sr_workunit *); void sr_raid0_intr(struct buf *); -void sr_raid0_set_chunk_state(struct sr_discipline *, int, int); -void sr_raid0_set_vol_state(struct sr_discipline *); /* Discipline initialisation. */ void @@ -71,8 +69,6 @@ sr_raid0_discipline_init(struct sr_discipline *sd) sd->sd_create = sr_raid0_create; sd->sd_free_resources = sr_raid0_free_resources; sd->sd_scsi_rw = sr_raid0_rw; - sd->sd_set_chunk_state = sr_raid0_set_chunk_state; - sd->sd_set_vol_state = sr_raid0_set_vol_state; } int @@ -156,112 +152,6 @@ sr_raid0_free_resources(struct sr_discipline *sd) return (rv); } -void -sr_raid0_set_chunk_state(struct sr_discipline *sd, int c, int new_state) -{ - int old_state, s; - - DNPRINTF(SR_D_STATE, "%s: %s: %s: sr_raid_set_chunk_state %d -> %d\n", - DEVNAME(sd->sd_sc), sd->sd_meta->ssd_devname, - sd->sd_vol.sv_chunks[c]->src_meta.scmi.scm_devname, c, new_state); - - /* ok to go to splbio since this only happens in error path */ - s = splbio(); - old_state = sd->sd_vol.sv_chunks[c]->src_meta.scm_status; - - /* multiple IOs to the same chunk that fail will come through here */ - if (old_state == new_state) - goto done; - - switch (old_state) { - case BIOC_SDONLINE: - if (new_state == BIOC_SDOFFLINE) - break; - else - goto die; - break; - - case BIOC_SDOFFLINE: - goto die; - - default: -die: - splx(s); /* XXX */ - panic("%s: %s: %s: invalid chunk state transition " - "%d -> %d\n", DEVNAME(sd->sd_sc), - sd->sd_meta->ssd_devname, - sd->sd_vol.sv_chunks[c]->src_meta.scmi.scm_devname, - old_state, new_state); - /* NOTREACHED */ - } - - sd->sd_vol.sv_chunks[c]->src_meta.scm_status = new_state; - sd->sd_set_vol_state(sd); - - sd->sd_must_flush = 1; - workq_add_task(NULL, 0, sr_meta_save_callback, sd, NULL); -done: - splx(s); -} - -void -sr_raid0_set_vol_state(struct sr_discipline *sd) -{ - int states[SR_MAX_STATES]; - int new_state, i, s, nd; - int old_state = sd->sd_vol_status; - - DNPRINTF(SR_D_STATE, "%s: %s: sr_raid_set_vol_state\n", - DEVNAME(sd->sd_sc), sd->sd_meta->ssd_devname); - - nd = sd->sd_meta->ssdi.ssd_chunk_no; - - for (i = 0; i < SR_MAX_STATES; i++) - states[i] = 0; - - for (i = 0; i < nd; i++) { - s = sd->sd_vol.sv_chunks[i]->src_meta.scm_status; - if (s >= SR_MAX_STATES) - panic("%s: %s: %s: invalid chunk state", - DEVNAME(sd->sd_sc), - sd->sd_meta->ssd_devname, - sd->sd_vol.sv_chunks[i]->src_meta.scmi.scm_devname); - states[s]++; - } - - if (states[BIOC_SDONLINE] == nd) - new_state = BIOC_SVONLINE; - else - new_state = BIOC_SVOFFLINE; - - DNPRINTF(SR_D_STATE, "%s: %s: sr_raid_set_vol_state %d -> %d\n", - DEVNAME(sd->sd_sc), sd->sd_meta->ssd_devname, - old_state, new_state); - - switch (old_state) { - case BIOC_SVONLINE: - if (new_state == BIOC_SVOFFLINE || new_state == BIOC_SVONLINE) - break; - else - goto die; - break; - - case BIOC_SVOFFLINE: - /* XXX this might be a little too much */ - goto die; - - default: -die: - panic("%s: %s: invalid volume state transition " - "%d -> %d\n", DEVNAME(sd->sd_sc), - sd->sd_meta->ssd_devname, - old_state, new_state); - /* NOTREACHED */ - } - - sd->sd_vol_status = new_state; -} - int sr_raid0_rw(struct sr_workunit *wu) { |