.\" Automatically generated by Pandoc 2.0.6 .\" .TH "PMEMLOG_CREATE" "3" "2022-08-25" "PMDK - pmemlog API version 1.1" "PMDK Programmer's Manual" .hy .\" SPDX-License-Identifier: BSD-3-Clause .\" Copyright 2017-2018, Intel Corporation .SH NAME .PP \f[B]pmemlog_create\f[](), \f[B]pmemlog_open\f[](), \f[B]pmemlog_close\f[](), \f[B]pmemlog_check\f[]() \- create, open, close and validate persistent memory resident log file .SH SYNOPSIS .IP .nf \f[C] #include\ PMEMlogpool\ *pmemlog_open(const\ char\ *path); PMEMlogpool\ *pmemlog_create(const\ char\ *path,\ size_t\ poolsize,\ mode_t\ mode); void\ pmemlog_close(PMEMlogpool\ *plp); int\ pmemlog_check(const\ char\ *path); \f[] .fi .SH DESCRIPTION .PP The \f[B]pmemlog_create\f[]() function creates a log memory pool with the given total \f[I]poolsize\f[]. Since the transactional nature of a log memory pool requires some space overhead in the memory pool, the resulting available log size is less than \f[I]poolsize\f[], and is made available to the caller via the \f[B]pmemlog_nbyte\f[](3) function. \f[I]path\f[] specifies the name of the memory pool file to be created. \f[I]mode\f[] specifies the permissions to use when creating the file as described by \f[B]creat\f[](2). The memory pool file is fully allocated to the size \f[I]poolsize\f[] using \f[B]posix_fallocate\f[](3). The caller may choose to take responsibility for creating the memory pool file by creating it before calling \f[B]pmemlog_create\f[]() and then specifying \f[I]poolsize\f[] as zero. In this case \f[B]pmemlog_create\f[]() will take the pool size from the size of the existing file and will verify that the file appears to be empty by searching for any non\-zero data in the pool header at the beginning of the file. The net pool size of a pool file is equal to the file size. The minimum net pool size allowed by the library for a log pool is defined in \f[B]\f[] as \f[B]PMEMLOG_MIN_POOL\f[]. .PP Depending on the configuration of the system, the available non\-volatile memory space may be divided into multiple memory devices. In such case, the maximum size of the pmemlog memory pool could be limited by the capacity of a single memory device. \f[B]libpmemlog\f[](7) allows building persistent memory resident logs spanning multiple memory devices by creation of persistent memory pools consisting of multiple files, where each part of such a \f[I]pool set\f[] may be stored on a different memory device or pmem\-aware filesystem. .PP Creation of all the parts of the pool set can be done with \f[B]pmemlog_create\f[](); however, the recommended method for creating pool sets is with the \f[B]pmempool\f[](1) utility. .PP When creating a pool set consisting of multiple files, the \f[I]path\f[] argument passed to \f[B]pmemlog_create\f[]() must point to the special \f[I]set\f[] file that defines the pool layout and the location of all the parts of the pool set. The \f[I]poolsize\f[] argument must be 0. The meaning of the \f[I]mode\f[] argument does not change, except that the same \f[I]mode\f[] is used for creation of all the parts of the pool set. .PP The set file is a plain text file, the structure of which is described in \f[B]poolset\f[](5). .PP The \f[B]pmemlog_open\f[]() function opens an existing log memory pool. Similar to \f[B]pmemlog_create\f[](), \f[I]path\f[] must identify either an existing log memory pool file, or the \f[I]set\f[] file used to create a pool set. The application must have permission to open the file and memory map the file or pool set with read/write permissions. .PP Be aware that if the pool contains bad blocks inside, opening can be aborted by the SIGBUS signal, because currently the pool is not checked against bad blocks during opening. It can be turned on by setting the CHECK_BAD_BLOCKS compat feature. For details see description of this feature in \f[B]pmempool\-feature\f[](1). .PP The \f[B]pmemlog_close\f[]() function closes the memory pool indicated by \f[I]plp\f[] and deletes the memory pool handle. The log memory pool itself lives on in the file that contains it and may be re\-opened at a later time using \f[B]pmemlog_open\f[]() as described above. .PP The \f[B]pmemlog_check\f[]() function performs a consistency check of the file indicated by \f[I]path\f[]. \f[B]pmemlog_check\f[]() opens the given \f[I]path\f[] read\-only so it never makes any changes to the file. This function is not supported on Device DAX. .SH RETURN VALUE .PP On success, \f[B]pmemlog_create\f[]() returns a \f[I]PMEMlogpool*\f[] handle to the memory pool that is used with most of the functions from \f[B]libpmemlog\f[](7). If an error prevents any of the pool set files from being created, it returns NULL and sets \f[I]errno\f[] appropriately. .PP On success, \f[B]pmemlog_open\f[]() returns a \f[I]PMEMlogpool*\f[] handle to the memory pool that is used with most of the functions from \f[B]libpmemlog\f[](7). If an error prevents the pool from being opened, or a pool set is being opened and the actual size of any file does not match the corresponding part size defined in the \f[I]set\f[] file, \f[B]pmemlog_open\f[]() returns NULL and sets \f[I]errno\f[] appropriately. .PP The \f[B]pmemlog_close\f[]() function returns no value. .PP The \f[B]pmemlog_check\f[]() function returns 1 if the persistent memory resident log file is found to be consistent. Any inconsistencies will cause \f[B]pmemlog_check\f[]() to return 0, in which case the use of the file with \f[B]libpmemlog\f[] will result in undefined behavior. The debug version of \f[B]libpmemlog\f[] will provide additional details on inconsistencies when \f[B]PMEMLOG_LOG_LEVEL\f[] is at least 1, as described in the \f[B]DEBUGGING AND ERROR HANDLING\f[] section in \f[B]libpmemlog\f[](7). \f[B]pmemlog_check\f[]() will return \-1 and set \f[I]errno\f[] if it cannot perform the consistency check due to other errors. .SH CAVEATS .PP Not all file systems support \f[B]posix_fallocate\f[](3). \f[B]pmemlog_create\f[]() will fail if the underlying file system does not support \f[B]posix_fallocate\f[](3). .SH SEE ALSO .PP \f[B]pmempool\f[](1), \f[B]creat\f[](2), \f[B]posix_fallocate\f[](3), \f[B]pmemlog_nbyte\f[](3), \f[B]poolset\f[](5), \f[B]libpmemlog\f[](7) and \f[B]\f[]