]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Update bcachefs sources to 9fc6ccd865 bcachefs: fix copygc_pred()
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 #include "util.h"
5
6 struct bucket_mark {
7         union {
8         struct {
9                 u64             counter;
10         };
11
12         struct {
13                 u8              gen;
14                 u8              data_type:3,
15                                 gen_valid:1,
16                                 owned_by_allocator:1,
17                                 nouse:1,
18                                 journal_seq_valid:1;
19                 u16             dirty_sectors;
20                 u16             cached_sectors;
21
22                 /*
23                  * low bits of journal sequence number when this bucket was most
24                  * recently modified: if journal_seq_valid is set, this bucket
25                  * can't be reused until the journal sequence number written to
26                  * disk is >= the bucket's journal sequence number:
27                  */
28                 u16             journal_seq;
29         };
30         };
31 };
32
33 struct bucket {
34         u16                             prio[2];
35
36         union {
37                 struct bucket_mark      _mark;
38                 const struct bucket_mark mark;
39         };
40 };
41
42 struct bucket_array {
43         struct rcu_head         rcu;
44         u16                     first_bucket;
45         size_t                  nbuckets;
46         struct bucket           b[];
47 };
48
49 struct bch_dev_usage {
50         u64                     buckets[BCH_DATA_NR];
51         u64                     buckets_alloc;
52         u64                     buckets_unavailable;
53
54         /* _compressed_ sectors: */
55         u64                     sectors[BCH_DATA_NR];
56         u64                     sectors_fragmented;
57 };
58
59 /* kill, switch to bch_data_type? */
60 enum s_alloc {
61         S_META,
62         S_DIRTY,
63         S_ALLOC_NR,
64 };
65
66 struct bch_fs_usage {
67         /* all fields are in units of 512 byte sectors: */
68         /* _uncompressed_ sectors: */
69         u64                     online_reserved;
70         u64                     available_cache;
71
72         struct {
73                 u64             data[S_ALLOC_NR];
74                 u64             persistent_reserved;
75         }                       s[BCH_REPLICAS_MAX];
76 };
77
78 /*
79  * A reservation for space on disk:
80  */
81 struct disk_reservation {
82         u64             sectors;
83         u32             gen;
84         unsigned        nr_replicas;
85 };
86
87 struct copygc_heap_entry {
88         u64                     offset;
89         struct bucket_mark      mark;
90 };
91
92 typedef HEAP(struct copygc_heap_entry) copygc_heap;
93
94 #endif /* _BUCKETS_TYPES_H */