xref: /openbmc/linux/drivers/md/bcache/request.h (revision b54d6934da7857f87b092df9b77dc1f42818ba94)
1cafe5635SKent Overstreet #ifndef _BCACHE_REQUEST_H_
2cafe5635SKent Overstreet #define _BCACHE_REQUEST_H_
3cafe5635SKent Overstreet 
4cafe5635SKent Overstreet #include <linux/cgroup.h>
5cafe5635SKent Overstreet 
6cafe5635SKent Overstreet struct search {
7cafe5635SKent Overstreet 	/* Stack frame for bio_complete */
8cafe5635SKent Overstreet 	struct closure		cl;
9*b54d6934SKent Overstreet 	struct closure		btree;
10cafe5635SKent Overstreet 
11cafe5635SKent Overstreet 	struct bcache_device	*d;
12c18536a7SKent Overstreet 	struct cache_set	*c;
13cafe5635SKent Overstreet 	struct task_struct	*task;
14cafe5635SKent Overstreet 
15cafe5635SKent Overstreet 	struct bbio		bio;
16cafe5635SKent Overstreet 	struct bio		*orig_bio;
17cafe5635SKent Overstreet 	struct bio		*cache_miss;
18c18536a7SKent Overstreet 
19c18536a7SKent Overstreet 	/* Bio to be inserted into the cache */
20c18536a7SKent Overstreet 	struct bio		*cache_bio;
21cafe5635SKent Overstreet 	unsigned		cache_bio_sectors;
22cafe5635SKent Overstreet 
23c18536a7SKent Overstreet 	unsigned		inode;
24c18536a7SKent Overstreet 
25cafe5635SKent Overstreet 	unsigned		recoverable:1;
26cafe5635SKent Overstreet 	unsigned		unaligned_bvec:1;
27cafe5635SKent Overstreet 
28cafe5635SKent Overstreet 	unsigned		write:1;
29cafe5635SKent Overstreet 	unsigned		writeback:1;
30cafe5635SKent Overstreet 
31c18536a7SKent Overstreet 	unsigned		csum:1;
32c18536a7SKent Overstreet 	unsigned		bypass:1;
33c18536a7SKent Overstreet 	unsigned		flush_journal:1;
34c18536a7SKent Overstreet 
35c18536a7SKent Overstreet 	unsigned		insert_data_done:1;
36c18536a7SKent Overstreet 
37c18536a7SKent Overstreet 	uint16_t		write_prio;
38c18536a7SKent Overstreet 
39cafe5635SKent Overstreet 	/* IO error returned to s->bio */
40cafe5635SKent Overstreet 	short			error;
41cafe5635SKent Overstreet 	unsigned long		start_time;
42cafe5635SKent Overstreet 
43cafe5635SKent Overstreet 	struct btree_op		op;
440b93207aSKent Overstreet 
450b93207aSKent Overstreet 	/* Anything past this point won't get zeroed in search_alloc() */
460b93207aSKent Overstreet 	struct keylist		insert_keys;
47cafe5635SKent Overstreet };
48cafe5635SKent Overstreet 
49c37511b8SKent Overstreet unsigned bch_get_congested(struct cache_set *);
50a34a8bfdSKent Overstreet void bch_data_insert(struct closure *cl);
51cafe5635SKent Overstreet 
52cafe5635SKent Overstreet void bch_open_buckets_free(struct cache_set *);
53cafe5635SKent Overstreet int bch_open_buckets_alloc(struct cache_set *);
54cafe5635SKent Overstreet 
55cafe5635SKent Overstreet void bch_cached_dev_request_init(struct cached_dev *dc);
56cafe5635SKent Overstreet void bch_flash_dev_request_init(struct bcache_device *d);
57cafe5635SKent Overstreet 
58cafe5635SKent Overstreet extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
59cafe5635SKent Overstreet 
60cafe5635SKent Overstreet struct bch_cgroup {
61cafe5635SKent Overstreet #ifdef CONFIG_CGROUP_BCACHE
62cafe5635SKent Overstreet 	struct cgroup_subsys_state	css;
63cafe5635SKent Overstreet #endif
64cafe5635SKent Overstreet 	/*
65cafe5635SKent Overstreet 	 * We subtract one from the index into bch_cache_modes[], so that
66cafe5635SKent Overstreet 	 * default == -1; this makes it so the rest match up with d->cache_mode,
67cafe5635SKent Overstreet 	 * and we use d->cache_mode if cgrp->cache_mode < 0
68cafe5635SKent Overstreet 	 */
69cafe5635SKent Overstreet 	short				cache_mode;
70cafe5635SKent Overstreet 	bool				verify;
71cafe5635SKent Overstreet 	struct cache_stat_collector	stats;
72cafe5635SKent Overstreet };
73cafe5635SKent Overstreet 
74cafe5635SKent Overstreet struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
75cafe5635SKent Overstreet 
76cafe5635SKent Overstreet #endif /* _BCACHE_REQUEST_H_ */
77