1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <sys/stat.h>
#include "journal-def.h"
typedef struct MMapCache MMapCache;
typedef struct MMapFileDescriptor MMapFileDescriptor;
typedef enum MMapCacheCategory {
MMAP_CACHE_CATEGORY_ANY = OBJECT_UNUSED,
MMAP_CACHE_CATEGORY_DATA = OBJECT_DATA,
MMAP_CACHE_CATEGORY_FIELD = OBJECT_FIELD,
MMAP_CACHE_CATEGORY_ENTRY = OBJECT_ENTRY,
MMAP_CACHE_CATEGORY_DATA_HASH_TABLE = OBJECT_DATA_HASH_TABLE,
MMAP_CACHE_CATEGORY_FIELD_HASH_TABLE = OBJECT_FIELD_HASH_TABLE,
MMAP_CACHE_CATEGORY_ENTRY_ARRAY = OBJECT_ENTRY_ARRAY,
MMAP_CACHE_CATEGORY_TAG = OBJECT_TAG,
MMAP_CACHE_CATEGORY_HEADER, /* for reading file header */
MMAP_CACHE_CATEGORY_PIN, /* for temporary pinning a object */
_MMAP_CACHE_CATEGORY_MAX,
_MMAP_CACHE_CATEGORY_INVALID = -EINVAL,
} MMapCacheCategory;
assert_cc((int) _OBJECT_TYPE_MAX < (int) _MMAP_CACHE_CATEGORY_MAX);
static inline MMapCacheCategory type_to_category(ObjectType type) {
return type >= 0 && type < _OBJECT_TYPE_MAX ? (MMapCacheCategory) type : MMAP_CACHE_CATEGORY_ANY;
}
MMapCache* mmap_cache_new(void);
MMapCache* mmap_cache_ref(MMapCache *m);
MMapCache* mmap_cache_unref(MMapCache *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(MMapCache*, mmap_cache_unref);
int mmap_cache_fd_get(
MMapFileDescriptor *f,
MMapCacheCategory c,
bool keep_always,
uint64_t offset,
size_t size,
struct stat *st,
void **ret);
int mmap_cache_fd_pin(
MMapFileDescriptor *f,
MMapCacheCategory c,
void *addr,
size_t size);
int mmap_cache_add_fd(MMapCache *m, int fd, int prot, MMapFileDescriptor **ret);
MMapCache* mmap_cache_fd_cache(MMapFileDescriptor *f);
MMapFileDescriptor* mmap_cache_fd_free(MMapFileDescriptor *f);
void mmap_cache_stats_log_debug(MMapCache *m);
bool mmap_cache_fd_got_sigbus(MMapFileDescriptor *f);
|