blob: 54d7de27356f1a20f330eb404b62f23d422a07b7 [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 Overstreetcafe5632013-03-23 16:11:31 -07009 struct task_struct *task;
Kent Overstreet220bb382013-09-10 19:02:45 -070010 struct bio *bio;
Kent Overstreetcafe5632013-03-23 16:11:31 -070011
Kent Overstreetc18536a2013-07-24 17:44:17 -070012 unsigned inode;
Kent Overstreet220bb382013-09-10 19:02:45 -070013 uint16_t write_prio;
14 short error;
Kent Overstreetc18536a2013-07-24 17:44:17 -070015
Kent Overstreetc18536a2013-07-24 17:44:17 -070016 unsigned bypass:1;
Kent Overstreet220bb382013-09-10 19:02:45 -070017 unsigned writeback:1;
Kent Overstreetc18536a2013-07-24 17:44:17 -070018 unsigned flush_journal:1;
Kent Overstreet220bb382013-09-10 19:02:45 -070019 unsigned csum:1;
20
21 unsigned replace:1;
22 unsigned replace_collision:1;
Kent Overstreetc18536a2013-07-24 17:44:17 -070023
24 unsigned insert_data_done:1;
Kent Overstreet0b932072013-07-24 17:26:51 -070025
26 /* Anything past this point won't get zeroed in search_alloc() */
27 struct keylist insert_keys;
Kent Overstreet1b207d82013-09-10 18:52:54 -070028 BKEY_PADDED(replace_key);
Kent Overstreetcafe5632013-03-23 16:11:31 -070029};
30
Kent Overstreetc37511b2013-04-26 15:39:55 -070031unsigned bch_get_congested(struct cache_set *);
Kent Overstreeta34a8bf2013-10-24 17:07:04 -070032void bch_data_insert(struct closure *cl);
Kent Overstreetcafe5632013-03-23 16:11:31 -070033
34void bch_open_buckets_free(struct cache_set *);
35int bch_open_buckets_alloc(struct cache_set *);
36
37void bch_cached_dev_request_init(struct cached_dev *dc);
38void bch_flash_dev_request_init(struct bcache_device *d);
39
40extern struct kmem_cache *bch_search_cache, *bch_passthrough_cache;
41
42struct bch_cgroup {
43#ifdef CONFIG_CGROUP_BCACHE
44 struct cgroup_subsys_state css;
45#endif
46 /*
47 * We subtract one from the index into bch_cache_modes[], so that
48 * default == -1; this makes it so the rest match up with d->cache_mode,
49 * and we use d->cache_mode if cgrp->cache_mode < 0
50 */
51 short cache_mode;
52 bool verify;
53 struct cache_stat_collector stats;
54};
55
56struct bch_cgroup *bch_bio_to_cgroup(struct bio *bio);
57
58#endif /* _BCACHE_REQUEST_H_ */