Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/fs/bcachefs/alloc_background_format.h
26288 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
#ifndef _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H
3
#define _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H
4
5
struct bch_alloc {
6
struct bch_val v;
7
__u8 fields;
8
__u8 gen;
9
__u8 data[];
10
} __packed __aligned(8);
11
12
#define BCH_ALLOC_FIELDS_V1() \
13
x(read_time, 16) \
14
x(write_time, 16) \
15
x(data_type, 8) \
16
x(dirty_sectors, 16) \
17
x(cached_sectors, 16) \
18
x(oldest_gen, 8) \
19
x(stripe, 32) \
20
x(stripe_redundancy, 8)
21
22
enum {
23
#define x(name, _bits) BCH_ALLOC_FIELD_V1_##name,
24
BCH_ALLOC_FIELDS_V1()
25
#undef x
26
};
27
28
struct bch_alloc_v2 {
29
struct bch_val v;
30
__u8 nr_fields;
31
__u8 gen;
32
__u8 oldest_gen;
33
__u8 data_type;
34
__u8 data[];
35
} __packed __aligned(8);
36
37
#define BCH_ALLOC_FIELDS_V2() \
38
x(read_time, 64) \
39
x(write_time, 64) \
40
x(dirty_sectors, 32) \
41
x(cached_sectors, 32) \
42
x(stripe, 32) \
43
x(stripe_redundancy, 8)
44
45
struct bch_alloc_v3 {
46
struct bch_val v;
47
__le64 journal_seq;
48
__le32 flags;
49
__u8 nr_fields;
50
__u8 gen;
51
__u8 oldest_gen;
52
__u8 data_type;
53
__u8 data[];
54
} __packed __aligned(8);
55
56
LE32_BITMASK(BCH_ALLOC_V3_NEED_DISCARD,struct bch_alloc_v3, flags, 0, 1)
57
LE32_BITMASK(BCH_ALLOC_V3_NEED_INC_GEN,struct bch_alloc_v3, flags, 1, 2)
58
59
struct bch_alloc_v4 {
60
struct bch_val v;
61
__u64 journal_seq_nonempty;
62
__u32 flags;
63
__u8 gen;
64
__u8 oldest_gen;
65
__u8 data_type;
66
__u8 stripe_redundancy;
67
__u32 dirty_sectors;
68
__u32 cached_sectors;
69
__u64 io_time[2];
70
__u32 stripe;
71
__u32 nr_external_backpointers;
72
/* end of fields in original version of alloc_v4 */
73
__u64 journal_seq_empty;
74
__u32 stripe_sectors;
75
__u32 pad;
76
} __packed __aligned(8);
77
78
#define BCH_ALLOC_V4_U64s_V0 6
79
#define BCH_ALLOC_V4_U64s (sizeof(struct bch_alloc_v4) / sizeof(__u64))
80
81
BITMASK(BCH_ALLOC_V4_NEED_DISCARD, struct bch_alloc_v4, flags, 0, 1)
82
BITMASK(BCH_ALLOC_V4_NEED_INC_GEN, struct bch_alloc_v4, flags, 1, 2)
83
BITMASK(BCH_ALLOC_V4_BACKPOINTERS_START,struct bch_alloc_v4, flags, 2, 8)
84
BITMASK(BCH_ALLOC_V4_NR_BACKPOINTERS, struct bch_alloc_v4, flags, 8, 14)
85
86
#define KEY_TYPE_BUCKET_GENS_BITS 8
87
#define KEY_TYPE_BUCKET_GENS_NR (1U << KEY_TYPE_BUCKET_GENS_BITS)
88
#define KEY_TYPE_BUCKET_GENS_MASK (KEY_TYPE_BUCKET_GENS_NR - 1)
89
90
struct bch_bucket_gens {
91
struct bch_val v;
92
u8 gens[KEY_TYPE_BUCKET_GENS_NR];
93
} __packed __aligned(8);
94
95
#endif /* _BCACHEFS_ALLOC_BACKGROUND_FORMAT_H */
96
97