diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2011-07-06 17:32:48 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2011-07-06 17:32:48 +0000 |
commit | c20d6c3243d55487e27229660f94d832b077af15 (patch) | |
tree | c0e4397474177b7b77c0bb9e9c5db38ceba03f97 | |
parent | 310253e7fcab4d8fe72c7be76ecae1ae30afced6 (diff) |
Use a single shutdown hook for the softraid controller instead of
having one per volume.
ok marco@
-rw-r--r-- | sys/dev/softraid.c | 26 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 4 |
2 files changed, 16 insertions, 14 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 6e304470e1f..5486f04b2e9 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.239 2011/07/06 15:55:25 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.240 2011/07/06 17:32:47 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -1672,6 +1672,8 @@ sr_attach(struct device *parent, struct device *self, void *aux) softraid_disk_attach = sr_disk_attach; + sc->sc_shutdownhook = shutdownhook_establish(sr_shutdown, sc); + sr_boot_assembly(sc); } @@ -1683,6 +1685,9 @@ sr_detach(struct device *self, int flags) DNPRINTF(SR_D_MISC, "%s: sr_detach\n", DEVNAME(sc)); + if (sc->sc_shutdownhook) + shutdownhook_disestablish(sc->sc_shutdownhook); + /* XXX this will not work when we stagger disciplines */ for (i = 0; i < SR_MAX_LD; i++) if (sc->sc_dis[i]) @@ -3148,7 +3153,6 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user) /* save metadata to disk */ rv = sr_meta_save(sd, SR_META_DIRTY); - sd->sd_shutdownhook = shutdownhook_establish(sr_shutdown, sd); if (sd->sd_vol_status == BIOC_SVREBUILD) kthread_create_deferred(sr_rebuild, sd); @@ -3429,9 +3433,6 @@ sr_discipline_shutdown(struct sr_discipline *sd, int meta_save) sd->sd_ready = 0; - if (sd->sd_shutdownhook) - shutdownhook_disestablish(sd->sd_shutdownhook); - /* make sure there isn't a sync pending and yield */ wakeup(sd); while (sd->sd_sync || sd->sd_must_flush) @@ -3796,14 +3797,15 @@ sr_validate_stripsize(u_int32_t b) void sr_shutdown(void *arg) { - struct sr_discipline *sd = arg; -#ifdef SR_DEBUG - struct sr_softc *sc = sd->sd_sc; -#endif - DNPRINTF(SR_D_DIS, "%s: sr_shutdown %s\n", - DEVNAME(sc), sd->sd_meta->ssd_devname); + struct sr_softc *sc = arg; + int i; - sr_discipline_shutdown(sd, 1); + DNPRINTF(SR_D_MISC, "%s: sr_shutdown\n", DEVNAME(sc)); + + /* XXX this will not work when we stagger disciplines */ + for (i = 0; i < SR_MAX_LD; i++) + if (sc->sc_dis[i]) + sr_discipline_shutdown(sc->sc_dis[i], 1); } int diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index bcdf56a720f..95a5dfbd90f 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.103 2011/07/06 15:44:11 jsing Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.104 2011/07/06 17:32:47 jsing Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -505,7 +505,6 @@ struct sr_discipline { int sd_deleted; struct device *sd_scsibus_dev; - void (*sd_shutdownhook)(void *); /* discipline volume */ struct sr_volume sd_vol; /* volume associated */ @@ -567,6 +566,7 @@ struct sr_softc { struct device sc_dev; int (*sc_ioctl)(struct device *, u_long, caddr_t); + void (*sc_shutdownhook)(void *); struct rwlock sc_lock; |