Repository navigation
Expand file tree
/
Copy pathdrbd_meta_data.h
More file actions
170 lines (141 loc) · 4.87 KB
/
Copy pathdrbd_meta_data.h
File metadata and controls
170 lines (141 loc) · 4.87 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef DRBD_META_DATA_H
#define DRBD_META_DATA_H
#ifdef __KERNEL__
#define be_u64 __be64
#define be_s64 __be64
#define be_u32 __be32
#define be_s32 __be32
#define be_u16 __be16
#else
#define be_u64 struct { uint64_t be; }
#define be_s64 struct { int64_t be; }
#define be_u32 struct { uint32_t be; }
#define be_s32 struct { int32_t be; }
#define be_u16 struct { uint16_t be; }
#endif
/* how I came up with this magic?
* base64 decode "actlog==" ;)
*/
#define DRBD_AL_MAGIC 0x69cb65a2
#define BM_BLOCK_SHIFT_4k 12 /* 4k per bit */
#define BM_BLOCK_SHIFT_MIN BM_BLOCK_SHIFT_4k
#define BM_BLOCK_SHIFT_MAX 20
#define BM_BLOCK_SIZE_4k 4096
#define BM_BLOCK_SIZE_MIN (1<<BM_BLOCK_SHIFT_MIN)
#define BM_BLOCK_SIZE_MAX (1<<BM_BLOCK_SHIFT_MAX)
struct peer_dev_md_on_disk_9 {
be_u64 bitmap_uuid;
be_u64 bitmap_dagtag;
be_u32 flags;
be_s32 bitmap_index;
be_u32 reserved_u32[2];
} __packed;
/* Changed block tracking: one bitmap slot, not owned by a peer, records every
* write to the backing device since the bookmark "id". Valid only with
* DRBD_MDFF_CBT in the features.
*/
struct cbt_bookmark_on_disk_9 {
be_u64 id; /* the slot records changes since this bookmark */
be_u64 bitmap_uuid; /* current UUID at cbt-start */
be_u64 bitmap_dagtag; /* the Primary's dagtag at cbt-start */
be_s64 since; /* time of cbt-start, seconds since the epoch */
be_u32 flags; /* CBT_BOOKMARK_* */
be_s32 bitmap_index;
} __packed;
struct meta_data_on_disk_9 {
be_u64 effective_size; /* last agreed size */
be_u64 current_uuid;
be_u64 members; /* only if MDF_HAVE_MEMBERS_MASK is in the flags */
/* Feature flags. Values prefixed with "DRBD_MDFF".
* Separate from "flags": Unknown features bits are cleared; unknown flags bits are kept.
*/
be_u64 features;
be_u64 reserved_u64[2]; /* to have the magic at the same position as in v07, and v08 */
be_u64 device_uuid;
be_u32 flags; /* MDF */
be_u32 magic;
be_u32 md_size_sect;
be_u32 al_offset; /* offset to this block */
be_u32 al_nr_extents; /* important for restoring the AL */
be_u32 bm_offset; /* offset to the bitmap, from here */
be_u32 bm_bytes_per_bit; /* BM_BLOCK_SIZE */
be_u32 la_peer_max_bio_size; /* last peer max_bio_size */
be_u32 bm_max_peers;
be_s32 node_id;
/* see al_tr_number_to_on_disk_sector() */
be_u32 al_stripes;
be_u32 al_stripe_size_4k;
be_u32 reserved_u32[2];
struct peer_dev_md_on_disk_9 peers[DRBD_PEERS_MAX];
be_u64 history_uuids[HISTORY_UUIDS];
struct cbt_bookmark_on_disk_9 cbt_bookmark;
unsigned char padding_start[0];
unsigned char padding_end[0] __attribute__((aligned(4096)));
} __packed;
/* Attention, these two are defined in drbd_int.h as well! */
#define AL_UPDATES_PER_TRANSACTION 64
#define AL_CONTEXT_PER_TRANSACTION 919
enum al_transaction_types {
AL_TR_UPDATE = 0,
AL_TR_INITIALIZED = 0xffff
};
/* all fields on disc in big endian */
struct __packed al_transaction_on_disk {
/* don't we all like magic */
be_u32 magic;
/* to identify the most recent transaction block
* in the on disk ring buffer
*/
be_u32 tr_number;
/* checksum on the full 4k block, with this field set to 0. */
be_u32 crc32c;
/* type of transaction, special transaction types like:
* purge-all, set-all-idle, set-all-active, ... to-be-defined
* see also enum al_transaction_types
*/
be_u16 transaction_type;
/* we currently allow only a few thousand extents,
* so 16bit will be enough for the slot number.
*/
/* how many updates in this transaction */
be_u16 n_updates;
/* maximum slot number, "al-extents" in drbd.conf speak.
* Having this in each transaction should make reconfiguration
* of that parameter easier.
*/
be_u16 context_size;
/* slot number the context starts with */
be_u16 context_start_slot_nr;
/* Some reserved bytes. Expected usage is a 64bit counter of
* sectors-written since device creation, and other data generation tag
* supporting usage
*/
be_u32 __reserved[4];
/* --- 36 byte used --- */
/* Reserve space for up to AL_UPDATES_PER_TRANSACTION changes
* in one transaction, then use the remaining byte in the 4k block for
* context information. "Flexible" number of updates per transaction
* does not help, as we have to account for the case when all update
* slots are used anyways, so it would only complicate code without
* additional benefit.
*/
be_u16 update_slot_nr[AL_UPDATES_PER_TRANSACTION];
/* but the extent number is 32bit, which at an extent size of 4 MiB
* allows to cover device sizes of up to 2**54 Byte (16 PiB)
*/
be_u32 update_extent_nr[AL_UPDATES_PER_TRANSACTION];
/* --- 420 bytes used (36 + 64*6) --- */
/* 4096 - 420 = 3676 = 919 * 4 */
be_u32 context[AL_CONTEXT_PER_TRANSACTION];
};
#define DRBD_AL_PMEM_MAGIC 0x6aa667a6 /* "al==pmem" */
struct __packed al_on_pmem {
be_u32 magic;
be_u32 slots[];
};
#undef be_u64
#undef be_u32
#undef be_s32
#undef be_u16
#endif