]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Merge pull request #211 from oz123/master
[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         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_base {
49         u64                     hidden;
50         u64                     btree;
51         u64                     data;
52         u64                     cached;
53         u64                     reserved;
54         u64                     nr_inodes;
55 };
56
57 struct bch_fs_usage {
58         /* all fields are in units of 512 byte sectors: */
59         struct bch_fs_usage_base b;
60         u64                     persistent_reserved[BCH_REPLICAS_MAX];
61         u64                     replicas[];
62 };
63
64 struct bch_fs_usage_online {
65         u64                     online_reserved;
66         struct bch_fs_usage     u;
67 };
68
69 struct bch_fs_usage_short {
70         u64                     capacity;
71         u64                     used;
72         u64                     free;
73         u64                     nr_inodes;
74 };
75
76 /*
77  * A reservation for space on disk:
78  */
79 struct disk_reservation {
80         u64                     sectors;
81         u32                     gen;
82         unsigned                nr_replicas;
83 };
84
85 #endif /* _BUCKETS_TYPES_H */