DbMpoolFile



NAME

       DbMpoolFile - shared memory buffer pool


SYNOPSIS

       #include <db_cxx.h>

       static int
       DbMpoolFile::open(DbMpool *mp, char *file, int ftype, int flags,
            int mode, size_t pagesize, int lsn_offset, Dbt *pgcookie,
            u_int8_t *uid, DbMpoolFile **mpf);

       int
       DbMpoolFile::close();

       int
       DbMpoolFile::get(db_pgno_t *pgnoaddr, int flags, void **pagep);

       int
       DbMpoolFile::put(void *pgaddr, int flags);

       int
       DbMpoolFile::set(void *pgaddr, int flags);

       int
       DbMpoolFile::sync();


DESCRIPTION

       The DB library is a family of classes that provides a mod-
       ular programming interface to transactions and record-ori-
       ented  file  access.   The  library  includes  support for
       transactions, locking, logging and file page  caching,  as
       well  as  various  indexed  access  methods.   Many of the
       classes (e.g., the file page  caching  class)  are  useful
       independent of the other DB classes, although some classes
       are explicitly based on other classes (e.g.,  transactions
       and  logging).   For a general description of the DB pack-
       age, see db_intro(3).

       This manual page describes the  specific  details  of  the
       per-file memory pool interface.

       The  DbMpool(3) and DbMpoolFile(3) classes are the library
       interface intended to provide  general-purpose,  page-ori-
       ented  buffer  management  of  one  or  more files.  While
       designed to work with the other Db functions, these  func-
       tions are also useful for more general purposes.  The mem-
       ory pools (DbMpool::'s) are referred to in  this  document
       as  simply  ``pools''.   Pools  may be shared between pro-
       cesses.  Pools are usually filled by  pages  from  one  or
       more   files  (DbMpoolFile's).   Pages  in  the  pool  are
       replaced in LRU (least-recently-used) order, with each new
       page  replacing the page that has been unused the longest.
       Pages retrieved from the pool using  DbMpoolFile::get  are
       ``pinned''  in  the  pool,  by  default,  until  they  are

       The ftype argument should be the same as a ftype  argument
       previously  specified  to the DbMpool::db_register method,
       unless no input or output processing of the  file's  pages
       are  necessary,  in  which  case it should be 0.  (See the
       description of the DbMpool::db_register  method  for  more
       information.)

       The  flags  and  mode  arguments specify how files will be
       opened and/or created when they don't already exist.   The
       flags value is specified by or'ing together one or more of
       the following values:

       DB_CREATE
            Create any underlying files, as  necessary.   If  the
            files  do not already exist and the DB_CREATE flag is
            not specified, the call will fail.

       DB_NOMMAP
            Always copy this file into the local cache instead of
            mapping  it  into process memory (see the description
            of the mp_mmapsize field of the DbEnv object for fur-
            ther information).

       DB_RDONLY
            Open  any  underlying  files  for  reading only.  Any
            attempt to write the file using  the  pool  functions
            will  fail,  regardless  of the actual permissions of
            the file.

       All files created by the method DbMpoolFile::open are cre-
       ated  with  mode mode (as described in chmod(2)) and modi-
       fied by the process' umask value at the time  of  creation
       (see  umask(2)).   The group ownership of created files is
       based on the system and directory  defaults,  and  is  not
       further specified by DB.

       The  pagesize  argument is the size, in bytes, of the unit
       of transfer between the application and the pool, although
       it  is  not  necessarily  the unit of transfer between the
       pool and the source file.


       The lsn_offset argument is the zero-based byte  offset  in
       the page of the page's log sequence number (LSN), or -1 if
       no LSN offset is specified.  (See the description  of  the
       DbMpool::sync method for more information.)

       The  pgcookie  argument  contains  the byte string that is
       passed to the pgin and pgout functions for this  file,  if
       any.   (See  the  description  of the DbMpool::db_register
       method for more information.)

       The uid argument is a unique identifier for the file.  The
       provide  the  same unique identifier.  If the uid argument
       is  non-NULL,  it  must  reference  a  DB_FILE_ID_LEN  (as
       defined  in <db_cxx.h>) length array of bytes that will be
       used to uniquely identify the file.  This  should  not  be
       necessary  for most applications.  Specifically, it is not
       necessary if the memory pool is re-instantiated after each
       system  reboot,  the  application  is  using the Db access
       methods instead of calling the pool functions  explicitly,
       or  the files in the memory pool are stored on filesystems
       where the file device and  inode  numbers  do  not  change
       across system reboots.

       The  DbMpoolFile::open  method  throws a DbException(3) or
       returns the value of errno on failure and 0 on success.

  DbMpoolFile::close
       The DbMpoolFile::close method closes the source file indi-
       cated  by  the  DbMpoolFile  object.  This method does not
       imply a call to DbMpoolFile::sync, i.e. no pages are writ-
       ten  to  the  source  file  as as a result of calling DbM-
       poolFile::close.

       In addition, if the file argument to DbMpoolFile::open was
       NULL,  any  underlying  files created for this DbMpoolFile
       will be removed.

       The DbMpoolFile::close method throws a  DbException(3)  or
       returns the value of errno on failure and 0 on success.

  DbMpoolFile::get
       The  DbMpoolFile::get  method copies a pointer to the page
       with the page  number  specified  by  pgnoaddr,  from  the
       source  file  specified by the DbMpoolFile object into the
       memory location referenced by pagep.  If the page does not
       exist  or cannot be retrieved, DbMpoolFile::get will fail.

       The returned page is size_t type aligned.

       Page numbers begin at 0, e.g., the first page in the  file
       is page number 0, not page number 1.

       The  flags argument is specified by or'ing together one or
       more of the following values:

       DB_MPOOL_CREATE
            If the specified page does not exist, create it.   In
            this  case, the pgin method, if specified, is called.

       DB_MPOOL_LAST
            Return the last page of the source file and copy  its
            page number to the location referenced by pgnoaddr.

       DB_MPOOL_NEW
            Create  a new page in the file and copy its page num-

       The DbMpoolFile::get method  throws  a  DbException(3)  or
       returns the value of errno on failure and 0 on success.

  DbMpoolFile::put
       The DbMpoolFile::put method indicates that the page refer-
       enced by pgaddr can be evicted from the pool.  Pgaddr must
       be an address previously returned by DbMpoolFile::get.

       The  flags argument is specified by or'ing together one or
       more of the following values:

       DB_MPOOL_CLEAN
            Clear any  previously  set  modification  information
            (i.e.,  don't  bother  writing  the  page back to the
            source file).

       DB_MPOOL_DIRTY
            The page has been modified and must be written to the
            source file before being evicted from the pool.
       DB_MPOOL_DISCARD
            The page is unlikely to be useful in the near future,
            and should be discarded before  other  pages  in  the
            pool.

       The  DB_MPOOL_CLEAN  and DB_MPOOL_DIRTY flags are mutually
       exclusive.

       The DbMpoolFile::put method  throws  a  DbException(3)  or
       returns the value of errno on failure and 0 on success.

  DbMpoolFile::set
       The DbMpoolFile::set method sets the flags associated with
       the page referenced by pgaddr without  unpinning  it  from
       the  pool.   Pgaddr must be an address previously returned
       by  DbMpoolFile::get.   The   flags   argument   to   DbM-
       poolFile::set  is specified by or'ing together one or more
       of the values specified as flags for the  DbMpoolFile::put
       call.

       The  DbMpoolFile::set  method  throws  a DbException(3) or
       returns the value of errno on failure and 0 on success.

  DbMpoolFile::sync
       The DbMpoolFile::sync method writes all  pages  associated
       with  the  DbMpoolFile object that were marked as modified
       using DbMpoolFile::put or DbMpoolFile::set,  back  to  the
       source file.  If any of the modified pages are also pinned
       (i.e., currently referenced by this  or  another  process)
       DbMpoolFile::sync will ignore them.

       The  DbMpoolFile::sync  method  throws a DbException(3) or
       returns the value of errno on failure, 0 on  success,  and
       DB_INCOMPLETE  if there were pages which were modified but
       which DbMpoolFile::sync was unable to write.
       mmap(2), open(2), sigfillset(3), sigprocmask(2), stat(2),
       strcpy(3), strdup(3), strerror(3), strlen(3), time(3),
       unlink(2), and write(2).

       In  addition,  the  DbMpoolFile::open  method may fail and
       throw a DbException(3) or return errno for  the  following
       conditions:
       [EINVAL]
            An invalid flag value or parameter was specified.

            The  file has already been entered into the pool, and
            the pagesize value is not the same as when  the  file
            was  entered into the pool, or the length of the file
            is not zero or a multiple of the pagesize.

            The DB_RDONLY flag was  specified  for  an  in-memory
            pool.

       The  DbMpoolFile::close  method may fail and throw a DbEx-
       ception(3) or return errno for any of the errors specified
       for the following DB and library functions: close(2),
       fcntl(2), fflush(3), munmap(2), and strerror(3).

       The DbMpoolFile::get method may fail and throw a  DbExcep-
       tion(3)  or  return  errno for any of the errors specified
       for the following DB and library functions:
       DBmemp->pgin(3), DBmemp->pgout(3), DbLog::compare(3),
       DbLog::flush(3), close(2), fcntl(2), fflush(3), fsync(2),
       lseek(2), malloc(3), memcmp(3), memcpy(3), memset(3),
       mmap(2), open(2), read(2), sigfillset(3), sigprocmask(2),
       stat(2), strcpy(3), strdup(3), strerror(3), strlen(3),
       time(3), unlink(2), and write(2).

       In addition, the  DbMpoolFile::get  method  may  fail  and
       throw  a  DbException(3) or return errno for the following
       conditions:

       [EAGAIN]
            The  page  reference  count  has  overflowed.   (This
            should  never  happen unless there's a bug in the ap-
            plication.)

       [EINVAL]
            An invalid flag value or parameter was specified.

            The DB_MPOOL_NEW flag was set and the source file was
            not opened for writing.

            The requested page does not exist and DB_MPOOL_CREATE
            was not set.

            More than one of DB_MPOOL_CREATE,  DB_MPOOL_LAST  and
            DB_MPOOL_NEW was set.

       unlink(2), and write(2).

       In addition, the  DbMpoolFile::put  method  may  fail  and
       throw  a  DbException(3) or return errno for the following
       conditions:

       [EACCES]
            The DB_MPOOL_DIRTY flag was set and the  source  file
            was not opened for writing.

       [EINVAL]
            An invalid flag value or parameter was specified.

            The  pgaddr  parameter  does not reference a page re-
            turned by DbMpoolFile::get.

            More than one of  DB_MPOOL_CLEAN  and  DB_MPOOL_DIRTY
            was set.

       The  DbMpoolFile::set method may fail and throw a DbExcep-
       tion(3) or return errno for any of  the  errors  specified
       for the following DB and library functions: fcntl(2), and
       fflush(3).

       In addition, the  DbMpoolFile::set  method  may  fail  and
       throw  a  DbException(3) or return errno for the following
       conditions:

       [EINVAL]
            An invalid flag value or parameter was specified.

       The DbMpoolFile::sync method may fail and throw a DbExcep-
       tion(3)  or  return  errno for any of the errors specified
       for the following DB and library functions:
       DBmemp->pgin(3), DBmemp->pgout(3), DbLog::compare(3),
       DbLog::flush(3), close(2), fcntl(2), fflush(3), fsync(2),
       lseek(2), malloc(3), memcpy(3), memset(3), open(2),
       qsort(3), realloc(3), sigfillset(3), sigprocmask(2),
       stat(2), strcpy(3), strdup(3), strerror(3), strlen(3),
       unlink(2), and write(2).



SEE ALSO

       db_archive(1), db_checkpoint(1), db_deadlock(1), db_dump(1),
       db_load(1), db_recover(1), db_stat(1), db_intro(3), db_jump(3),
       db_thread(3), Db(3), Dbc(3), DbEnv(3), DbException(3), DbInfo(3),
       DbLock(3), DbLocktab(3), DbLog(3), DbLsn(3), DbMpool(3),
       DbMpoolFile(3), Dbt(3), DbTxn(3), DbTxnMgr(3)