blob: ed578aa53ee2ec599de3f272e9d28cd7181c31a1 [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;
Kent Overstreetb54d6932013-07-24 18:04:18 -07009 struct closure btree;
Kent Overstreetcafe5632013-03-23 16:11:31 -070010
11 struct bcache_device *d;
Kent Overstreetc18536a2013-07-24 17:44:17 -070012 struct cache_set *c;
Kent Overstreetcafe5632013-03-23 16:11:31 -070013 struct task_struct *task;
14
15 struct bbio bio;
16 struct bio *orig_bio;
17 struct bio *cache_miss;
Kent Overstreetc18536a2013-07-24 17:44:17 -070018
19 /* Bio to be inserted into the cache */
20 struct bio *cache_bio;
Kent Overstreetcafe5632013-03-23 16:11:31 -070021 unsigned cache_bio_sectors;
22
Kent Overstreetc18536a2013-07-24 17:44:17 -070023 unsigned inode;
24
Kent Overstreetcafe5632013-03-23 16:11:31 -070025 unsigned recoverable:1;
26 unsigned unaligned_bvec:1;
27
28 unsigned write:1;
29 unsigned writeback:1;
30
Kent Overstreetc18536a2013-07-24 17:44:17 -070031 unsigned csum:1;
32 unsigned bypass:1;
33 unsigned flush_journal:1;
34
35 unsigned insert_data_done:1;
36
37 uint16_t write_prio;
38
Kent Overstreetcafe5632013-03-23 16:11:31 -070039 /* IO error returned to s->bio */
40 short error;
41 unsigned long start_time;
42
Kent Overstreetcafe5632013-03-23 16:11:31 -070043 struct btree_op op;
Kent Overstreet0b932072013-07-24 17:26:51 -070044
45 /* Anything past this point won't get zeroed in search_alloc() */
46 struct keylist insert_keys;
Kent Overstreetcafe5632013-03-23 16:11:31 -070047};
48
Kent Overstreetc37511b2013-04-26 15:39:55 -070049unsigned bch_get_congested(struct cache_set *);
Kent Overstreeta34a8bf2013-10-24 17:07:04 -070050void bch_data_insert(struct closure *cl);
Kent Overstreetcafe5632013-03-23 16:11:31 -070051
52void bch_open_buckets_free(struct cache_set *);
53int bch_open_buckets_alloc(struct cache_set *);
54
55void bch_cached_dev_request_init(struct cached_dev *dc);
56void bch_flash_dev_request_init(struct bcache_device *d);
57
58extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
59
60struct bch_cgroup {
61#ifdef CONFIG_CGROUP_BCACHE
62 struct cgroup_subsys_state css;
63#endif
64 /*
65 * We subtract one from the index into bch_cache_modes[], so that
66 * default == -1; this makes it so the rest match up with d->cache_mode,
67 * and we use d->cache_mode if cgrp->cache_mode < 0
68 */
69 short cache_mode;
70 bool verify;
71 struct cache_stat_collector stats;
72};
73
74struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
75
76#endif /* _BCACHE_REQUEST_H_ */