]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/libpmemblk/btt_layout.h
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright 2014-2020, Intel Corporation */
5 * btt_layout.h -- block translation table on-media layout definitions
9 * Layout of BTT info block. All integers are stored little-endian.
13 #define BTT_LAYOUT_H 1
19 #define BTT_ALIGNMENT ((uintptr_t)4096) /* alignment of all BTT structures */
20 #define BTTINFO_SIG_LEN 16
21 #define BTTINFO_UUID_LEN 16
22 #define BTTINFO_UNUSED_LEN 3968
23 #define BTTINFO_SIG "BTT_ARENA_INFO\0"
26 char sig
[BTTINFO_SIG_LEN
]; /* must be "BTT_ARENA_INFO\0\0" */
27 uint8_t uuid
[BTTINFO_UUID_LEN
]; /* BTT UUID */
28 uint8_t parent_uuid
[BTTINFO_UUID_LEN
]; /* UUID of container */
29 uint32_t flags
; /* see flag bits below */
30 uint16_t major
; /* major version */
31 uint16_t minor
; /* minor version */
32 uint32_t external_lbasize
; /* advertised LBA size (bytes) */
33 uint32_t external_nlba
; /* advertised LBAs in this arena */
34 uint32_t internal_lbasize
; /* size of data area blocks (bytes) */
35 uint32_t internal_nlba
; /* number of blocks in data area */
36 uint32_t nfree
; /* number of free blocks */
37 uint32_t infosize
; /* size of this info block */
40 * The following offsets are relative to the beginning of
43 uint64_t nextoff
; /* offset to next arena (or zero) */
44 uint64_t dataoff
; /* offset to arena data area */
45 uint64_t mapoff
; /* offset to area map */
46 uint64_t flogoff
; /* offset to area flog */
47 uint64_t infooff
; /* offset to backup info block */
49 char unused
[BTTINFO_UNUSED_LEN
]; /* must be zero */
51 uint64_t checksum
; /* Fletcher64 of all fields */
55 * Definitions for flags mask for btt_info structure above.
57 #define BTTINFO_FLAG_ERROR 0x00000001 /* error state (read-only) */
58 #define BTTINFO_FLAG_ERROR_MASK 0x00000001 /* all error bits */
61 * Current on-media format versions.
63 #define BTTINFO_MAJOR_VERSION 1
64 #define BTTINFO_MINOR_VERSION 1
67 * Layout of a BTT "flog" entry. All integers are stored little-endian.
69 * The "nfree" field in the BTT info block determines how many of these
70 * flog entries there are, and each entry consists of two of the following
71 * structs (entry updates alternate between the two structs), padded up
72 * to a cache line boundary to isolate adjacent updates.
75 #define BTT_FLOG_PAIR_ALIGN ((uintptr_t)64)
78 uint32_t lba
; /* last pre-map LBA using this entry */
79 uint32_t old_map
; /* old post-map LBA (the freed block) */
80 uint32_t new_map
; /* new post-map LBA */
81 uint32_t seq
; /* sequence number (01, 10, 11) */
85 * Layout of a BTT "map" entry. 4-byte internal LBA offset, little-endian.
87 #define BTT_MAP_ENTRY_SIZE 4
88 #define BTT_MAP_ENTRY_ERROR 0x40000000U
89 #define BTT_MAP_ENTRY_ZERO 0x80000000U
90 #define BTT_MAP_ENTRY_NORMAL 0xC0000000U
91 #define BTT_MAP_ENTRY_LBA_MASK 0x3fffffffU
92 #define BTT_MAP_LOCK_ALIGN ((uintptr_t)64)
95 * BTT layout properties...
97 #define BTT_MIN_SIZE ((1u << 20) * 16)
98 #define BTT_MAX_ARENA (1ull << 39) /* 512GB per arena */
99 #define BTT_MIN_LBA_SIZE (size_t)512
100 #define BTT_INTERNAL_LBA_ALIGNMENT 256U
101 #define BTT_DEFAULT_NFREE 256