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