]> git.sesse.net Git - bcachefs-tools-debian/blob - c_src/libbcachefs/buckets_types.h
move Rust sources to top level, C sources into c_src
[bcachefs-tools-debian] / c_src / 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 {
11         u8                      lock;
12         u8                      gen_valid:1;
13         u8                      data_type:7;
14         u8                      gen;
15         u8                      stripe_redundancy;
16         u32                     stripe;
17         u32                     dirty_sectors;
18         u32                     cached_sectors;
19 };
20
21 struct bucket_array {
22         struct rcu_head         rcu;
23         u16                     first_bucket;
24         size_t                  nbuckets;
25         struct bucket           b[];
26 };
27
28 struct bucket_gens {
29         struct rcu_head         rcu;
30         u16                     first_bucket;
31         size_t                  nbuckets;
32         u8                      b[];
33 };
34
35 struct bch_dev_usage {
36         struct {
37                 u64             buckets;
38                 u64             sectors; /* _compressed_ sectors: */
39                 /*
40                  * XXX
41                  * Why do we have this? Isn't it just buckets * bucket_size -
42                  * sectors?
43                  */
44                 u64             fragmented;
45         }                       d[BCH_DATA_NR];
46 };
47
48 struct bch_fs_usage {
49         /* all fields are in units of 512 byte sectors: */
50         u64                     hidden;
51         u64                     btree;
52         u64                     data;
53         u64                     cached;
54         u64                     reserved;
55         u64                     nr_inodes;
56
57         /* XXX: add stats for compression ratio */
58 #if 0
59         u64                     uncompressed;
60         u64                     compressed;
61 #endif
62
63         /* broken out: */
64
65         u64                     persistent_reserved[BCH_REPLICAS_MAX];
66         u64                     replicas[];
67 };
68
69 struct bch_fs_usage_online {
70         u64                     online_reserved;
71         struct bch_fs_usage     u;
72 };
73
74 struct bch_fs_usage_short {
75         u64                     capacity;
76         u64                     used;
77         u64                     free;
78         u64                     nr_inodes;
79 };
80
81 /*
82  * A reservation for space on disk:
83  */
84 struct disk_reservation {
85         u64                     sectors;
86         u32                     gen;
87         unsigned                nr_replicas;
88 };
89
90 #endif /* _BUCKETS_TYPES_H */