diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2009-06-18 15:51:57 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2009-06-18 15:51:57 +0000 |
commit | b380e7506842751982e3f676b96051678f9b9f98 (patch) | |
tree | 562c998ccfc6808fbd951be5e67cc9732324f045 /sys | |
parent | 4cd8e9cd5ebebe0f5b6f4e68ee7b588bf6bf9208 (diff) |
Check the set state status rather than always assuming a rebuild has been
requested. Also move the rebuild initialisation code into a separate
function whilst here.
ok marco@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/softraid.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 8d61109a9c1..d8e450020e0 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.154 2009/06/18 15:47:38 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.155 2009/06/18 15:51:56 jsing Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -117,6 +117,7 @@ void sr_checksum(struct sr_softc *, void *, void *, u_int32_t); int sr_boot_assembly(struct sr_softc *); int sr_already_assembled(struct sr_discipline *); +int sr_rebuild_init(struct sr_discipline *, dev_t); void sr_rebuild(void *); void sr_rebuild_thread(void *); @@ -1869,15 +1870,9 @@ sr_ioctl_disk(struct sr_softc *sc, struct bioc_disk *bd) int sr_ioctl_setstate(struct sr_softc *sc, struct bioc_setstate *bs) { - int rv = EINVAL, part; - int i, c, found, vol, open = 0; - struct sr_discipline *sd = NULL, *sw = NULL; - char devname[32]; - struct bdevsw *bdsw; - dev_t dev; - daddr64_t size, csize; - struct disklabel label; - struct sr_meta_chunk *old, *new; + int rv = EINVAL; + int i, vol; + struct sr_discipline *sd = NULL; if (bs->bs_other_id_type == BIOC_SSOTHER_UNUSED) goto done; @@ -1894,6 +1889,46 @@ sr_ioctl_setstate(struct sr_softc *sc, struct bioc_setstate *bs) if (sd == NULL) goto done; + switch (bs->bs_status) { + case BIOC_SSOFFLINE: + break; + + case BIOC_SDSCRUB: + break; + + case BIOC_SSHOTSPARE: + break; + + case BIOC_SSREBUILD: + rv = sr_rebuild_init(sd, (dev_t)bs->bs_other_id); + break; + + default: + printf("%s: unsupported state request %d\n", + DEVNAME(sc), bs->bs_status); + } + +done: + return (rv); +} + +int +sr_rebuild_init(struct sr_discipline *sd, dev_t dev) +{ + struct sr_softc *sc = sd->sd_sc; + int rv = EINVAL, part; + int i, c, found, vol, open = 0; + struct sr_discipline *sw = NULL; + char devname[32]; + struct bdevsw *bdsw; + daddr64_t size, csize; + struct disklabel label; + struct sr_meta_chunk *old, *new; + + /* + * Attempt to initiate a rebuild onto the specified device. + */ + if (!sd->sd_rebuild) { printf("%s: discipline does not support rebuild\n", DEVNAME(sc)); @@ -1932,7 +1967,6 @@ sr_ioctl_setstate(struct sr_softc *sc, struct bioc_setstate *bs) } /* populate meta entry */ - dev = (dev_t)bs->bs_other_id; sr_meta_getdevname(sc, dev, devname, sizeof(devname)); bdsw = bdevsw_lookup(dev); |