]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to b84661c042 bcachefs: Fix reflink repair code
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BUCKETS_TYPES_H
3 #define _BUCKETS_TYPES_H
4
5 #include "bcachefs_format.h"
6 #include "util.h"
7
8 #define BUCKET_JOURNAL_SEQ_BITS         16
9
10 struct bucket_mark {
11         union {
12         atomic64_t      v;
13
14         struct {
15         u8              gen;
16         u8              data_type:3,
17                         owned_by_allocator:1,
18                         stripe:1;
19         u16             dirty_sectors;
20         u16             cached_sectors;
21         };
22         };
23 };
24
25 struct bucket {
26         union {
27                 struct bucket_mark      _mark;
28                 const struct bucket_mark mark;
29         };
30
31         u64                             io_time[2];
32         u8                              oldest_gen;
33         unsigned                        gen_valid:1;
34         u8                              stripe_redundancy;
35         u32                             stripe;
36 };
37
38 struct bucket_array {
39         struct rcu_head         rcu;
40         u16                     first_bucket;
41         size_t                  nbuckets;
42         struct bucket           b[];
43 };
44
45 struct bucket_gens {
46         struct rcu_head         rcu;
47         u16                     first_bucket;
48         size_t                  nbuckets;
49         u8                      b[];
50 };
51
52 struct bch_dev_usage {
53         u64                     buckets_ec;
54         u64                     buckets_unavailable;
55
56         struct {
57                 u64             buckets;
58                 u64             sectors; /* _compressed_ sectors: */
59                 /*
60                  * XXX
61                  * Why do we have this? Isn't it just buckets * bucket_size -
62                  * sectors?
63                  */
64                 u64             fragmented;
65         }                       d[BCH_DATA_NR];
66 };
67
68 struct bch_fs_usage {
69         /* all fields are in units of 512 byte sectors: */
70         u64                     hidden;
71         u64                     btree;
72         u64                     data;
73         u64                     cached;
74         u64                     reserved;
75         u64                     nr_inodes;
76
77         /* XXX: add stats for compression ratio */
78 #if 0
79         u64                     uncompressed;
80         u64                     compressed;
81 #endif
82
83         /* broken out: */
84
85         u64                     persistent_reserved[BCH_REPLICAS_MAX];
86         u64                     replicas[];
87 };
88
89 struct bch_fs_usage_online {
90         u64                     online_reserved;
91         struct bch_fs_usage     u;
92 };
93
94 struct bch_fs_usage_short {
95         u64                     capacity;
96         u64                     used;
97         u64                     free;
98         u64                     nr_inodes;
99 };
100
101 /*
102  * A reservation for space on disk:
103  */
104 struct disk_reservation {
105         u64                     sectors;
106         u32                     gen;
107         unsigned                nr_replicas;
108 };
109
110 struct copygc_heap_entry {
111         u8                      dev;
112         u8                      gen;
113         u8                      replicas;
114         u16                     fragmentation;
115         u32                     sectors;
116         u64                     offset;
117 };
118
119 typedef HEAP(struct copygc_heap_entry) copygc_heap;
120
121 #endif /* _BUCKETS_TYPES_H */