summaryrefslogtreecommitdiff
path: root/libbcache/keybuf_types.h
blob: 3facc4a07526dae4b21d421adc7117069bb925e8 (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
#ifndef _BCACHE_KEYBUF_TYPES_H
#define _BCACHE_KEYBUF_TYPES_H

struct keybuf_key {
	struct rb_node		node;
	BKEY_PADDED(key);
	atomic_t		ref;
};

#define KEYBUF_REFILL_BATCH	500

struct keybuf {
	struct bpos		last_scanned;
	spinlock_t		lock;

	/*
	 * Beginning and end of range in rb tree - so that we can skip taking
	 * lock and checking the rb tree when we need to check for overlapping
	 * keys.
	 */
	struct bpos		start;
	struct bpos		end;

	struct rb_root		keys;

	unsigned		max_in_flight;
	struct semaphore	in_flight;

	DECLARE_ARRAY_ALLOCATOR(struct keybuf_key, freelist,
				KEYBUF_REFILL_BATCH);
};

#endif /* _BCACHE_KEYBUF_TYPES_H */