]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to bf340e68c7 bcachefs: Ignore cached data when calculating...
[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         u8                              gc_gen;
34         unsigned                        gen_valid:1;
35         u8                              stripe_redundancy;
36         u32                             stripe;
37 };
38
39 struct bucket_array {
40         struct rcu_head         rcu;
41         u16                     first_bucket;
42         size_t                  nbuckets;
43         struct bucket           b[];
44 };
45
46 struct bucket_gens {
47         struct rcu_head         rcu;
48         u16                     first_bucket;
49         size_t                  nbuckets;
50         u8                      b[];
51 };
52
53 struct bch_dev_usage {
54         u64                     buckets_ec;
55         u64                     buckets_unavailable;
56
57         struct {
58                 u64             buckets;
59                 u64             sectors; /* _compressed_ sectors: */
60                 /*
61                  * XXX
62                  * Why do we have this? Isn't it just buckets * bucket_size -
63                  * sectors?
64                  */
65                 u64             fragmented;
66         }                       d[BCH_DATA_NR];
67 };
68
69 struct bch_fs_usage {
70         /* all fields are in units of 512 byte sectors: */
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_online {
91         u64                     online_reserved;
92         struct bch_fs_usage     u;
93 };
94
95 struct bch_fs_usage_short {
96         u64                     capacity;
97         u64                     used;
98         u64                     free;
99         u64                     nr_inodes;
100 };
101
102 /*
103  * A reservation for space on disk:
104  */
105 struct disk_reservation {
106         u64                     sectors;
107         u32                     gen;
108         unsigned                nr_replicas;
109 };
110
111 struct copygc_heap_entry {
112         u8                      dev;
113         u8                      gen;
114         u8                      replicas;
115         u16                     fragmentation;
116         u32                     sectors;
117         u64                     offset;
118 };
119
120 typedef HEAP(struct copygc_heap_entry) copygc_heap;
121
122 #endif /* _BUCKETS_TYPES_H */