blob: 5ea7a0e6fca039f610a1c43c18dac40fa0123b99 [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;
Kent Overstreet1b207d82013-09-10 18:52:54 -070036 unsigned replace:1;
Kent Overstreetc18536a2013-07-24 17:44:17 -070037
38 uint16_t write_prio;
39
Kent Overstreetcafe5632013-03-23 16:11:31 -070040 /* IO error returned to s->bio */
41 short error;
42 unsigned long start_time;
43
Kent Overstreetcafe5632013-03-23 16:11:31 -070044 struct btree_op op;
Kent Overstreet0b932072013-07-24 17:26:51 -070045
46 /* Anything past this point won't get zeroed in search_alloc() */
47 struct keylist insert_keys;
Kent Overstreet1b207d82013-09-10 18:52:54 -070048 BKEY_PADDED(replace_key);
Kent Overstreetcafe5632013-03-23 16:11:31 -070049};
50
Kent Overstreetc37511b2013-04-26 15:39:55 -070051unsigned bch_get_congested(struct cache_set *);
Kent Overstreeta34a8bf2013-10-24 17:07:04 -070052void bch_data_insert(struct closure *cl);
Kent Overstreetcafe5632013-03-23 16:11:31 -070053
54void bch_open_buckets_free(struct cache_set *);
55int bch_open_buckets_alloc(struct cache_set *);
56
57void bch_cached_dev_request_init(struct cached_dev *dc);
58void bch_flash_dev_request_init(struct bcache_device *d);
59
60extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
61
62struct bch_cgroup {
63#ifdef CONFIG_CGROUP_BCACHE
64 struct cgroup_subsys_state css;
65#endif
66 /*
67 * We subtract one from the index into bch_cache_modes[], so that
68 * default == -1; this makes it so the rest match up with d->cache_mode,
69 * and we use d->cache_mode if cgrp->cache_mode < 0
70 */
71 short cache_mode;
72 bool verify;
73 struct cache_stat_collector stats;
74};
75
76struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
77
78#endif /* _BCACHE_REQUEST_H_ */