]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/buckets_types.h
Rename from bcache-tools to bcachefs-tools
[bcachefs-tools-debian] / libbcachefs / buckets_types.h
1 #ifndef _BUCKETS_TYPES_H
2 #define _BUCKETS_TYPES_H
3
4 enum bucket_data_type {
5         BUCKET_DATA     = 0,
6         BUCKET_BTREE,
7         BUCKET_PRIOS,
8         BUCKET_JOURNAL,
9         BUCKET_SB,
10 };
11
12 struct bucket_mark {
13         union {
14         struct {
15                 u64             counter;
16         };
17
18         struct {
19                 u8              gen;
20
21                 /* generation copygc is going to move this bucket into */
22                 unsigned        copygc:1;
23
24                 unsigned        journal_seq_valid:1;
25
26                 /*
27                  * If this bucket had metadata while at the current generation
28                  * number, the allocator must increment its gen before we reuse
29                  * it:
30                  */
31                 unsigned        had_metadata:1;
32
33                 unsigned        owned_by_allocator:1;
34
35                 unsigned        data_type:3;
36
37                 unsigned        nouse:1;
38
39                 u16             dirty_sectors;
40                 u16             cached_sectors;
41
42                 /*
43                  * low bits of journal sequence number when this bucket was most
44                  * recently modified: if journal_seq_valid is set, this bucket
45                  * can't be reused until the journal sequence number written to
46                  * disk is >= the bucket's journal sequence number:
47                  */
48                 u16             journal_seq;
49         };
50         };
51 };
52
53 struct bucket {
54         union {
55                 struct {
56                         u16     read_prio;
57                         u16     write_prio;
58                 };
59                 u16             prio[2];
60         };
61
62         union {
63                 struct bucket_mark      _mark;
64                 const struct bucket_mark mark;
65         };
66 };
67
68 enum s_compressed {
69         S_COMPRESSED,
70         S_UNCOMPRESSED,
71         S_COMPRESSED_NR,
72 };
73
74 enum s_alloc {
75         S_META,
76         S_DIRTY,
77         S_CACHED,
78         S_ALLOC_NR,
79 };
80
81 struct bch_dev_usage {
82         u64                     buckets_dirty;
83         u64                     buckets_cached;
84         u64                     buckets_meta;
85         u64                     buckets_alloc;
86
87         u64                     sectors[S_ALLOC_NR];
88 };
89
90 struct bch_fs_usage {
91         /* all fields are in units of 512 byte sectors: */
92         u64                     s[S_COMPRESSED_NR][S_ALLOC_NR];
93         u64                     persistent_reserved;
94         u64                     online_reserved;
95         u64                     available_cache;
96 };
97
98 struct bucket_heap_entry {
99         struct bucket *g;
100         unsigned long val;
101 };
102
103 /*
104  * A reservation for space on disk:
105  */
106 struct disk_reservation {
107         u64             sectors;
108         u32             gen;
109         unsigned        nr_replicas;
110 };
111
112 #endif /* _BUCKETS_TYPES_H */