1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright 2014-2020, Intel Corporation */
5 * log.h -- internal definitions for libpmem log module
17 #include "os_thread.h"
19 #include "page_size.h"
26 #include "fault_injection.h"
28 #define PMEMLOG_LOG_PREFIX "libpmemlog"
29 #define PMEMLOG_LOG_LEVEL_VAR "PMEMLOG_LOG_LEVEL"
30 #define PMEMLOG_LOG_FILE_VAR "PMEMLOG_LOG_FILE"
32 /* attributes of the log memory pool format for the pool header */
33 #define LOG_HDR_SIG "PMEMLOG" /* must be 8 bytes including '\0' */
34 #define LOG_FORMAT_MAJOR 1
36 #define LOG_FORMAT_FEAT_DEFAULT \
37 {POOL_FEAT_COMPAT_DEFAULT, POOL_FEAT_INCOMPAT_DEFAULT, 0x0000}
39 #define LOG_FORMAT_FEAT_CHECK \
40 {POOL_FEAT_COMPAT_VALID, POOL_FEAT_INCOMPAT_VALID, 0x0000}
42 static const features_t log_format_feat_default
= LOG_FORMAT_FEAT_DEFAULT
;
45 struct pool_hdr hdr
; /* memory pool header */
47 /* root info for on-media format... */
48 uint64_t start_offset
; /* start offset of the usable log space */
49 uint64_t end_offset
; /* maximum offset of the usable log space */
50 uint64_t write_offset
; /* current write point for the log */
52 /* some run-time state, allocated out of memory pool... */
53 void *addr
; /* mapped region */
54 size_t size
; /* size of mapped region */
55 int is_pmem
; /* true if pool is PMEM */
56 int rdonly
; /* true if pool is opened read-only */
57 os_rwlock_t
*rwlockp
; /* pointer to RW lock */
58 int is_dev_dax
; /* true if mapped on device dax */
59 struct ctl
*ctl
; /* top level node of the ctl tree structure */
61 struct pool_set
*set
; /* pool set info */
64 /* data area starts at this alignment after the struct pmemlog above */
65 #define LOG_FORMAT_DATA_ALIGN ((uintptr_t)PMEM_PAGESIZE)
68 * log_convert2h -- convert pmemlog structure to host byte order
71 log_convert2h(struct pmemlog
*plp
)
73 plp
->start_offset
= le64toh(plp
->start_offset
);
74 plp
->end_offset
= le64toh(plp
->end_offset
);
75 plp
->write_offset
= le64toh(plp
->write_offset
);
79 * log_convert2le -- convert pmemlog structure to LE byte order
82 log_convert2le(struct pmemlog
*plp
)
84 plp
->start_offset
= htole64(plp
->start_offset
);
85 plp
->end_offset
= htole64(plp
->end_offset
);
86 plp
->write_offset
= htole64(plp
->write_offset
);
91 pmemlog_inject_fault_at(enum pmem_allocation_type type
, int nth
,
95 pmemlog_fault_injection_enabled(void);
98 pmemlog_inject_fault_at(enum pmem_allocation_type type
, int nth
,
105 pmemlog_fault_injection_enabled(void)