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 .\" 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.
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
32 .\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/db/man/mpool.3,v 1.5.2.5 2003/02/23 19:45:52 trhodes Exp $
34 .\" $DragonFly: src/lib/libc/db/man/mpool.3,v 1.2 2003/06/17 04:26:41 dillon Exp $
41 .Nd "shared memory buffer pool"
46 .Fn mpool_open "void *key" "int fd" "pgno_t pagesize" "pgno_t maxcache"
50 .Fa "void (*pgin)(void *, pgno_t, void *)"
51 .Fa "void (*pgout)(void *, pgno_t, void *)"
55 .Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr"
57 .Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags"
59 .Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags"
61 .Fn mpool_sync "MPOOL *mp"
63 .Fn mpool_close "MPOOL *mp"
67 library interface is intended to provide page oriented buffer management
69 The buffers may be shared between processes.
73 function initializes a memory pool.
76 argument is the byte string used to negotiate between multiple
77 processes wishing to share buffers.
78 If the file buffers are mapped in shared memory, all processes using
79 the same key will share the buffers.
84 the buffers are mapped into private memory.
87 argument is a file descriptor for the underlying file, which must be seekable.
92 and matches a file already being mapped, the
98 argument is the size, in bytes, of the pages into which the file is broken up.
101 argument is the maximum number of pages from the underlying file to cache
103 This value is not relative to the number of processes which share a file's
104 buffers, but will be the largest value specified by any of the processes
109 function is intended to make transparent input and output processing of the
113 function is specified, it is called each time a buffer is read into the memory
114 pool from the backing file.
117 function is specified, it is called each time a buffer is written into the
119 Both functions are called with the
121 pointer, the page number and a pointer to the page to being read or written.
127 pointer and an address as arguments.
128 If a new page can be allocated, a pointer to the page is returned and
129 the page number is stored into the
142 pointer and a page number as arguments.
143 If the page exists, a pointer to the page is returned.
151 argument is not currently used.
155 function unpins the page referenced by
160 must be an address previously returned by
166 argument is specified by
168 any of the following values:
169 .Bl -tag -width indent
171 The page has been modified and needs to be written to the backing file.
177 returns 0 on success and -1 if an error occurs.
181 function writes all modified pages associated with the
188 returns 0 on success and -1 if an error occurs.
192 function free's up any allocated memory associated with the memory pool
196 written to the backing file.
200 returns 0 on success and -1 if an error occurs.
204 function may fail and set
206 for any of the errors specified for the library routine
211 function may fail and set
216 The requested record doesn't exist.
223 functions may fail and set
225 for any of the errors specified for the library routines
233 function may fail and set
235 for any of the errors specified for the library routine
240 function may fail and set
242 for any of the errors specified for the library routine