1 .\" Copyright (c) 2005 The DragonFly Project. All rights reserved.
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Hiten Pandya <hmp@dragonflybsd.org>.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in
14 .\" the documentation and/or other materials provided with the
16 .\" 3. Neither the name of The DragonFly Project nor the names of its
17 .\" contributors may be used to endorse or promote products derived
18 .\" from this software without specific, prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" $DragonFly: src/share/man/man9/bufcache.9,v 1.5 2007/11/23 23:03:57 swildner Exp $
42 .Nd Buffer Cache Functions
50 .Fa "struct vnode *vp"
53 .Fa "struct buf **bpp"
60 The buffer cache functions are at the heart of all storage file systems;
61 they are used for reading from and writing to the underlying storage.
66 functions observe most activity in the kernel from file systems, but other
73 function is invoked to initialize various accounting code.
76 number of buffers and inserts them into the empty queue
80 is a global variable in the kernel that is tunable at boot time using
84 .Bl -tag -width compact
85 .It Fn bread "*vp" "blkno" "size" "**bpp"
86 Retrieve a buffer with specified data.
89 is called to check whether the data is available in cache or if it
90 should be read from the
92 If the data is available in cache, the
94 flag will be set otherwise
96 bytes will be read starting at block number
98 from the block special device vnode
101 In case when the buffer is not in cache or not cacheable this
102 function will put the calling process or thread to sleep, using
104 as the wait channel and
108 On successful return, the
112 will point to valid data address and
114 will contain the number of bytes read.
116 Write a buffer back to the device pointed to by
119 Until the write operation is complete, the calling thread or
120 process will be put to sleep by the kernel using
122 as the wait channel and
126 Before calling this function, the following fields are the least
128 .Bl -tag -width compact
130 This field should be set to a valid data buffer to be written by
133 Size of buffer to be written, analogous to the
138 Logical block number at which the buffer should be written.
140 This can be set by using the
142 function on the device vnode.
144 This should be set to the vnode of the device to which the buffer
148 This function will put the calling process or thread to sleep if the
149 data cannot be written when operating synchronously, using
151 as the wait channel and
154 On successful return the
158 will be set to the value zero, thus indicating a successful write.
161 The file system code, located under
163 directory are the main source of reference.
169 This manual page was written by
170 .An Hiten Pandya Aq hmp@freebsd.org .