]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 02ae70070a bcachefs: Allocate new btree roots lazily
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 #include "util.h"
5
6 struct bucket_mark {
7         union {
8         struct {
9                 u64             counter;
10         };
11
12         struct {
13                 u8              gen;
14                 u8              data_type:3,
15                                 gen_valid:1,
16                                 owned_by_allocator:1,
17                                 nouse:1,
18                                 journal_seq_valid:1;
19                 u16             dirty_sectors;
20                 u16             cached_sectors;
21
22                 /*
23                  * low bits of journal sequence number when this bucket was most
24                  * recently modified: if journal_seq_valid is set, this bucket
25                  * can't be reused until the journal sequence number written to
26                  * disk is >= the bucket's journal sequence number:
27                  */
28                 u16             journal_seq;
29         };
30         };
31 };
32
33 struct bucket {
34         u16                             prio[2];
35
36         union {
37                 struct bucket_mark      _mark;
38                 const struct bucket_mark mark;
39         };
40 };
41
42 struct bucket_array {
43         struct rcu_head         rcu;
44         u16                     first_bucket;
45         size_t                  nbuckets;
46         struct bucket           b[];
47 };
48
49 struct bch_dev_usage {
50         u64                     buckets[BCH_DATA_NR];
51         u64                     buckets_alloc;
52         u64                     buckets_unavailable;
53
54         /* _compressed_ sectors: */
55         u64                     sectors[BCH_DATA_NR];
56 };
57
58 /* kill, switch to bch_data_type? */
59 enum s_alloc {
60         S_META,
61         S_DIRTY,
62         S_ALLOC_NR,
63 };
64
65 struct bch_fs_usage {
66         /* all fields are in units of 512 byte sectors: */
67         /* _uncompressed_ sectors: */
68         u64                     online_reserved;
69         u64                     available_cache;
70
71         struct {
72                 u64             data[S_ALLOC_NR];
73                 u64             persistent_reserved;
74         }                       s[BCH_REPLICAS_MAX];
75 };
76
77 /*
78  * A reservation for space on disk:
79  */
80 struct disk_reservation {
81         u64             sectors;
82         u32             gen;
83         unsigned        nr_replicas;
84 };
85
86 struct copygc_heap_entry {
87         u64                     offset;
88         struct bucket_mark      mark;
89 };
90
91 typedef HEAP(struct copygc_heap_entry) copygc_heap;
92
93 #endif /* _BUCKETS_TYPES_H */