1 .\" $NetBSD: mpool.3,v 1.10 2010/12/16 11:49:35 jruoho Exp $
3 .\" Copyright (c) 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
44 .Nd shared memory buffer pool
49 .Fn mpool_open "DBT *key" "int fd" "pgno_t pagesize" "pgno_t maxcache"
51 .Fn mpool_filter "MPOOL *mp" "void (*pgin)(void *, pgno_t, void *)" \
52 "void (*pgout)(void *, pgno_t, void *)" "void *pgcookie"
54 .Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr"
56 .Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags"
58 .Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags"
60 .Fn mpool_sync "MPOOL *mp"
62 .Fn mpool_close "MPOOL *mp"
65 is the library interface intended to provide page oriented buffer
67 The buffers may be shared between processes.
71 initializes a memory pool.
74 argument is the byte string used to negotiate between multiple
75 processes wishing to share buffers.
76 If the file buffers are mapped in shared memory, all processes using
77 the same key will share the buffers.
82 the buffers are mapped into private memory.
85 argument is a file descriptor for the underlying file, which must be
91 and matches a file already being mapped, the
97 argument is the size, in bytes, of the pages into which the file is
101 argument is the maximum number of pages from the underlying file to
102 cache at any one time.
103 This value is not relative to the number of processes which share a
104 file's buffers, but will be the largest value specified by any of the
105 processes sharing the file.
109 function is intended to make transparent input and output processing
110 of the pages possible.
113 function is specified, it is called each time a buffer is read into
114 the memory pool from the backing file.
117 function is specified, it is called each time a buffer is written into
119 Both functions are are called with the
121 pointer, the page number and a pointer to the page to being read or
126 takes an MPOOL pointer and an address as arguments.
127 If a new page can be allocated, a pointer to the page is returned and
128 the page number is stored into the
133 is returned and errno is set.
137 takes a MPOOL pointer and a page number as arguments.
138 If the page exists, a pointer to the page is returned.
141 is returned and errno is set.
142 The flags parameter is not currently used.
146 unpins the page referenced by
149 must be an address previously returned by
153 The flag value is specified by or'ing any of the following values:
154 .Bl -tag -width MPOOL_DIRTYX -offset indent
156 The page has been modified and needs to be written to the backing
161 returns 0 on success and \-1 if an error occurs.
165 writes all modified pages associated with the MPOOL pointer to the
168 returns 0 on success and \-1 if an error occurs.
172 function frees up any allocated memory associated with the memory pool
176 written to the backing file.
178 returns 0 on success and \-1 if an error occurs.
182 function may fail and set
184 for any of the errors specified for the library routine
189 function may fail and set
192 .Bl -tag -width Er -offset indent
194 The requested record doesn't exist.
201 functions may fail and set
203 for any of the errors specified for the library routines
211 function may fail and set
213 for any of the errors specified for the library routine
218 function may fail and set
220 for any of the errors specified for the library routine