1 .\" Copyright (c) 1990, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
36 .Nd "shared memory buffer pool"
41 .Fn mpool_open "void *key" "int fd" "pgno_t pagesize" "pgno_t maxcache"
45 .Fa "void (*pgin)(void *, pgno_t, void *)"
46 .Fa "void (*pgout)(void *, pgno_t, void *)"
50 .Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr" "u_int flags"
52 .Fn mpool_delete "MPOOL *mp" "void *page"
54 .Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags"
56 .Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags"
58 .Fn mpool_sync "MPOOL *mp"
60 .Fn mpool_close "MPOOL *mp"
64 library interface is intended to provide page oriented buffer management
69 function initializes a memory pool.
72 argument is currently ignored.
75 argument is a file descriptor for the underlying file, which must be seekable.
79 argument is the size, in bytes, of the pages into which the file is broken up.
82 argument is the maximum number of pages from the underlying file to cache
84 This value is not relative to the number of processes which share a file's
85 buffers, but will be the largest value specified by any of the processes
90 function is intended to make transparent input and output processing of the
94 function is specified, it is called each time a buffer is read into the memory
95 pool from the backing file.
98 function is specified, it is called each time a buffer is written into the
100 Both functions are called with the
102 pointer, the page number and a pointer to the page to being read or written.
108 pointer, an address, and a set of flags as arguments.
109 If a new page can be allocated, a pointer to the page is returned and
110 the page number is stored into the
118 The flags value is formed by
120 the following values:
122 .It Dv MPOOL_PAGE_REQUEST
123 Allocate a new page with a specific page number.
124 .It Dv MPOOL_PAGE_NEXT
125 Allocate a new page with the next page number.
130 deletes the specified page from a pool and frees the page.
133 pointer and a page as arguments.
134 The page must have been generated by
141 pointer and a page number as arguments.
142 If the page exists, a pointer to the page is returned.
150 argument is specified by
152 any of the following values:
153 .Bl -tag -width indent
154 .It Dv MPOOL_IGNOREPIN
155 The page returned is not pinned;
156 page will otherwise be pinned on return.
161 function unpins the page referenced by
166 must be an address previously returned by
172 argument is specified by
174 any of the following values:
175 .Bl -tag -width indent
177 The page has been modified and needs to be written to the backing file.
183 returns 0 on success and -1 if an error occurs.
187 function writes all modified pages associated with the
194 returns 0 on success and -1 if an error occurs.
198 function free's up any allocated memory associated with the memory pool
202 written to the backing file.
206 returns 0 on success and -1 if an error occurs.
210 function may fail and set
212 for any of the errors specified for the library routine
217 function may fail and set
222 The requested record does not exist.
229 functions may fail and set
231 for any of the errors specified for the library routines
239 function may fail and set
241 for any of the errors specified for the library routine
246 function may fail and set
248 for any of the errors specified for the library routine