summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_journal_iter_types.h
blob: 8b773823704f27fc53d41dcd99abc6d9ff43bcf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H
#define _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H

struct journal_key_range_overwritten {
	size_t			start, end;
};

struct journal_key {
	u64			journal_seq;
	u32			journal_offset;
	enum btree_id		btree_id:8;
	unsigned		level:8;
	bool			allocated;
	bool			overwritten;
	struct journal_key_range_overwritten __rcu *
				overwritten_range;
	struct bkey_i		*k;
};

struct journal_keys {
	/* must match layout in darray_types.h */
	size_t			nr, size;
	struct journal_key	*data;
	/*
	 * Gap buffer: instead of all the empty space in the array being at the
	 * end of the buffer - from @nr to @size - the empty space is at @gap.
	 * This means that sequential insertions are O(n) instead of O(n^2).
	 */
	size_t			gap;
	atomic_t		ref;
	bool			initial_ref_held;
	struct mutex		overwrite_lock;
};

#endif /* _BCACHEFS_BTREE_JOURNAL_ITER_TYPES_H */