]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
btree_write_buffer: ensure atomic64_sub_return_release availability
[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 {
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         u64                     buckets_ec;
37
38         struct {
39                 u64             buckets;
40                 u64             sectors; /* _compressed_ sectors: */
41                 /*
42                  * XXX
43                  * Why do we have this? Isn't it just buckets * bucket_size -
44                  * sectors?
45                  */
46                 u64             fragmented;
47         }                       d[BCH_DATA_NR];
48 };
49
50 struct bch_fs_usage {
51         /* all fields are in units of 512 byte sectors: */
52         u64                     hidden;
53         u64                     btree;
54         u64                     data;
55         u64                     cached;
56         u64                     reserved;
57         u64                     nr_inodes;
58
59         /* XXX: add stats for compression ratio */
60 #if 0
61         u64                     uncompressed;
62         u64                     compressed;
63 #endif
64
65         /* broken out: */
66
67         u64                     persistent_reserved[BCH_REPLICAS_MAX];
68         u64                     replicas[];
69 };
70
71 struct bch_fs_usage_online {
72         u64                     online_reserved;
73         struct bch_fs_usage     u;
74 };
75
76 struct bch_fs_usage_short {
77         u64                     capacity;
78         u64                     used;
79         u64                     free;
80         u64                     nr_inodes;
81 };
82
83 /*
84  * A reservation for space on disk:
85  */
86 struct disk_reservation {
87         u64                     sectors;
88         u32                     gen;
89         unsigned                nr_replicas;
90 };
91
92 #endif /* _BUCKETS_TYPES_H */