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