]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to f7670cba39 bcachefs: Fix for building in userspace
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 #include "bcachefs_format.h"
5 #include "util.h"
6
7 #define BUCKET_JOURNAL_SEQ_BITS         16
8
9 struct bucket_mark {
10         union {
11         atomic64_t      v;
12
13         struct {
14         u8              gen;
15         u8              data_type:3,
16                         owned_by_allocator:1,
17                         dirty:1,
18                         journal_seq_valid:1,
19                         stripe:1;
20         u16             dirty_sectors;
21         u16             cached_sectors;
22
23         /*
24          * low bits of journal sequence number when this bucket was most
25          * recently modified: if journal_seq_valid is set, this bucket can't be
26          * reused until the journal sequence number written to disk is >= the
27          * bucket's journal sequence number:
28          */
29         u16             journal_seq;
30         };
31         };
32 };
33
34 struct bucket {
35         union {
36                 struct bucket_mark      _mark;
37                 const struct bucket_mark mark;
38         };
39
40         u16                             io_time[2];
41         unsigned                        gen_valid:1;
42 };
43
44 struct bucket_array {
45         struct rcu_head         rcu;
46         u16                     first_bucket;
47         size_t                  nbuckets;
48         struct bucket           b[];
49 };
50
51 struct bch_dev_usage {
52         u64                     buckets[BCH_DATA_NR];
53         u64                     buckets_alloc;
54         u64                     buckets_ec;
55         u64                     buckets_unavailable;
56
57         /* _compressed_ sectors: */
58         u64                     sectors[BCH_DATA_NR];
59         u64                     sectors_fragmented;
60 };
61
62 struct bch_fs_usage {
63         /* all fields are in units of 512 byte sectors: */
64
65         /* summarized: */
66         struct bch_fs_usage_summarized {
67                 u64             online_reserved;
68
69                 /* fields after online_reserved are cleared/recalculated by gc: */
70                 u64             gc_start[0];
71
72                 u64             hidden;
73                 u64             data;
74                 u64             cached;
75                 u64             reserved;
76                 u64             nr_inodes;
77         } s;
78
79         /* broken out: */
80         struct {
81                 u64             data[BCH_DATA_NR];
82                 u64             ec_data;
83                 u64             persistent_reserved;
84         }                       replicas[BCH_REPLICAS_MAX];
85
86         u64                     buckets[BCH_DATA_NR];
87 };
88
89 struct bch_fs_usage_short {
90         u64                     capacity;
91         u64                     used;
92         u64                     nr_inodes;
93 };
94
95 /*
96  * A reservation for space on disk:
97  */
98 struct disk_reservation {
99         u64                     sectors;
100         u32                     gen;
101         unsigned                nr_replicas;
102 };
103
104 struct copygc_heap_entry {
105         u8                      gen;
106         u32                     sectors;
107         u64                     offset;
108 };
109
110 typedef HEAP(struct copygc_heap_entry) copygc_heap;
111
112 #endif /* _BUCKETS_TYPES_H */