X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libbcache%2Fblockdev.h;h=aa6c12bba1d5c5bf78a8c0063eef5cf565f85887;hb=171ee48e57be78f4e95954c99851553fa523bf91;hp=0fc0ed1b80c4387f562c2f4fbed810c86b259ccc;hpb=a5b5eba7f788bb77cf57f9c94f3474a2d439ab0b;p=bcachefs-tools-debian diff --git a/libbcache/blockdev.h b/libbcache/blockdev.h index 0fc0ed1..aa6c12b 100644 --- a/libbcache/blockdev.h +++ b/libbcache/blockdev.h @@ -4,6 +4,49 @@ #include "blockdev_types.h" #include "io_types.h" +struct search { + /* Stack frame for bio_complete */ + struct closure cl; + + union { + struct bch_read_bio rbio; + struct bch_write_bio wbio; + }; + /* Not modified */ + struct bio *orig_bio; + struct bcache_device *d; + + unsigned inode; + unsigned write:1; + + /* Flags only used for reads */ + unsigned recoverable:1; + unsigned read_dirty_data:1; + unsigned cache_miss:1; + + /* + * For reads: bypass read from cache and insertion into cache + * For writes: discard key range from cache, sending the write to + * the backing device (if there is a backing device) + */ + unsigned bypass:1; + + unsigned long start_time; + + /* + * Mostly only used for writes. For reads, we still make use of + * some trivial fields: + * - c + * - error + */ + struct bch_write_op iop; +}; + +#ifndef NO_BCACHE_BLOCKDEV + +extern struct kobj_type bch_cached_dev_ktype; +extern struct kobj_type bch_blockdev_volume_ktype; + void bch_write_bdev_super(struct cached_dev *, struct closure *); void bch_cached_dev_release(struct kobject *); @@ -24,9 +67,49 @@ int bch_blockdev_volumes_start(struct cache_set *); void bch_blockdevs_stop(struct cache_set *); +void bch_fs_blockdev_exit(struct cache_set *); +int bch_fs_blockdev_init(struct cache_set *); void bch_blockdev_exit(void); int bch_blockdev_init(void); +#else + +static inline void bch_write_bdev_super(struct cached_dev *dc, + struct closure *cl) {} + +static inline void bch_cached_dev_release(struct kobject *kobj) {} +static inline void bch_blockdev_volume_release(struct kobject *kobj) {} + +static inline int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) +{ + return 0; +} +static inline void bch_attach_backing_devs(struct cache_set *c) {} + +static inline void bch_cached_dev_detach(struct cached_dev *dc) {} +static inline void bch_cached_dev_run(struct cached_dev *dc) {} +static inline void bch_blockdev_stop(struct bcache_device *d) {} + +static inline bool bch_is_open_backing_dev(struct block_device *bdev) +{ + return false; +} +static inline const char *bch_backing_dev_register(struct bcache_superblock *sb) +{ + return "not implemented"; +} + +static inline int bch_blockdev_volume_create(struct cache_set *c, u64 s) { return 0; } +static inline int bch_blockdev_volumes_start(struct cache_set *c) { return 0; } + +static inline void bch_blockdevs_stop(struct cache_set *c) {} +static inline void bch_fs_blockdev_exit(struct cache_set *c) {} +static inline int bch_fs_blockdev_init(struct cache_set *c) { return 0; } +static inline void bch_blockdev_exit(void) {} +static inline int bch_blockdev_init(void) { return 0; } + +#endif + static inline void cached_dev_put(struct cached_dev *dc) { if (atomic_dec_and_test(&dc->count)) @@ -53,47 +136,4 @@ static inline struct bcache_device *bch_dev_find(struct cache_set *c, u64 inode) return radix_tree_lookup(&c->devices, inode); } -struct search { - /* Stack frame for bio_complete */ - struct closure cl; - - union { - struct bch_read_bio rbio; - struct bch_write_bio wbio; - }; - /* Not modified */ - struct bio *orig_bio; - struct bcache_device *d; - - unsigned inode; - unsigned write:1; - - /* Flags only used for reads */ - unsigned recoverable:1; - unsigned read_dirty_data:1; - unsigned cache_miss:1; - - /* - * For reads: bypass read from cache and insertion into cache - * For writes: discard key range from cache, sending the write to - * the backing device (if there is a backing device) - */ - unsigned bypass:1; - - unsigned long start_time; - - /* - * Mostly only used for writes. For reads, we still make use of - * some trivial fields: - * - c - * - error - */ - struct bch_write_op iop; -}; - -extern struct kmem_cache *bch_search_cache; - -extern struct kobj_type bch_cached_dev_ktype; -extern struct kobj_type bch_blockdev_volume_ktype; - #endif /* _BCACHE_BLOCKDEV_H */