blob: 0f79177c4f335a27113ccded335a6e5600a0c1a4 [file] [log] [blame]
Kent Overstreetcafe5632013-03-23 16:11:31 -07001#ifndef _BCACHE_REQUEST_H_
2#define _BCACHE_REQUEST_H_
3
4#include <linux/cgroup.h>
5
6struct search {
7 /* Stack frame for bio_complete */
8 struct closure cl;
9
10 struct bcache_device *d;
Kent Overstreetc18536a2013-07-24 17:44:17 -070011 struct cache_set *c;
Kent Overstreetcafe5632013-03-23 16:11:31 -070012 struct task_struct *task;
13
14 struct bbio bio;
15 struct bio *orig_bio;
16 struct bio *cache_miss;
Kent Overstreetc18536a2013-07-24 17:44:17 -070017
18 /* Bio to be inserted into the cache */
19 struct bio *cache_bio;
Kent Overstreetcafe5632013-03-23 16:11:31 -070020 unsigned cache_bio_sectors;
21
Kent Overstreetc18536a2013-07-24 17:44:17 -070022 unsigned inode;
23
Kent Overstreetcafe5632013-03-23 16:11:31 -070024 unsigned recoverable:1;
25 unsigned unaligned_bvec:1;
26
27 unsigned write:1;
28 unsigned writeback:1;
29
Kent Overstreetc18536a2013-07-24 17:44:17 -070030 unsigned csum:1;
31 unsigned bypass:1;
32 unsigned flush_journal:1;
33
34 unsigned insert_data_done:1;
35
36 uint16_t write_prio;
37
Kent Overstreetcafe5632013-03-23 16:11:31 -070038 /* IO error returned to s->bio */
39 short error;
40 unsigned long start_time;
41
Kent Overstreetcafe5632013-03-23 16:11:31 -070042 struct btree_op op;
Kent Overstreet0b932072013-07-24 17:26:51 -070043
44 /* Anything past this point won't get zeroed in search_alloc() */
45 struct keylist insert_keys;
Kent Overstreetcafe5632013-03-23 16:11:31 -070046};
47
Kent Overstreetc37511b2013-04-26 15:39:55 -070048unsigned bch_get_congested(struct cache_set *);
Kent Overstreeta34a8bf2013-10-24 17:07:04 -070049void bch_data_insert(struct closure *cl);
Kent Overstreetcafe5632013-03-23 16:11:31 -070050
51void bch_open_buckets_free(struct cache_set *);
52int bch_open_buckets_alloc(struct cache_set *);
53
54void bch_cached_dev_request_init(struct cached_dev *dc);
55void bch_flash_dev_request_init(struct bcache_device *d);
56
57extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
58
59struct bch_cgroup {
60#ifdef CONFIG_CGROUP_BCACHE
61 struct cgroup_subsys_state css;
62#endif
63 /*
64 * We subtract one from the index into bch_cache_modes[], so that
65 * default == -1; this makes it so the rest match up with d->cache_mode,
66 * and we use d->cache_mode if cgrp->cache_mode < 0
67 */
68 short cache_mode;
69 bool verify;
70 struct cache_stat_collector stats;
71};
72
73struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
74
75#endif /* _BCACHE_REQUEST_H_ */