1 #ifndef _BCACHE_BLOCKDEV_H
2 #define _BCACHE_BLOCKDEV_H
4 #include "blockdev_types.h"
7 void bch_write_bdev_super(struct cached_dev *, struct closure *);
9 void bch_cached_dev_release(struct kobject *);
10 void bch_blockdev_volume_release(struct kobject *);
12 int bch_cached_dev_attach(struct cached_dev *, struct cache_set *);
13 void bch_attach_backing_devs(struct cache_set *);
15 void bch_cached_dev_detach(struct cached_dev *);
16 void bch_cached_dev_run(struct cached_dev *);
17 void bch_blockdev_stop(struct bcache_device *);
19 bool bch_is_open_backing_dev(struct block_device *);
20 const char *bch_backing_dev_register(struct bcache_superblock *);
22 int bch_blockdev_volume_create(struct cache_set *, u64);
23 int bch_blockdev_volumes_start(struct cache_set *);
25 void bch_blockdevs_stop(struct cache_set *);
27 void bch_blockdev_exit(void);
28 int bch_blockdev_init(void);
30 static inline void cached_dev_put(struct cached_dev *dc)
32 if (atomic_dec_and_test(&dc->count))
33 schedule_work(&dc->detach);
36 static inline bool cached_dev_get(struct cached_dev *dc)
38 if (!atomic_inc_not_zero(&dc->count))
41 /* Paired with the mb in cached_dev_attach */
42 smp_mb__after_atomic();
46 static inline u64 bcache_dev_inum(struct bcache_device *d)
48 return d->inode.k.p.inode;
51 static inline struct bcache_device *bch_dev_find(struct cache_set *c, u64 inode)
53 return radix_tree_lookup(&c->devices, inode);
57 /* Stack frame for bio_complete */
61 struct bch_read_bio rbio;
62 struct bch_write_bio wbio;
66 struct bcache_device *d;
71 /* Flags only used for reads */
72 unsigned recoverable:1;
73 unsigned read_dirty_data:1;
74 unsigned cache_miss:1;
77 * For reads: bypass read from cache and insertion into cache
78 * For writes: discard key range from cache, sending the write to
79 * the backing device (if there is a backing device)
83 unsigned long start_time;
86 * Mostly only used for writes. For reads, we still make use of
87 * some trivial fields:
91 struct bch_write_op iop;
94 extern struct kmem_cache *bch_search_cache;
96 extern struct kobj_type bch_cached_dev_ktype;
97 extern struct kobj_type bch_blockdev_volume_ktype;
99 #endif /* _BCACHE_BLOCKDEV_H */