1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BUCKETS_TYPES_H
3 #define _BUCKETS_TYPES_H
4 
5 #include "bcachefs_format.h"
6 #include "util.h"
7 
8 #define BUCKET_JOURNAL_SEQ_BITS		16
9 
10 struct bucket {
11 	u8			lock;
12 	u8			gen_valid:1;
13 	u8			data_type:7;
14 	u8			gen;
15 	u8			stripe_redundancy;
16 	u32			stripe;
17 	u32			dirty_sectors;
18 	u32			cached_sectors;
19 	u32			stripe_sectors;
20 } __aligned(sizeof(long));
21 
22 struct bucket_gens {
23 	struct rcu_head		rcu;
24 	u16			first_bucket;
25 	size_t			nbuckets;
26 	size_t			nbuckets_minus_first;
27 	u8			b[];
28 };
29 
30 struct bch_dev_usage {
31 	struct bch_dev_usage_type {
32 		u64		buckets;
33 		u64		sectors; /* _compressed_ sectors: */
34 		/*
35 		 * XXX
36 		 * Why do we have this? Isn't it just buckets * bucket_size -
37 		 * sectors?
38 		 */
39 		u64		fragmented;
40 	}			d[BCH_DATA_NR];
41 };
42 
43 struct bch_fs_usage_base {
44 	u64			hidden;
45 	u64			btree;
46 	u64			data;
47 	u64			cached;
48 	u64			reserved;
49 	u64			nr_inodes;
50 };
51 
52 struct bch_fs_usage_short {
53 	u64			capacity;
54 	u64			used;
55 	u64			free;
56 	u64			nr_inodes;
57 };
58 
59 /*
60  * A reservation for space on disk:
61  */
62 struct disk_reservation {
63 	u64			sectors;
64 	u32			gen;
65 	unsigned		nr_replicas;
66 };
67 
68 #endif /* _BUCKETS_TYPES_H */
69