diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2018-02-08 06:02:10 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2018-02-08 06:02:10 +0000 |
commit | 7c1685df3cfc36361f17d366368d68b68c793f38 (patch) | |
tree | 1402ef679dfeaa146589a1a09cebbcea81fbccc7 | |
parent | 3349e2fa163a81333692a778fa49b6e95de55fac (diff) |
sr_quiesce() is a new approach for ensuring that softraid drains
output to the disks.
This is part of a larger suspend/resume filesystem-safety diff, which
has been worked on for a couple of months already. Tests by job, krw,
beck, benno, and others. Sometimes even by snapshot users...
-rw-r--r-- | sys/dev/acpi/acpi.c | 9 | ||||
-rw-r--r-- | sys/dev/softraid.c | 20 |
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index c037c5240c9..58b18398f7f 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.335 2017/11/29 22:51:01 kettenis Exp $ */ +/* $OpenBSD: acpi.c,v 1.336 2018/02/08 06:02:09 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -61,6 +61,7 @@ #include "wd.h" #include "wsdisplay.h" +#include "softraid.h" #ifdef ACPI_DEBUG int acpi_debug = 16; @@ -2443,6 +2444,9 @@ acpi_sleep_state(struct acpi_softc *sc, int sleepmode) size_t rndbuflen = 0; char *rndbuf = NULL; int state, s; +#if NSOFTRAID > 0 + extern void sr_quiesce(void); +#endif switch (sleepmode) { case ACPI_SLEEP_SUSPEND: @@ -2495,6 +2499,9 @@ acpi_sleep_state(struct acpi_softc *sc, int sleepmode) if (config_suspend_all(DVACT_QUIESCE)) goto fail_quiesce; +#if NSOFTRAID > 0 + sr_quiesce(); +#endif bufq_quiesce(); #ifdef MULTIPROCESSOR diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 0d79973b854..0e69dc4829d 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.390 2018/02/07 06:16:08 krw Exp $ */ +/* $OpenBSD: softraid.c,v 1.391 2018/02/08 06:02:09 deraadt Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -3922,6 +3922,12 @@ sr_discipline_shutdown(struct sr_discipline *sd, int meta_save, int dying) EWOULDBLOCK) break; + if (dying == -1) { + sd->sd_ready = 1; + splx(s); + return; + } + #ifndef SMALL_KERNEL sr_sensors_delete(sd); #endif /* SMALL_KERNEL */ @@ -4535,6 +4541,18 @@ sr_validate_stripsize(u_int32_t b) } void +sr_quiesce(void) +{ + struct sr_softc *sc = softraid0; + struct sr_discipline *sd, *nsd; + + /* Shutdown disciplines in reverse attach order. */ + TAILQ_FOREACH_REVERSE_SAFE(sd, &sc->sc_dis_list, + sr_discipline_list, sd_link, nsd) + sr_discipline_shutdown(sd, 1, -1); +} + +void sr_shutdown(int dying) { struct sr_softc *sc = softraid0; |