xref: /linux/fs/bcachefs/btree_journal_iter_types.h (revision 6f2a71a99ebd5dfaa7948a2e9c59eae94b741bd8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H
3 #define _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H
4 
5 struct journal_key_range_overwritten {
6 	size_t			start, end;
7 };
8 
9 struct journal_key {
10 	u64			journal_seq;
11 	u32			journal_offset;
12 	enum btree_id		btree_id:8;
13 	unsigned		level:8;
14 	bool			allocated:1;
15 	bool			overwritten:1;
16 	bool			rewind:1;
17 	struct journal_key_range_overwritten __rcu *
18 				overwritten_range;
19 	struct bkey_i		*k;
20 };
21 
22 struct journal_keys {
23 	/* must match layout in darray_types.h */
24 	size_t			nr, size;
25 	struct journal_key	*data;
26 	/*
27 	 * Gap buffer: instead of all the empty space in the array being at the
28 	 * end of the buffer - from @nr to @size - the empty space is at @gap.
29 	 * This means that sequential insertions are O(n) instead of O(n^2).
30 	 */
31 	size_t			gap;
32 	atomic_t		ref;
33 	bool			initial_ref_held;
34 	struct mutex		overwrite_lock;
35 };
36 
37 #endif /* _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H */
38