]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 6f603b8d79 bcachefs: some improvements to startup messages...
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 #include "bcachefs_format.h"
5 #include "util.h"
6
7 #define BUCKET_JOURNAL_SEQ_BITS         16
8
9 struct bucket_mark {
10         union {
11         atomic64_t      v;
12
13         struct {
14         u8              gen;
15         u8              data_type:3,
16                         owned_by_allocator:1,
17                         dirty:1,
18                         journal_seq_valid:1,
19                         stripe:1;
20         u16             dirty_sectors;
21         u16             cached_sectors;
22
23         /*
24          * low bits of journal sequence number when this bucket was most
25          * recently modified: if journal_seq_valid is set, this bucket can't be
26          * reused until the journal sequence number written to disk is >= the
27          * bucket's journal sequence number:
28          */
29         u16             journal_seq;
30         };
31         };
32 };
33
34 struct bucket {
35         union {
36                 struct bucket_mark      _mark;
37                 const struct bucket_mark mark;
38         };
39
40         u16                             io_time[2];
41         u8                              oldest_gen;
42         unsigned                        gen_valid:1;
43 };
44
45 struct bucket_array {
46         struct rcu_head         rcu;
47         u16                     first_bucket;
48         size_t                  nbuckets;
49         struct bucket           b[];
50 };
51
52 struct bch_dev_usage {
53         u64                     buckets[BCH_DATA_NR];
54         u64                     buckets_alloc;
55         u64                     buckets_ec;
56         u64                     buckets_unavailable;
57
58         /* _compressed_ sectors: */
59         u64                     sectors[BCH_DATA_NR];
60         u64                     sectors_fragmented;
61 };
62
63 struct bch_fs_usage {
64         /* all fields are in units of 512 byte sectors: */
65
66         u64                     online_reserved;
67
68         /* fields after online_reserved are cleared/recalculated by gc: */
69         u64                     gc_start[0];
70
71         u64                     hidden;
72         u64                     btree;
73         u64                     data;
74         u64                     cached;
75         u64                     reserved;
76         u64                     nr_inodes;
77
78         /* XXX: add stats for compression ratio */
79 #if 0
80         u64                     uncompressed;
81         u64                     compressed;
82 #endif
83
84         /* broken out: */
85
86         u64                     persistent_reserved[BCH_REPLICAS_MAX];
87         u64                     replicas[];
88 };
89
90 struct bch_fs_usage_short {
91         u64                     capacity;
92         u64                     used;
93         u64                     free;
94         u64                     nr_inodes;
95 };
96
97 struct replicas_delta {
98         s64                     delta;
99         struct bch_replicas_entry r;
100 };
101
102 struct replicas_delta_list {
103         struct bch_fs_usage     fs_usage;
104
105         struct replicas_delta   *top;
106         struct replicas_delta   d[0];
107         u8                      pad[256];
108 };
109
110 /*
111  * A reservation for space on disk:
112  */
113 struct disk_reservation {
114         u64                     sectors;
115         u32                     gen;
116         unsigned                nr_replicas;
117 };
118
119 struct copygc_heap_entry {
120         u8                      gen;
121         u32                     sectors;
122         u64                     offset;
123 };
124
125 typedef HEAP(struct copygc_heap_entry) copygc_heap;
126
127 #endif /* _BUCKETS_TYPES_H */