1PMEMLOG_CREATE(3) PMDK Programmer's Manual PMEMLOG_CREATE(3)
2
3
4
6 pmemlog_create(), pmemlog_open(), pmemlog_close(), pmemlog_check() --
7 create, open, close and validate persistent memory resident log file
8
10 #include <libpmemlog.h>
11
12 PMEMlogpool *pmemlog_open(const char *path);
13 PMEMlogpool *pmemlog_create(const char *path, size_t poolsize, mode_t mode);
14 void pmemlog_close(PMEMlogpool *plp);
15 int pmemlog_check(const char *path);
16
18 The pmemlog_create() function creates a log memory pool with the given
19 total poolsize. Since the transactional nature of a log memory pool
20 requires some space overhead in the memory pool, the resulting avail‐
21 able log size is less than poolsize, and is made available to the call‐
22 er via the pmemlog_nbyte(3) function. path specifies the name of the
23 memory pool file to be created. mode specifies the permissions to use
24 when creating the file as described by creat(2). The memory pool file
25 is fully allocated to the size poolsize using posix_fallocate(3). The
26 caller may choose to take responsibility for creating the memory pool
27 file by creating it before calling pmemlog_create() and then specifying
28 poolsize as zero. In this case pmemlog_create() will take the pool
29 size from the size of the existing file and will verify that the file
30 appears to be empty by searching for any non-zero data in the pool
31 header at the beginning of the file. The net pool size of a pool file
32 is equal to the file size. The minimum net pool size allowed by the
33 library for a log pool is defined in <libpmemlog.h> as PMEM‐
34 LOG_MIN_POOL.
35
36 Depending on the configuration of the system, the available
37 non-volatile memory space may be divided into multiple memory devices.
38 In such case, the maximum size of the pmemlog memory pool could be lim‐
39 ited by the capacity of a single memory device. libpmemlog(7) allows
40 building persistent memory resident logs spanning multiple memory de‐
41 vices by creation of persistent memory pools consisting of multiple
42 files, where each part of such a pool set may be stored on a different
43 memory device or pmem-aware filesystem.
44
45 Creation of all the parts of the pool set can be done with pmemlog_cre‐
46 ate(); however, the recommended method for creating pool sets is with
47 the pmempool(1) utility.
48
49 When creating a pool set consisting of multiple files, the path argu‐
50 ment passed to pmemlog_create() must point to the special set file that
51 defines the pool layout and the location of all the parts of the pool
52 set. The poolsize argument must be 0. The meaning of the mode argu‐
53 ment does not change, except that the same mode is used for creation of
54 all the parts of the pool set.
55
56 The set file is a plain text file, the structure of which is described
57 in poolset(5).
58
59 The pmemlog_open() function opens an existing log memory pool. Similar
60 to pmemlog_create(), path must identify either an existing log memory
61 pool file, or the set file used to create a pool set. The application
62 must have permission to open the file and memory map the file or pool
63 set with read/write permissions.
64
65 The pmemlog_close() function closes the memory pool indicated by plp
66 and deletes the memory pool handle. The log memory pool itself lives
67 on in the file that contains it and may be re-opened at a later time
68 using pmemlog_open() as described above.
69
70 The pmemlog_check() function performs a consistency check of the file
71 indicated by path. pmemlog_check() opens the given path read-only so
72 it never makes any changes to the file. This function is not supported
73 on Device DAX.
74
76 On success, pmemlog_create() returns a PMEMlogpool* handle to the memo‐
77 ry pool that is used with most of the functions from libpmemlog(7). If
78 an error prevents any of the pool set files from being created, it re‐
79 turns NULL and sets errno appropriately.
80
81 On success, pmemlog_open() returns a PMEMlogpool* handle to the memory
82 pool that is used with most of the functions from libpmemlog(7). If an
83 error prevents the pool from being opened, or a pool set is being
84 opened and the actual size of any file does not match the corresponding
85 part size defined in the set file, pmemlog_open() returns NULL and sets
86 errno appropriately.
87
88 The pmemlog_close() function returns no value.
89
90 The pmemlog_check() function returns 1 if the persistent memory resi‐
91 dent log file is found to be consistent. Any inconsistencies will
92 cause pmemlog_check() to return 0, in which case the use of the file
93 with libpmemlog will result in undefined behavior. The debug version
94 of libpmemlog will provide additional details on inconsistencies when
95 PMEMLOG_LOG_LEVEL is at least 1, as described in the DEBUGGING AND ER‐
96 ROR HANDLING section in libpmemlog(7). pmemlog_check() will return -1
97 and set errno if it cannot perform the consistency check due to other
98 errors.
99
101 Not all file systems support posix_fallocate(3). pmemlog_create() will
102 fail if the underlying file system does not support posix_fallocate(3).
103
105 pmempool(1), creat(2), posix_fallocate(3), pmemlog_nbyte(3),
106 poolset(5), libpmemlog(7) and <http://pmem.io>
107
108
109
110PMDK - pmemlog API version 1.1 2018-03-13 PMEMLOG_CREATE(3)