xref: /openbmc/linux/drivers/md/bcache/request.h (revision da415a096fc06e49d1a15f7a06bcfe6ad44c5d38)
1cafe5635SKent Overstreet #ifndef _BCACHE_REQUEST_H_
2cafe5635SKent Overstreet #define _BCACHE_REQUEST_H_
3cafe5635SKent Overstreet 
4cafe5635SKent Overstreet #include <linux/cgroup.h>
5cafe5635SKent Overstreet 
6220bb38cSKent Overstreet struct data_insert_op {
7cafe5635SKent Overstreet 	struct closure		cl;
8c18536a7SKent Overstreet 	struct cache_set	*c;
9220bb38cSKent Overstreet 	struct bio		*bio;
10*da415a09SNicholas Swenson 	struct workqueue_struct *wq;
11cafe5635SKent Overstreet 
12c18536a7SKent Overstreet 	unsigned		inode;
132599b53bSKent Overstreet 	uint16_t		write_point;
14220bb38cSKent Overstreet 	uint16_t		write_prio;
15220bb38cSKent Overstreet 	short			error;
16c18536a7SKent Overstreet 
17a5ae4300SKent Overstreet 	union {
18a5ae4300SKent Overstreet 		uint16_t	flags;
19a5ae4300SKent Overstreet 
20a5ae4300SKent Overstreet 	struct {
21c18536a7SKent Overstreet 		unsigned	bypass:1;
22220bb38cSKent Overstreet 		unsigned	writeback:1;
23c18536a7SKent Overstreet 		unsigned	flush_journal:1;
24220bb38cSKent Overstreet 		unsigned	csum:1;
25220bb38cSKent Overstreet 
26220bb38cSKent Overstreet 		unsigned	replace:1;
27220bb38cSKent Overstreet 		unsigned	replace_collision:1;
28c18536a7SKent Overstreet 
29c18536a7SKent Overstreet 		unsigned	insert_data_done:1;
30a5ae4300SKent Overstreet 	};
31a5ae4300SKent Overstreet 	};
320b93207aSKent Overstreet 
330b93207aSKent Overstreet 	struct keylist		insert_keys;
341b207d80SKent Overstreet 	BKEY_PADDED(replace_key);
35cafe5635SKent Overstreet };
36cafe5635SKent Overstreet 
37c37511b8SKent Overstreet unsigned bch_get_congested(struct cache_set *);
38a34a8bfdSKent Overstreet void bch_data_insert(struct closure *cl);
39cafe5635SKent Overstreet 
40cafe5635SKent Overstreet void bch_cached_dev_request_init(struct cached_dev *dc);
41cafe5635SKent Overstreet void bch_flash_dev_request_init(struct bcache_device *d);
42cafe5635SKent Overstreet 
43cafe5635SKent Overstreet extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
44cafe5635SKent Overstreet 
45cafe5635SKent Overstreet struct bch_cgroup {
46cafe5635SKent Overstreet #ifdef CONFIG_CGROUP_BCACHE
47cafe5635SKent Overstreet 	struct cgroup_subsys_state	css;
48cafe5635SKent Overstreet #endif
49cafe5635SKent Overstreet 	/*
50cafe5635SKent Overstreet 	 * We subtract one from the index into bch_cache_modes[], so that
51cafe5635SKent Overstreet 	 * default == -1; this makes it so the rest match up with d->cache_mode,
52cafe5635SKent Overstreet 	 * and we use d->cache_mode if cgrp->cache_mode < 0
53cafe5635SKent Overstreet 	 */
54cafe5635SKent Overstreet 	short				cache_mode;
55cafe5635SKent Overstreet 	bool				verify;
56cafe5635SKent Overstreet 	struct cache_stat_collector	stats;
57cafe5635SKent Overstreet };
58cafe5635SKent Overstreet 
59cafe5635SKent Overstreet struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
60cafe5635SKent Overstreet 
61cafe5635SKent Overstreet #endif /* _BCACHE_REQUEST_H_ */
62