]> git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/common/util_pmem.h
import ceph 16.2.7
[ceph.git] / ceph / src / pmdk / src / common / util_pmem.h
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright 2017-2020, Intel Corporation */
3
4 /*
5 * util_pmem.h -- internal definitions for pmem utils
6 */
7
8 #ifndef PMDK_UTIL_PMEM_H
9 #define PMDK_UTIL_PMEM_H 1
10
11 #include "libpmem.h"
12 #include "out.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /*
19 * util_persist -- flush to persistence
20 */
21 static inline void
22 util_persist(int is_pmem, const void *addr, size_t len)
23 {
24 LOG(3, "is_pmem %d, addr %p, len %zu", is_pmem, addr, len);
25
26 if (is_pmem)
27 pmem_persist(addr, len);
28 else if (pmem_msync(addr, len))
29 FATAL("!pmem_msync");
30 }
31
32 /*
33 * util_persist_auto -- flush to persistence
34 */
35 static inline void
36 util_persist_auto(int is_pmem, const void *addr, size_t len)
37 {
38 LOG(3, "is_pmem %d, addr %p, len %zu", is_pmem, addr, len);
39
40 util_persist(is_pmem || pmem_is_pmem(addr, len), addr, len);
41 }
42
43 #ifdef __cplusplus
44 }
45 #endif
46
47 #endif /* util_pmem.h */