]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/db/man/mpool.3
This commit was generated by cvs2svn to compensate for changes in r161701,
[FreeBSD/FreeBSD.git] / lib / libc / db / man / mpool.3
1 .\" Copyright (c) 1990, 1993
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.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
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 .\"     @(#)mpool.3     8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD$
34 .\"
35 .Dd June 4, 1993
36 .Dt MPOOL 3
37 .Os
38 .Sh NAME
39 .Nm mpool
40 .Nd "shared memory buffer pool"
41 .Sh SYNOPSIS
42 .In db.h
43 .In mpool.h
44 .Ft MPOOL *
45 .Fn mpool_open "void *key" "int fd" "pgno_t pagesize" "pgno_t maxcache"
46 .Ft void
47 .Fo mpool_filter
48 .Fa "MPOOL *mp"
49 .Fa "void (*pgin)(void *, pgno_t, void *)"
50 .Fa "void (*pgout)(void *, pgno_t, void *)"
51 .Fa "void *pgcookie"
52 .Fc
53 .Ft void *
54 .Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr"
55 .Ft void *
56 .Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags"
57 .Ft int
58 .Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags"
59 .Ft int
60 .Fn mpool_sync "MPOOL *mp"
61 .Ft int
62 .Fn mpool_close "MPOOL *mp"
63 .Sh DESCRIPTION
64 The
65 .Nm mpool
66 library interface is intended to provide page oriented buffer management
67 of files.
68 .Pp
69 The
70 .Fn mpool_open
71 function initializes a memory pool.
72 The
73 .Fa key
74 argument is currently ignored.
75 The
76 .Fa fd
77 argument is a file descriptor for the underlying file, which must be seekable.
78 .Pp
79 The
80 .Fa pagesize
81 argument is the size, in bytes, of the pages into which the file is broken up.
82 The
83 .Fa maxcache
84 argument is the maximum number of pages from the underlying file to cache
85 at any one time.
86 This value is not relative to the number of processes which share a file's
87 buffers, but will be the largest value specified by any of the processes
88 sharing the file.
89 .Pp
90 The
91 .Fn mpool_filter
92 function is intended to make transparent input and output processing of the
93 pages possible.
94 If the
95 .Fa pgin
96 function is specified, it is called each time a buffer is read into the memory
97 pool from the backing file.
98 If the
99 .Fa pgout
100 function is specified, it is called each time a buffer is written into the
101 backing file.
102 Both functions are called with the
103 .Fa pgcookie
104 pointer, the page number and a pointer to the page to being read or written.
105 .Pp
106 The
107 .Fn mpool_new
108 function takes an
109 .Ft MPOOL
110 pointer and an address as arguments.
111 If a new page can be allocated, a pointer to the page is returned and
112 the page number is stored into the
113 .Fa pgnoaddr
114 address.
115 Otherwise,
116 .Dv NULL
117 is returned and
118 .Va errno
119 is set.
120 .Pp
121 The
122 .Fn mpool_get
123 function takes a
124 .Ft MPOOL
125 pointer and a page number as arguments.
126 If the page exists, a pointer to the page is returned.
127 Otherwise,
128 .Dv NULL
129 is returned and
130 .Va errno
131 is set.
132 The
133 .Fa flags
134 argument is not currently used.
135 .Pp
136 The
137 .Fn mpool_put
138 function unpins the page referenced by
139 .Fa pgaddr .
140 The
141 .Fa pgaddr
142 argument
143 must be an address previously returned by
144 .Fn mpool_get
145 or
146 .Fn mpool_new .
147 The
148 .Fa flags
149 argument is specified by
150 .Em or Ns 'ing
151 any of the following values:
152 .Bl -tag -width indent
153 .It Dv MPOOL_DIRTY
154 The page has been modified and needs to be written to the backing file.
155 .El
156 .Pp
157 The
158 .Fn mpool_put
159 function
160 returns 0 on success and -1 if an error occurs.
161 .Pp
162 The
163 .Fn mpool_sync
164 function writes all modified pages associated with the
165 .Ft MPOOL
166 pointer to the
167 backing file.
168 The
169 .Fn mpool_sync
170 function
171 returns 0 on success and -1 if an error occurs.
172 .Pp
173 The
174 .Fn mpool_close
175 function free's up any allocated memory associated with the memory pool
176 cookie.
177 Modified pages are
178 .Em not
179 written to the backing file.
180 The
181 .Fn mpool_close
182 function
183 returns 0 on success and -1 if an error occurs.
184 .Sh ERRORS
185 The
186 .Fn mpool_open
187 function may fail and set
188 .Va errno
189 for any of the errors specified for the library routine
190 .Xr malloc 3 .
191 .Pp
192 The
193 .Fn mpool_get
194 function may fail and set
195 .Va errno
196 for the following:
197 .Bl -tag -width Er
198 .It Bq Er EINVAL
199 The requested record does not exist.
200 .El
201 .Pp
202 The
203 .Fn mpool_new
204 and
205 .Fn mpool_get
206 functions may fail and set
207 .Va errno
208 for any of the errors specified for the library routines
209 .Xr read 2 ,
210 .Xr write 2 ,
211 and
212 .Xr malloc 3 .
213 .Pp
214 The
215 .Fn mpool_sync
216 function may fail and set
217 .Va errno
218 for any of the errors specified for the library routine
219 .Xr write 2 .
220 .Pp
221 The
222 .Fn mpool_close
223 function may fail and set
224 .Va errno
225 for any of the errors specified for the library routine
226 .Xr free 3 .
227 .Sh SEE ALSO
228 .Xr btree 3 ,
229 .Xr dbopen 3 ,
230 .Xr hash 3 ,
231 .Xr recno 3