| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ld.c,v 1.97 2016/09/27 03:33:32 pgoyette Exp $ */ | | 1 | /* $NetBSD: ld.c,v 1.98 2016/10/11 18:31:11 jdolecek Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran and Charles M. Hannum. | | 8 | * by Andrew Doran and Charles M. Hannum. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -24,47 +24,48 @@ | | | @@ -24,47 +24,48 @@ |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Disk driver for use by RAID controllers. | | 33 | * Disk driver for use by RAID controllers. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.97 2016/09/27 03:33:32 pgoyette Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.98 2016/10/11 18:31:11 jdolecek Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/kernel.h> | | 41 | #include <sys/kernel.h> |
42 | #include <sys/device.h> | | 42 | #include <sys/device.h> |
43 | #include <sys/queue.h> | | 43 | #include <sys/queue.h> |
44 | #include <sys/proc.h> | | 44 | #include <sys/proc.h> |
45 | #include <sys/buf.h> | | 45 | #include <sys/buf.h> |
46 | #include <sys/bufq.h> | | 46 | #include <sys/bufq.h> |
47 | #include <sys/endian.h> | | 47 | #include <sys/endian.h> |
48 | #include <sys/disklabel.h> | | 48 | #include <sys/disklabel.h> |
49 | #include <sys/disk.h> | | 49 | #include <sys/disk.h> |
50 | #include <sys/dkio.h> | | 50 | #include <sys/dkio.h> |
51 | #include <sys/stat.h> | | 51 | #include <sys/stat.h> |
52 | #include <sys/conf.h> | | 52 | #include <sys/conf.h> |
53 | #include <sys/fcntl.h> | | 53 | #include <sys/fcntl.h> |
54 | #include <sys/vnode.h> | | 54 | #include <sys/vnode.h> |
55 | #include <sys/syslog.h> | | 55 | #include <sys/syslog.h> |
56 | #include <sys/mutex.h> | | 56 | #include <sys/mutex.h> |
57 | #include <sys/module.h> | | 57 | #include <sys/module.h> |
| | | 58 | #include <sys/reboot.h> |
58 | | | 59 | |
59 | #include <dev/ldvar.h> | | 60 | #include <dev/ldvar.h> |
60 | | | 61 | |
61 | static void ldminphys(struct buf *bp); | | 62 | static void ldminphys(struct buf *bp); |
62 | static bool ld_suspend(device_t, const pmf_qual_t *); | | 63 | static bool ld_suspend(device_t, const pmf_qual_t *); |
63 | static bool ld_shutdown(device_t, int); | | 64 | static bool ld_shutdown(device_t, int); |
64 | static int ld_diskstart(device_t, struct buf *bp); | | 65 | static int ld_diskstart(device_t, struct buf *bp); |
65 | static void ld_iosize(device_t, int *); | | 66 | static void ld_iosize(device_t, int *); |
66 | static int ld_dumpblocks(device_t, void *, daddr_t, int); | | 67 | static int ld_dumpblocks(device_t, void *, daddr_t, int); |
67 | static void ld_fake_geometry(struct ld_softc *); | | 68 | static void ld_fake_geometry(struct ld_softc *); |
68 | static void ld_set_geometry(struct ld_softc *); | | 69 | static void ld_set_geometry(struct ld_softc *); |
69 | static void ld_config_interrupts (device_t); | | 70 | static void ld_config_interrupts (device_t); |
70 | static int ld_lastclose(device_t); | | 71 | static int ld_lastclose(device_t); |
| @@ -264,27 +265,28 @@ ldenddetach(struct ld_softc *sc) | | | @@ -264,27 +265,28 @@ ldenddetach(struct ld_softc *sc) |
264 | static bool | | 265 | static bool |
265 | ld_suspend(device_t dev, const pmf_qual_t *qual) | | 266 | ld_suspend(device_t dev, const pmf_qual_t *qual) |
266 | { | | 267 | { |
267 | return ld_shutdown(dev, 0); | | 268 | return ld_shutdown(dev, 0); |
268 | } | | 269 | } |
269 | | | 270 | |
270 | /* ARGSUSED */ | | 271 | /* ARGSUSED */ |
271 | static bool | | 272 | static bool |
272 | ld_shutdown(device_t dev, int flags) | | 273 | ld_shutdown(device_t dev, int flags) |
273 | { | | 274 | { |
274 | struct ld_softc *sc = device_private(dev); | | 275 | struct ld_softc *sc = device_private(dev); |
275 | struct dk_softc *dksc = &sc->sc_dksc; | | 276 | struct dk_softc *dksc = &sc->sc_dksc; |
276 | | | 277 | |
277 | if (sc->sc_flush != NULL && (*sc->sc_flush)(sc, LDFL_POLL) != 0) { | | 278 | if ((flags & RB_NOSYNC) == 0 && sc->sc_flush != NULL |
| | | 279 | && (*sc->sc_flush)(sc, LDFL_POLL) != 0) { |
278 | device_printf(dksc->sc_dev, "unable to flush cache\n"); | | 280 | device_printf(dksc->sc_dev, "unable to flush cache\n"); |
279 | return false; | | 281 | return false; |
280 | } | | 282 | } |
281 | | | 283 | |
282 | return true; | | 284 | return true; |
283 | } | | 285 | } |
284 | | | 286 | |
285 | /* ARGSUSED */ | | 287 | /* ARGSUSED */ |
286 | static int | | 288 | static int |
287 | ldopen(dev_t dev, int flags, int fmt, struct lwp *l) | | 289 | ldopen(dev_t dev, int flags, int fmt, struct lwp *l) |
288 | { | | 290 | { |
289 | struct ld_softc *sc; | | 291 | struct ld_softc *sc; |
290 | struct dk_softc *dksc; | | 292 | struct dk_softc *dksc; |