]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 2e70771b8d
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 #include "util.h"
5
6 enum bucket_data_type {
7         BUCKET_DATA     = 0,
8         BUCKET_BTREE,
9         BUCKET_PRIOS,
10         BUCKET_JOURNAL,
11         BUCKET_SB,
12 };
13
14 struct bucket_mark {
15         union {
16         struct {
17                 u64             counter;
18         };
19
20         struct {
21                 u8              gen;
22
23                 unsigned        journal_seq_valid:1;
24
25                 /*
26                  * If this bucket had metadata while at the current generation
27                  * number, the allocator must increment its gen before we reuse
28                  * it:
29                  */
30                 unsigned        had_metadata:1;
31
32                 unsigned        owned_by_allocator:1;
33
34                 unsigned        data_type:3;
35
36                 unsigned        nouse:1;
37
38                 u16             dirty_sectors;
39                 u16             cached_sectors;
40
41                 /*
42                  * low bits of journal sequence number when this bucket was most
43                  * recently modified: if journal_seq_valid is set, this bucket
44                  * can't be reused until the journal sequence number written to
45                  * disk is >= the bucket's journal sequence number:
46                  */
47                 u16             journal_seq;
48         };
49         };
50 };
51
52 struct bucket {
53         union {
54                 struct {
55                         u16     read_prio;
56                         u16     write_prio;
57                 };
58                 u16             prio[2];
59         };
60
61         union {
62                 struct bucket_mark      _mark;
63                 const struct bucket_mark mark;
64         };
65 };
66
67 enum s_compressed {
68         S_COMPRESSED,
69         S_UNCOMPRESSED,
70         S_COMPRESSED_NR,
71 };
72
73 enum s_alloc {
74         S_META,
75         S_DIRTY,
76         S_CACHED,
77         S_ALLOC_NR,
78 };
79
80 struct bch_dev_usage {
81         u64                     buckets_dirty;
82         u64                     buckets_cached;
83         u64                     buckets_meta;
84         u64                     buckets_alloc;
85
86         u64                     sectors[S_ALLOC_NR];
87 };
88
89 struct bch_fs_usage {
90         /* all fields are in units of 512 byte sectors: */
91         u64                     s[S_COMPRESSED_NR][S_ALLOC_NR];
92         u64                     persistent_reserved;
93         u64                     online_reserved;
94         u64                     available_cache;
95 };
96
97 struct bucket_heap_entry {
98         size_t                  bucket;
99         struct bucket_mark      mark;
100 };
101
102 typedef HEAP(struct bucket_heap_entry) bucket_heap;
103
104 /*
105  * A reservation for space on disk:
106  */
107 struct disk_reservation {
108         u64             sectors;
109         u32             gen;
110         unsigned        nr_replicas;
111 };
112
113 #endif /* _BUCKETS_TYPES_H */