Deleted Added
full compact
buf.9 (87519) buf.9 (89124)
1.\" Copyright (c) 1998
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 15 unchanged lines hidden (view full) ---

24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
1.\" Copyright (c) 1998
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 15 unchanged lines hidden (view full) ---

24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $FreeBSD: head/share/man/man9/buf.9 87519 2001-12-08 04:15:37Z davidc $
32.\" $FreeBSD: head/share/man/man9/buf.9 89124 2002-01-09 11:43:48Z mpp $
33.\"
34.Dd December 22, 1998
35.Dt BUF 9
36.Os
37.Sh NAME
38.Nm buf
39.Nd "kernel buffer I/O scheme used in FreeBSD VM system"
40.Sh DESCRIPTION

--- 34 unchanged lines hidden (view full) ---

75.Pp
76A VM buffer is capable of mapping the underlying VM cache pages into KVM in
77order to allow the kernel to directly manipulate the data associated with
78the (vnode,b_offset,b_size). The kernel typically unmaps VM buffers the moment
79they are no longer needed but often keeps the 'struct buf' structure
80instantiated and even bp->b_pages array instantiated despite having unmapped
81them from KVM. If a page making up a VM buffer is about to undergo I/O, the
82system typically unmaps it from KVM and replaces the page in the b_pages[]
33.\"
34.Dd December 22, 1998
35.Dt BUF 9
36.Os
37.Sh NAME
38.Nm buf
39.Nd "kernel buffer I/O scheme used in FreeBSD VM system"
40.Sh DESCRIPTION

--- 34 unchanged lines hidden (view full) ---

75.Pp
76A VM buffer is capable of mapping the underlying VM cache pages into KVM in
77order to allow the kernel to directly manipulate the data associated with
78the (vnode,b_offset,b_size). The kernel typically unmaps VM buffers the moment
79they are no longer needed but often keeps the 'struct buf' structure
80instantiated and even bp->b_pages array instantiated despite having unmapped
81them from KVM. If a page making up a VM buffer is about to undergo I/O, the
82system typically unmaps it from KVM and replaces the page in the b_pages[]
83array with a placemarker called bogus_page. The placemarker forces any kernel
83array with a place-marker called bogus_page. The place-marker forces any kernel
84subsystems referencing the associated struct buf to re-lookup the associated
84subsystems referencing the associated struct buf to re-lookup the associated
85page. I believe the placemarker hack is used to allow sophisticated devices
85page. I believe the place-marker hack is used to allow sophisticated devices
86such as filesystem devices to remap underlying pages in order to deal with,
86such as filesystem devices to remap underlying pages in order to deal with,
87for example, remapping a file fragment into a file block.
87for example, re-mapping a file fragment into a file block.
88.Pp
89VM buffers are used to track I/O operations within the kernel. Unfortunately,
90the I/O implementation is also somewhat of a hack because the kernel wants
91to clear the dirty bit on the underlying pages the moment it queues the I/O
92to the VFS device, not when the physical I/O is actually initiated. This
93can create confusion within filesystem devices that use delayed-writes because
94you wind up with pages marked clean that are actually still dirty. If not
95treated carefully, these pages could be thrown away! Indeed, a number of
96serious bugs related to this hack were not fixed until the 2.2.8/3.0 release.
88.Pp
89VM buffers are used to track I/O operations within the kernel. Unfortunately,
90the I/O implementation is also somewhat of a hack because the kernel wants
91to clear the dirty bit on the underlying pages the moment it queues the I/O
92to the VFS device, not when the physical I/O is actually initiated. This
93can create confusion within filesystem devices that use delayed-writes because
94you wind up with pages marked clean that are actually still dirty. If not
95treated carefully, these pages could be thrown away! Indeed, a number of
96serious bugs related to this hack were not fixed until the 2.2.8/3.0 release.
97The kernel uses an instantiated VM buffer (i.e. struct buf) to placemark pages
97The kernel uses an instantiated VM buffer (i.e. struct buf) to place-mark pages
98in this special state. The buffer is typically flagged B_DELWRI. When a
99device no longer needs a buffer it typically flags it as B_RELBUF. Due to
100the underlying pages being marked clean, the B_DELWRI|B_RELBUF combination must
101be interpreted to mean that the buffer is still actually dirty and must be
102written to its backing store before it can actually be released. In the case
103where B_DELWRI is not set, the underlying dirty pages are still properly
104marked as dirty and the buffer can be completely freed without losing that
105clean/dirty state information. ( XXX do we have to check other flags in

--- 19 unchanged lines hidden ---
98in this special state. The buffer is typically flagged B_DELWRI. When a
99device no longer needs a buffer it typically flags it as B_RELBUF. Due to
100the underlying pages being marked clean, the B_DELWRI|B_RELBUF combination must
101be interpreted to mean that the buffer is still actually dirty and must be
102written to its backing store before it can actually be released. In the case
103where B_DELWRI is not set, the underlying dirty pages are still properly
104marked as dirty and the buffer can be completely freed without losing that
105clean/dirty state information. ( XXX do we have to check other flags in

--- 19 unchanged lines hidden ---