| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vfs_bio.c,v 1.220 2009/11/11 07:22:33 rmind Exp $ */ | | 1 | /* $NetBSD: vfs_bio.c,v 1.221 2009/11/11 09:15:42 rmind Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2007, 2008, 2009 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 by Wasabi Systems, Inc. | | 8 | * by Andrew Doran, and by Wasabi Systems, Inc. |
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. |
| @@ -90,34 +90,50 @@ | | | @@ -90,34 +90,50 @@ |
90 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 90 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
91 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 91 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
92 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 92 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
93 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 93 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
94 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 94 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
97 | * SUCH DAMAGE. | | 97 | * SUCH DAMAGE. |
98 | * | | 98 | * |
99 | * @(#)vfs_bio.c 8.6 (Berkeley) 1/11/94 | | 99 | * @(#)vfs_bio.c 8.6 (Berkeley) 1/11/94 |
100 | */ | | 100 | */ |
101 | | | 101 | |
102 | /* | | 102 | /* |
| | | 103 | * The buffer cache subsystem. |
| | | 104 | * |
103 | * Some references: | | 105 | * Some references: |
104 | * Bach: The Design of the UNIX Operating System (Prentice Hall, 1986) | | 106 | * Bach: The Design of the UNIX Operating System (Prentice Hall, 1986) |
105 | * Leffler, et al.: The Design and Implementation of the 4.3BSD | | 107 | * Leffler, et al.: The Design and Implementation of the 4.3BSD |
106 | * UNIX Operating System (Addison Welley, 1989) | | 108 | * UNIX Operating System (Addison Welley, 1989) |
| | | 109 | * |
| | | 110 | * Locking |
| | | 111 | * |
| | | 112 | * There are three locks: |
| | | 113 | * - bufcache_lock: protects global buffer cache state. |
| | | 114 | * - BC_BUSY: a long term per-buffer lock. |
| | | 115 | * - buf_t::b_objlock: lock on completion (biowait vs biodone). |
| | | 116 | * |
| | | 117 | * For buffers associated with vnodes (a most common case) b_objlock points |
| | | 118 | * to the vnode_t::v_interlock. Otherwise, it points to generic buffer_lock. |
| | | 119 | * |
| | | 120 | * Lock order: |
| | | 121 | * bufcache_lock -> |
| | | 122 | * buf_t::b_objlock |
107 | */ | | 123 | */ |
108 | | | 124 | |
109 | #include <sys/cdefs.h> | | 125 | #include <sys/cdefs.h> |
110 | __KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.220 2009/11/11 07:22:33 rmind Exp $"); | | 126 | __KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.221 2009/11/11 09:15:42 rmind Exp $"); |
111 | | | 127 | |
112 | #include "fs_ffs.h" | | 128 | #include "fs_ffs.h" |
113 | #include "opt_bufcache.h" | | 129 | #include "opt_bufcache.h" |
114 | | | 130 | |
115 | #include <sys/param.h> | | 131 | #include <sys/param.h> |
116 | #include <sys/systm.h> | | 132 | #include <sys/systm.h> |
117 | #include <sys/kernel.h> | | 133 | #include <sys/kernel.h> |
118 | #include <sys/proc.h> | | 134 | #include <sys/proc.h> |
119 | #include <sys/buf.h> | | 135 | #include <sys/buf.h> |
120 | #include <sys/vnode.h> | | 136 | #include <sys/vnode.h> |
121 | #include <sys/mount.h> | | 137 | #include <sys/mount.h> |
122 | #include <sys/resourcevar.h> | | 138 | #include <sys/resourcevar.h> |
123 | #include <sys/sysctl.h> | | 139 | #include <sys/sysctl.h> |