Blob Blame History Raw
.\" Automatically generated by Pandoc 2.1.3
.\"
.TH "LIBPMEMOBJ" "7" "2018-10-17" "PMDK - pmemobj API version 2.3" "PMDK Programmer's Manual"
.hy
.\" Copyright 2014-2018, Intel Corporation
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\"     * Redistributions of source code must retain the above copyright
.\"       notice, this list of conditions and the following disclaimer.
.\"
.\"     * Redistributions in binary form must reproduce the above copyright
.\"       notice, this list of conditions and the following disclaimer in
.\"       the documentation and/or other materials provided with the
.\"       distribution.
.\"
.\"     * Neither the name of the copyright holder nor the names of its
.\"       contributors may be used to endorse or promote products derived
.\"       from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.SH NAME
.PP
\f[B]libpmemobj\f[] \- persistent memory transactional object store
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <libpmemobj.h>
cc\ \-std=gnu99\ ...\ \-lpmemobj\ \-lpmem
\f[]
.fi
.SS Library API versioning:
.IP
.nf
\f[C]
const\ char\ *pmemobj_check_version(
\ \ \ \ unsigned\ major_required,
\ \ \ \ unsigned\ minor_required);
\f[]
.fi
.SS Managing library behavior:
.IP
.nf
\f[C]
void\ pmemobj_set_funcs(
\ \ \ \ void\ *(*malloc_func)(size_t\ size),
\ \ \ \ void\ (*free_func)(void\ *ptr),
\ \ \ \ void\ *(*realloc_func)(void\ *ptr,\ size_t\ size),
\ \ \ \ char\ *(*strdup_func)(const\ char\ *s));
\f[]
.fi
.SS Error handling:
.IP
.nf
\f[C]
const\ char\ *pmemobj_errormsg(void);
\f[]
.fi
.SS Other library functions:
.PP
A description of other \f[B]libpmemobj\f[] functions can be found on the
following manual pages:
.IP \[bu] 2
control and statistics: \f[B]pmemobj_ctl_get\f[](3)
.IP \[bu] 2
create, open, close and validate: \f[B]pmemobj_open\f[](3)
.IP \[bu] 2
low\-level memory manipulation: \f[B]pmemobj_memcpy_persist\f[](3)
.IP \[bu] 2
locking: \f[B]pmemobj_mutex_zero\f[](3)
.IP \[bu] 2
persistent object identifier: \f[B]OID_IS_NULL\f[](3)
.IP \[bu] 2
type\-safety: \f[B]TOID_DECLARE\f[](3)
.IP \[bu] 2
layout declaration: \f[B]POBJ_LAYOUT_BEGIN\f[](3)
.IP \[bu] 2
non\-transactional atomic allocations: \f[B]pmemobj_alloc\f[](3)
.IP \[bu] 2
root object management: \f[B]pmemobj_root\f[](3)
.IP \[bu] 2
object containers: \f[B]pmemobj_first\f[](3)
.IP \[bu] 2
non\-transactional persistent atomic circular doubly\-linked list:
\f[B]pmemobj_list_insert\f[](3), \f[B]POBJ_LIST_HEAD\f[](3)
.IP \[bu] 2
transactional object manipulation: \f[B]pmemobj_tx_begin\f[](3),
\f[B]pmemobj_tx_add_range\f[](3), \f[B]pmemobj_tx_alloc\f[](3)
.IP \[bu] 2
delayed atomicity actions: \f[B]pmemobj_action\f[](3) (EXPERIMENTAL)
.SH DESCRIPTION
.PP
\f[B]libpmemobj\f[] provides a transactional object store in
\f[I]persistent memory\f[] (pmem) for applications that require
transactions and persistent memory management using direct access
storage (DAX), which is storage that supports load/store access without
paging blocks from a block storage device.
Some types of \f[I]non\-volatile memory DIMMs\f[] (NVDIMMs) provide this
type of byte addressable access to storage.
A \f[I]persistent memory aware file system\f[] is typically used to
expose the direct access to applications.
Memory mapping a file from this type of file system results in
load/store, non\-paged access to pmem.
\f[B]libpmemobj\f[] builds on this type of memory mapped file using the
low\-level pmem support provided by \f[B]libpmem\f[](7), handling the
transactional updates, flushing changes to persistence, and managing
recovery for the application.
.PP
\f[B]libpmemobj\f[] requires the \f[B]\-std=gnu99\f[] compilation flag
to build properly.
.PP
\f[B]libpmemobj\f[] is one of a collection of persistent memory
libraries available.
The others are:
.IP \[bu] 2
\f[B]libpmemblk\f[](7), providing pmem\-resident arrays of fixed\-sized
blocks with atomic updates.
.IP \[bu] 2
\f[B]libpmemlog\f[](7), providing a pmem\-resident log file.
.IP \[bu] 2
\f[B]libpmem\f[](7), low\-level persistent memory support.
.PP
Under normal usage, \f[B]libpmemobj\f[] will never print messages or
intentionally cause the process to exit.
The only exception to this is the debugging information, when enabled,
as described under \f[B]DEBUGGING AND ERROR HANDLING\f[], below.
.SH LIBRARY API VERSIONING
.PP
This section describes how the library API is versioned, allowing
applications to work with an evolving API.
.PP
The \f[B]pmemobj_check_version\f[]() function is used to see if the
installed \f[B]libpmemobj\f[] supports the version of the library API
required by an application.
The easiest way to do this is for the application to supply the
compile\-time version information, supplied by defines in
\f[B]<libpmemobj.h>\f[], like this:
.IP
.nf
\f[C]
reason\ =\ pmemobj_check_version(PMEMOBJ_MAJOR_VERSION,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ PMEMOBJ_MINOR_VERSION);
if\ (reason\ !=\ NULL)\ {
\ \ \ \ /*\ version\ check\ failed,\ reason\ string\ tells\ you\ why\ */
}
\f[]
.fi
.PP
Any mismatch in the major version number is considered a failure, but a
library with a newer minor version number will pass this check since
increasing minor versions imply backwards compatibility.
.PP
An application can also check specifically for the existence of an
interface by checking for the version where that interface was
introduced.
These versions are documented in this man page as follows: unless
otherwise specified, all interfaces described here are available in
version 1.0 of the library.
Interfaces added after version 1.0 will contain the text \f[I]introduced
in version x.y\f[] in the section of this manual describing the feature.
.PP
On success, \f[B]pmemobj_check_version\f[]() returns NULL.
Otherwise, the return value is a static string describing the reason the
version check failed.
The string returned by \f[B]pmemobj_check_version\f[]() must not be
modified or freed.
.SH MANAGING LIBRARY BEHAVIOR
.PP
The \f[B]pmemobj_set_funcs\f[]() function allows an application to
override memory allocation calls used internally by \f[B]libpmemobj\f[].
Passing in NULL for any of the handlers will cause the
\f[B]libpmemobj\f[] default function to be used.
The library does not make heavy use of the system malloc functions, but
it does allocate approximately 4\-8 kilobytes for each memory pool in
use.
.PP
By default, \f[B]libpmemobj\f[] supports up to 1024 parallel
transactions/allocations.
For debugging purposes it is possible to decrease this value by setting
the \f[B]PMEMOBJ_NLANES\f[] environment variable to the desired limit.
.SH DEBUGGING AND ERROR HANDLING
.PP
If an error is detected during the call to a \f[B]libpmemobj\f[]
function, the application may retrieve an error message describing the
reason for the failure from \f[B]pmemobj_errormsg\f[]().
This function returns a pointer to a static buffer containing the last
error message logged for the current thread.
If \f[I]errno\f[] was set, the error message may include a description
of the corresponding error code as returned by \f[B]strerror\f[](3).
The error message buffer is thread\-local; errors encountered in one
thread do not affect its value in other threads.
The buffer is never cleared by any library function; its content is
significant only when the return value of the immediately preceding call
to a \f[B]libpmemobj\f[] function indicated an error, or if
\f[I]errno\f[] was set.
The application must not modify or free the error message string, but it
may be modified by subsequent calls to other library functions.
.PP
Two versions of \f[B]libpmemobj\f[] are typically available on a
development system.
The normal version, accessed when a program is linked using the
\f[B]\-lpmemobj\f[] option, is optimized for performance.
That version skips checks that impact performance and never logs any
trace information or performs any run\-time assertions.
.PP
A second version of \f[B]libpmemobj\f[], accessed when a program uses
the libraries under \f[B]/usr/lib/pmdk_debug\f[], contains run\-time
assertions and trace points.
The typical way to access the debug version is to set the environment
variable \f[B]LD_LIBRARY_PATH\f[] to \f[B]/usr/lib/pmdk_debug\f[] or
\f[B]/usr/lib64/pmdk_debug\f[], as appropriate.
Debugging output is controlled using the following environment
variables.
These variables have no effect on the non\-debug version of the library.
.IP \[bu] 2
\f[B]PMEMOBJ_LOG_LEVEL\f[]
.PP
The value of \f[B]PMEMOBJ_LOG_LEVEL\f[] enables trace points in the
debug version of the library, as follows:
.IP \[bu] 2
\f[B]0\f[] \- This is the default level when \f[B]PMEMOBJ_LOG_LEVEL\f[]
is not set.
No log messages are emitted at this level.
.IP \[bu] 2
\f[B]1\f[] \- Additional details on any errors detected are logged, in
addition to returning the \f[I]errno\f[]\-based errors as usual.
The same information may be retrieved using \f[B]pmemobj_errormsg\f[]().
.IP \[bu] 2
\f[B]2\f[] \- A trace of basic operations is logged.
.IP \[bu] 2
\f[B]3\f[] \- Enables a very verbose amount of function call tracing in
the library.
.IP \[bu] 2
\f[B]4\f[] \- Enables voluminous and fairly obscure tracing information
that is likely only useful to the \f[B]libpmemobj\f[] developers.
.PP
Unless \f[B]PMEMOBJ_LOG_FILE\f[] is set, debugging output is written to
\f[I]stderr\f[].
.IP \[bu] 2
\f[B]PMEMOBJ_LOG_FILE\f[]
.PP
Specifies the name of a file where all logging information should be
written.
If the last character in the name is \[lq]\-\[rq], the \f[I]PID\f[] of
the current process will be appended to the file name when the log file
is created.
If \f[B]PMEMOBJ_LOG_FILE\f[] is not set, logging output is written to
\f[I]stderr\f[].
.PP
See also \f[B]libpmem\f[](7) to get information about other environment
variables affecting \f[B]libpmemobj\f[] behavior.
.SH EXAMPLE
.PP
See <http://pmem.io/pmdk/libpmemobj> for examples using the
\f[B]libpmemobj\f[] API.
.SH ACKNOWLEDGEMENTS
.PP
\f[B]libpmemobj\f[] builds on the persistent memory programming model
recommended by the SNIA NVM Programming Technical Work Group:
<http://snia.org/nvmp>
.SH SEE ALSO
.PP
\f[B]OID_IS_NULL\f[](3), \f[B]pmemobj_alloc\f[](3),
\f[B]pmemobj_ctl_exec\f[](3), \f[B]pmemobj_ctl_get\f[](3),
\f[B]pmemobj_ctl_set\f[](3), \f[B]pmemobj_first\f[](3),
\f[B]pmemobj_list_insert\f[](3), \f[B]pmemobj_memcpy_persist\f[](3),
\f[B]pmemobj_mutex_zero\f[](3), \f[B]pmemobj_open\f[](3),
\f[B]pmemobj_root\f[](3), \f[B]pmemobj_tx_add_range\f[](3),
\f[B]pmemobj_tx_alloc\f[](3), \f[B]pmemobj_tx_begin\f[](3),
\f[B]POBJ_LAYOUT_BEGIN\f[](3), \f[B]POBJ_LIST_HEAD\f[](3),
\f[B]strerror\f[](3), \f[B]TOID_DECLARE\f[](3), \f[B]libpmem\f[](7),
\f[B]libpmemblk\f[](7), \f[B]libpmemlog\f[](7), \f[B]libvmem\f[](7) and
\f[B]<http://pmem.io>\f[]