From: deraadt Date: Thu, 8 Feb 2018 06:02:09 +0000 (+0000) Subject: sr_quiesce() is a new approach for ensuring that softraid drains X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f5001adee9a5816521270ad7d801a6d56128a75a;p=openbsd 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... --- 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 * Copyright (c) 2005 Jordan Hargrave @@ -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 * Copyright (c) 2008 Chris Kuethe @@ -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 */ @@ -4534,6 +4540,18 @@ sr_validate_stripsize(u_int32_t b) return (s); } +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) {