]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 15f6e66e86 bcachefs: pass around bset_tree less
[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         struct {
12                 atomic64_t      v;
13         };
14
15         struct {
16                 u8              gen;
17                 u8              data_type:3,
18                                 gen_valid:1,
19                                 owned_by_allocator:1,
20                                 nouse:1,
21                                 journal_seq_valid:1;
22                 u16             dirty_sectors;
23                 u16             cached_sectors;
24
25                 /*
26                  * low bits of journal sequence number when this bucket was most
27                  * recently modified: if journal_seq_valid is set, this bucket
28                  * can't be reused until the journal sequence number written to
29                  * disk is >= the bucket's journal sequence number:
30                  */
31                 u16             journal_seq;
32         };
33         };
34 };
35
36 struct bucket {
37         union {
38                 struct bucket_mark      _mark;
39                 const struct bucket_mark mark;
40         };
41
42         u16                             io_time[2];
43 };
44
45 struct bucket_array {
46         struct rcu_head         rcu;
47         u16                     first_bucket;
48         size_t                  nbuckets;
49         struct bucket           b[];
50 };
51
52 struct bch_dev_usage {
53         u64                     buckets[BCH_DATA_NR];
54         u64                     buckets_alloc;
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         u64                     online_reserved;
65         u64                     available_cache;
66
67         struct {
68                 u64             data[BCH_DATA_NR];
69                 u64             persistent_reserved;
70         }                       replicas[BCH_REPLICAS_MAX];
71
72         u64                     buckets[BCH_DATA_NR];
73 };
74
75 /*
76  * A reservation for space on disk:
77  */
78 struct disk_reservation {
79         u64             sectors;
80         u32             gen;
81         unsigned        nr_replicas;
82 };
83
84 struct copygc_heap_entry {
85         u8                      gen;
86         u32                     sectors;
87         u64                     offset;
88 };
89
90 typedef HEAP(struct copygc_heap_entry) copygc_heap;
91
92 #endif /* _BUCKETS_TYPES_H */