]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 3610542890 bcachefs: Convert to skcipher interface for...
[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         u16                             prio[2];
54
55         union {
56                 struct bucket_mark      _mark;
57                 const struct bucket_mark mark;
58         };
59 };
60
61 enum s_compressed {
62         S_COMPRESSED,
63         S_UNCOMPRESSED,
64         S_COMPRESSED_NR,
65 };
66
67 enum s_alloc {
68         S_META,
69         S_DIRTY,
70         S_CACHED,
71         S_ALLOC_NR,
72 };
73
74 struct bch_dev_usage {
75         u64                     buckets_dirty;
76         u64                     buckets_cached;
77         u64                     buckets_meta;
78         u64                     buckets_alloc;
79
80         u64                     sectors[S_ALLOC_NR];
81 };
82
83 struct bch_fs_usage {
84         /* all fields are in units of 512 byte sectors: */
85         u64                     s[S_COMPRESSED_NR][S_ALLOC_NR];
86         u64                     persistent_reserved;
87         u64                     online_reserved;
88         u64                     available_cache;
89 };
90
91 struct bucket_heap_entry {
92         size_t                  bucket;
93         struct bucket_mark      mark;
94 };
95
96 typedef HEAP(struct bucket_heap_entry) bucket_heap;
97
98 /*
99  * A reservation for space on disk:
100  */
101 struct disk_reservation {
102         u64             sectors;
103         u32             gen;
104         unsigned        nr_replicas;
105 };
106
107 #endif /* _BUCKETS_TYPES_H */