xref: /minix3/lib/libc/db/man/mpool.3 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\"	$NetBSD: mpool.3,v 1.10 2010/12/16 11:49:35 jruoho Exp $
22639ae9bSBen Gras.\"
32639ae9bSBen Gras.\" Copyright (c) 1990, 1993
42639ae9bSBen Gras.\"	The Regents of the University of California.  All rights reserved.
52639ae9bSBen Gras.\"
62639ae9bSBen Gras.\" Redistribution and use in source and binary forms, with or without
72639ae9bSBen Gras.\" modification, are permitted provided that the following conditions
82639ae9bSBen Gras.\" are met:
92639ae9bSBen Gras.\" 1. Redistributions of source code must retain the above copyright
102639ae9bSBen Gras.\"    notice, this list of conditions and the following disclaimer.
112639ae9bSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122639ae9bSBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132639ae9bSBen Gras.\"    documentation and/or other materials provided with the distribution.
142639ae9bSBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152639ae9bSBen Gras.\"    may be used to endorse or promote products derived from this software
162639ae9bSBen Gras.\"    without specific prior written permission.
172639ae9bSBen Gras.\"
182639ae9bSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192639ae9bSBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202639ae9bSBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212639ae9bSBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222639ae9bSBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232639ae9bSBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242639ae9bSBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252639ae9bSBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262639ae9bSBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272639ae9bSBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282639ae9bSBen Gras.\" SUCH DAMAGE.
292639ae9bSBen Gras.\"
302639ae9bSBen Gras.\"	@(#)mpool.3	8.1 (Berkeley) 6/4/93
312639ae9bSBen Gras.\"
32*2fe8fb19SBen Gras.Dd December 16, 2010
332639ae9bSBen Gras.Dt MPOOL 3
342639ae9bSBen Gras.Os
352639ae9bSBen Gras.Sh NAME
362639ae9bSBen Gras.Nm mpool ,
372639ae9bSBen Gras.Nm mpool_open ,
382639ae9bSBen Gras.Nm mpool_filter ,
392639ae9bSBen Gras.Nm mpool_new ,
402639ae9bSBen Gras.Nm mpool_get ,
412639ae9bSBen Gras.Nm mpool_put ,
422639ae9bSBen Gras.Nm mpool_sync ,
432639ae9bSBen Gras.Nm mpool_close
442639ae9bSBen Gras.Nd shared memory buffer pool
452639ae9bSBen Gras.Sh SYNOPSIS
462639ae9bSBen Gras.In db.h
472639ae9bSBen Gras.In mpool.h
482639ae9bSBen Gras.Ft MPOOL *
492639ae9bSBen Gras.Fn mpool_open "DBT *key" "int fd" "pgno_t pagesize" "pgno_t maxcache"
502639ae9bSBen Gras.Ft void
512639ae9bSBen Gras.Fn mpool_filter "MPOOL *mp" "void (*pgin)(void *, pgno_t, void *)" \
522639ae9bSBen Gras"void (*pgout)(void *, pgno_t, void *)" "void *pgcookie"
532639ae9bSBen Gras.Ft void *
542639ae9bSBen Gras.Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr"
552639ae9bSBen Gras.Ft void *
562639ae9bSBen Gras.Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags"
572639ae9bSBen Gras.Ft int
582639ae9bSBen Gras.Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags"
592639ae9bSBen Gras.Ft int
602639ae9bSBen Gras.Fn mpool_sync "MPOOL *mp"
612639ae9bSBen Gras.Ft int
622639ae9bSBen Gras.Fn mpool_close "MPOOL *mp"
632639ae9bSBen Gras.Sh DESCRIPTION
642639ae9bSBen Gras.Nm
652639ae9bSBen Grasis the library interface intended to provide page oriented buffer
662639ae9bSBen Grasmanagement of files.
672639ae9bSBen GrasThe buffers may be shared between processes.
682639ae9bSBen Gras.Pp
692639ae9bSBen GrasThe function
70*2fe8fb19SBen Gras.Fn mpool_open
712639ae9bSBen Grasinitializes a memory pool.
722639ae9bSBen GrasThe
732639ae9bSBen Gras.Fa key
742639ae9bSBen Grasargument is the byte string used to negotiate between multiple
752639ae9bSBen Grasprocesses wishing to share buffers.
762639ae9bSBen GrasIf the file buffers are mapped in shared memory, all processes using
772639ae9bSBen Grasthe same key will share the buffers.
782639ae9bSBen GrasIf
792639ae9bSBen Gras.Fa key
802639ae9bSBen Grasis
812639ae9bSBen Gras.Dv NULL ,
822639ae9bSBen Grasthe buffers are mapped into private memory.
832639ae9bSBen GrasThe
842639ae9bSBen Gras.Fa fd
852639ae9bSBen Grasargument is a file descriptor for the underlying file, which must be
862639ae9bSBen Grasseekable.
872639ae9bSBen GrasIf
882639ae9bSBen Gras.Fa key
892639ae9bSBen Grasis
902639ae9bSBen Gras.No non- Ns Dv NULL
912639ae9bSBen Grasand matches a file already being mapped, the
922639ae9bSBen Gras.Fa fd
932639ae9bSBen Grasargument is ignored.
942639ae9bSBen Gras.Pp
952639ae9bSBen GrasThe
962639ae9bSBen Gras.Fa pagesize
972639ae9bSBen Grasargument is the size, in bytes, of the pages into which the file is
982639ae9bSBen Grasbroken up.
992639ae9bSBen GrasThe
1002639ae9bSBen Gras.Fa maxcache
1012639ae9bSBen Grasargument is the maximum number of pages from the underlying file to
1022639ae9bSBen Grascache at any one time.
1032639ae9bSBen GrasThis value is not relative to the number of processes which share a
1042639ae9bSBen Grasfile's buffers, but will be the largest value specified by any of the
1052639ae9bSBen Grasprocesses sharing the file.
1062639ae9bSBen Gras.Pp
1072639ae9bSBen GrasThe
108*2fe8fb19SBen Gras.Fn mpool_filter
1092639ae9bSBen Grasfunction is intended to make transparent input and output processing
1102639ae9bSBen Grasof the pages possible.
1112639ae9bSBen GrasIf the
1122639ae9bSBen Gras.Fa pgin
1132639ae9bSBen Grasfunction is specified, it is called each time a buffer is read into
1142639ae9bSBen Grasthe memory pool from the backing file.
1152639ae9bSBen GrasIf the
1162639ae9bSBen Gras.Fa pgout
1172639ae9bSBen Grasfunction is specified, it is called each time a buffer is written into
1182639ae9bSBen Grasthe backing file.
1192639ae9bSBen GrasBoth functions are are called with the
1202639ae9bSBen Gras.Fa pgcookie
1212639ae9bSBen Graspointer, the page number and a pointer to the page to being read or
1222639ae9bSBen Graswritten.
1232639ae9bSBen Gras.Pp
1242639ae9bSBen GrasThe function
125*2fe8fb19SBen Gras.Fn mpool_new
1262639ae9bSBen Grastakes an MPOOL pointer and an address as arguments.
1272639ae9bSBen GrasIf a new page can be allocated, a pointer to the page is returned and
1282639ae9bSBen Grasthe page number is stored into the
1292639ae9bSBen Gras.Fa pgnoaddr
1302639ae9bSBen Grasaddress.
1312639ae9bSBen GrasOtherwise,
1322639ae9bSBen Gras.Dv NULL
1332639ae9bSBen Grasis returned and errno is set.
1342639ae9bSBen Gras.Pp
1352639ae9bSBen GrasThe function
136*2fe8fb19SBen Gras.Fn mpool_get
1372639ae9bSBen Grastakes a MPOOL pointer and a page number as arguments.
1382639ae9bSBen GrasIf the page exists, a pointer to the page is returned.
1392639ae9bSBen GrasOtherwise,
1402639ae9bSBen Gras.Dv NULL
1412639ae9bSBen Grasis returned and errno is set.
1422639ae9bSBen GrasThe flags parameter is not currently used.
1432639ae9bSBen Gras.Pp
1442639ae9bSBen GrasThe function
145*2fe8fb19SBen Gras.Fn mpool_put
1462639ae9bSBen Grasunpins the page referenced by
1472639ae9bSBen Gras.Fa pgaddr .
1482639ae9bSBen Gras.Fa pgaddr
1492639ae9bSBen Grasmust be an address previously returned by
150*2fe8fb19SBen Gras.Fn mpool_get
1512639ae9bSBen Grasor
152*2fe8fb19SBen Gras.Fn mpool_new .
1532639ae9bSBen GrasThe flag value is specified by or'ing any of the following values:
1542639ae9bSBen Gras.Bl -tag -width MPOOL_DIRTYX -offset indent
1552639ae9bSBen Gras.It Dv MPOOL_DIRTY
1562639ae9bSBen GrasThe page has been modified and needs to be written to the backing
1572639ae9bSBen Grasfile.
1582639ae9bSBen Gras.El
1592639ae9bSBen Gras.Pp
160*2fe8fb19SBen Gras.Fn mpool_put
1612639ae9bSBen Grasreturns 0 on success and \-1 if an error occurs.
1622639ae9bSBen Gras.Pp
1632639ae9bSBen GrasThe function
164*2fe8fb19SBen Gras.Fn mpool_sync
1652639ae9bSBen Graswrites all modified pages associated with the MPOOL pointer to the
1662639ae9bSBen Grasbacking file.
167*2fe8fb19SBen Gras.Fn mpool_sync
1682639ae9bSBen Grasreturns 0 on success and \-1 if an error occurs.
1692639ae9bSBen Gras.Pp
1702639ae9bSBen GrasThe
171*2fe8fb19SBen Gras.Fn mpool_close
1722639ae9bSBen Grasfunction frees up any allocated memory associated with the memory pool
1732639ae9bSBen Grascookie.
1742639ae9bSBen GrasModified pages are
1752639ae9bSBen Gras.Em not
1762639ae9bSBen Graswritten to the backing file.
177*2fe8fb19SBen Gras.Fn mpool_close
1782639ae9bSBen Grasreturns 0 on success and \-1 if an error occurs.
1792639ae9bSBen Gras.Sh ERRORS
1802639ae9bSBen GrasThe
181*2fe8fb19SBen Gras.Fn mpool_open
1822639ae9bSBen Grasfunction may fail and set
1832639ae9bSBen Gras.Va errno
1842639ae9bSBen Grasfor any of the errors specified for the library routine
1852639ae9bSBen Gras.Xr malloc 3 .
1862639ae9bSBen Gras.Pp
1872639ae9bSBen GrasThe
188*2fe8fb19SBen Gras.Fn mpool_get
1892639ae9bSBen Grasfunction may fail and set
1902639ae9bSBen Gras.Va errno
1912639ae9bSBen Grasfor the following:
1922639ae9bSBen Gras.Bl -tag -width Er -offset indent
1932639ae9bSBen Gras.It Er EINVAL
1942639ae9bSBen GrasThe requested record doesn't exist.
1952639ae9bSBen Gras.El
1962639ae9bSBen Gras.Pp
1972639ae9bSBen GrasThe
198*2fe8fb19SBen Gras.Fn mpool_new
1992639ae9bSBen Grasand
200*2fe8fb19SBen Gras.Fn mpool_get
2012639ae9bSBen Grasfunctions may fail and set
2022639ae9bSBen Gras.Va errno
2032639ae9bSBen Grasfor any of the errors specified for the library routines
2042639ae9bSBen Gras.Xr read 2 ,
2052639ae9bSBen Gras.Xr write 2 ,
2062639ae9bSBen Grasand
2072639ae9bSBen Gras.Xr malloc 3 .
2082639ae9bSBen Gras.Pp
2092639ae9bSBen GrasThe
210*2fe8fb19SBen Gras.Fn mpool_sync
2112639ae9bSBen Grasfunction may fail and set
2122639ae9bSBen Gras.Va errno
2132639ae9bSBen Grasfor any of the errors specified for the library routine
2142639ae9bSBen Gras.Xr write 2 .
2152639ae9bSBen Gras.Pp
2162639ae9bSBen GrasThe
217*2fe8fb19SBen Gras.Fn mpool_close
2182639ae9bSBen Grasfunction may fail and set
2192639ae9bSBen Gras.Va errno
2202639ae9bSBen Grasfor any of the errors specified for the library routine
2212639ae9bSBen Gras.Xr free 3 .
2222639ae9bSBen Gras.Sh SEE ALSO
2232639ae9bSBen Gras.Xr btree 3 ,
2242639ae9bSBen Gras.Xr dbopen 3 ,
2252639ae9bSBen Gras.Xr hash 3 ,
2262639ae9bSBen Gras.Xr recno 3
227