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