blob: c117c4082aa2683ded10901962330fe4c83b2d2e [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
Kent Overstreet220bb382013-09-10 19:02:45 -07006struct data_insert_op {
Kent Overstreetcafe5632013-03-23 16:11:31 -07007 struct closure cl;
Kent Overstreetc18536a2013-07-24 17:44:17 -07008 struct cache_set *c;
Kent Overstreet220bb382013-09-10 19:02:45 -07009 struct bio *bio;
Nicholas Swensonda415a02014-01-09 16:03:04 -080010 struct workqueue_struct *wq;
Kent Overstreetcafe5632013-03-23 16:11:31 -070011
Kent Overstreetc18536a2013-07-24 17:44:17 -070012 unsigned inode;
Kent Overstreet2599b532013-07-24 18:11:11 -070013 uint16_t write_point;
Kent Overstreet220bb382013-09-10 19:02:45 -070014 uint16_t write_prio;
15 short error;
Kent Overstreetc18536a2013-07-24 17:44:17 -070016
Kent Overstreeta5ae4302013-09-10 19:16:31 -070017 union {
18 uint16_t flags;
Kent Overstreet220bb382013-09-10 19:02:45 -070019
Kent Overstreeta5ae4302013-09-10 19:16:31 -070020 struct {
21 unsigned bypass:1;
22 unsigned writeback:1;
23 unsigned flush_journal:1;
24 unsigned csum:1;
Kent Overstreetc18536a2013-07-24 17:44:17 -070025
Kent Overstreeta5ae4302013-09-10 19:16:31 -070026 unsigned replace:1;
27 unsigned replace_collision:1;
Kent Overstreet0b932072013-07-24 17:26:51 -070028
Kent Overstreeta5ae4302013-09-10 19:16:31 -070029 unsigned insert_data_done:1;
30 };
31 };
32
Kent Overstreet0b932072013-07-24 17:26:51 -070033 struct keylist insert_keys;
Kent Overstreet1b207d82013-09-10 18:52:54 -070034 BKEY_PADDED(replace_key);
Kent Overstreetcafe5632013-03-23 16:11:31 -070035};
36
Kent Overstreetc37511b2013-04-26 15:39:55 -070037unsigned bch_get_congested(struct cache_set *);
Kent Overstreeta34a8bf2013-10-24 17:07:04 -070038void bch_data_insert(struct closure *cl);
Kent Overstreetcafe5632013-03-23 16:11:31 -070039
Kent Overstreetcafe5632013-03-23 16:11:31 -070040void bch_cached_dev_request_init(struct cached_dev *dc);
41void bch_flash_dev_request_init(struct bcache_device *d);
42
43extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
44
45struct bch_cgroup {
46#ifdef CONFIG_CGROUP_BCACHE
47 struct cgroup_subsys_state css;
48#endif
49 /*
50 * We subtract one from the index into bch_cache_modes[], so that
51 * default == -1; this makes it so the rest match up with d->cache_mode,
52 * and we use d->cache_mode if cgrp->cache_mode < 0
53 */
54 short cache_mode;
55 bool verify;
56 struct cache_stat_collector stats;
57};
58
59struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
60
61#endif /* _BCACHE_REQUEST_H_ */