#include "bcache.h"
#include "btree.h"
#include "debug.h"
#include "extents.h"
#include "request.h"
#include "writeback.h"
#include "features.h"
#include <linux/blkdev.h>
#include <linux/pagemap.h>
#include <linux/debugfs.h>
#include <linux/idr.h>
#include <linux/kthread.h>
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/reboot.h>
#include <linux/sysfs.h>
unsigned int bch_cutoff_writeback;
unsigned int bch_cutoff_writeback_sync;
static const char bcache_magic[] = …;
static const char invalid_uuid[] = …;
static struct kobject *bcache_kobj;
struct mutex bch_register_lock;
bool bcache_is_reboot;
LIST_HEAD(…);
static LIST_HEAD(uncached_devices);
static int bcache_major;
static DEFINE_IDA(bcache_device_idx);
static wait_queue_head_t unregister_wait;
struct workqueue_struct *bcache_wq;
struct workqueue_struct *bch_flush_wq;
struct workqueue_struct *bch_journal_wq;
#define BTREE_MAX_PAGES …
#define BCACHE_MINORS …
#define BCACHE_DEVICE_IDX_MAX …
static unsigned int get_bucket_size(struct cache_sb *sb, struct cache_sb_disk *s)
{ … }
static const char *read_super_common(struct cache_sb *sb, struct block_device *bdev,
struct cache_sb_disk *s)
{ … }
static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
struct cache_sb_disk **res)
{ … }
static void write_bdev_super_endio(struct bio *bio)
{ … }
static void __write_super(struct cache_sb *sb, struct cache_sb_disk *out,
struct bio *bio)
{ … }
static CLOSURE_CALLBACK(bch_write_bdev_super_unlock)
{ … }
void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent)
{ … }
static void write_super_endio(struct bio *bio)
{ … }
static CLOSURE_CALLBACK(bcache_write_super_unlock)
{ … }
void bcache_write_super(struct cache_set *c)
{ … }
static void uuid_endio(struct bio *bio)
{ … }
static CLOSURE_CALLBACK(uuid_io_unlock)
{ … }
static void uuid_io(struct cache_set *c, blk_opf_t opf, struct bkey *k,
struct closure *parent)
{ … }
static char *uuid_read(struct cache_set *c, struct jset *j, struct closure *cl)
{ … }
static int __uuid_write(struct cache_set *c)
{ … }
int bch_uuid_write(struct cache_set *c)
{ … }
static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
{ … }
static struct uuid_entry *uuid_find_empty(struct cache_set *c)
{ … }
static void prio_endio(struct bio *bio)
{ … }
static void prio_io(struct cache *ca, uint64_t bucket, blk_opf_t opf)
{ … }
int bch_prio_write(struct cache *ca, bool wait)
{ … }
static int prio_read(struct cache *ca, uint64_t bucket)
{ … }
static int open_dev(struct gendisk *disk, blk_mode_t mode)
{ … }
static void release_dev(struct gendisk *b)
{ … }
static int ioctl_dev(struct block_device *b, blk_mode_t mode,
unsigned int cmd, unsigned long arg)
{ … }
static const struct block_device_operations bcache_cached_ops = …;
static const struct block_device_operations bcache_flash_ops = …;
void bcache_device_stop(struct bcache_device *d)
{ … }
static void bcache_device_unlink(struct bcache_device *d)
{ … }
static void bcache_device_link(struct bcache_device *d, struct cache_set *c,
const char *name)
{ … }
static void bcache_device_detach(struct bcache_device *d)
{ … }
static void bcache_device_attach(struct bcache_device *d, struct cache_set *c,
unsigned int id)
{ … }
static inline int first_minor_to_idx(int first_minor)
{ … }
static inline int idx_to_first_minor(int idx)
{ … }
static void bcache_device_free(struct bcache_device *d)
{ … }
static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
sector_t sectors, struct block_device *cached_bdev,
const struct block_device_operations *ops)
{ … }
static void calc_cached_dev_sectors(struct cache_set *c)
{ … }
#define BACKING_DEV_OFFLINE_TIMEOUT …
static int cached_dev_status_update(void *arg)
{ … }
int bch_cached_dev_run(struct cached_dev *dc)
{ … }
static void cancel_writeback_rate_update_dwork(struct cached_dev *dc)
{ … }
static void cached_dev_detach_finish(struct work_struct *w)
{ … }
void bch_cached_dev_detach(struct cached_dev *dc)
{ … }
int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
uint8_t *set_uuid)
{ … }
void bch_cached_dev_release(struct kobject *kobj)
{ … }
static CLOSURE_CALLBACK(cached_dev_free)
{ … }
static CLOSURE_CALLBACK(cached_dev_flush)
{ … }
static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
{ … }
static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
struct file *bdev_file,
struct cached_dev *dc)
{ … }
void bch_flash_dev_release(struct kobject *kobj)
{ … }
static CLOSURE_CALLBACK(flash_dev_free)
{ … }
static CLOSURE_CALLBACK(flash_dev_flush)
{ … }
static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
{ … }
static int flash_devs_run(struct cache_set *c)
{ … }
int bch_flash_dev_create(struct cache_set *c, uint64_t size)
{ … }
bool bch_cached_dev_error(struct cached_dev *dc)
{ … }
__printf(2, 3)
bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...)
{ … }
void bch_cache_set_release(struct kobject *kobj)
{ … }
static CLOSURE_CALLBACK(cache_set_free)
{ … }
static CLOSURE_CALLBACK(cache_set_flush)
{ … }
static void conditional_stop_bcache_device(struct cache_set *c,
struct bcache_device *d,
struct cached_dev *dc)
{ … }
static CLOSURE_CALLBACK(__cache_set_unregister)
{ … }
void bch_cache_set_stop(struct cache_set *c)
{ … }
void bch_cache_set_unregister(struct cache_set *c)
{ … }
#define alloc_meta_bucket_pages(gfp, sb) …
struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
{ … }
static int run_cache_set(struct cache_set *c)
{ … }
static const char *register_cache_set(struct cache *ca)
{ … }
void bch_cache_release(struct kobject *kobj)
{ … }
static int cache_alloc(struct cache *ca)
{ … }
static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
struct file *bdev_file,
struct cache *ca)
{ … }
static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
const char *buffer, size_t size);
static ssize_t bch_pending_bdevs_cleanup(struct kobject *k,
struct kobj_attribute *attr,
const char *buffer, size_t size);
kobj_attribute_write(…);
kobj_attribute_write(…);
kobj_attribute_write(…);
static bool bch_is_open_backing(dev_t dev)
{ … }
static bool bch_is_open_cache(dev_t dev)
{ … }
static bool bch_is_open(dev_t dev)
{ … }
struct async_reg_args { … };
static void register_bdev_worker(struct work_struct *work)
{ … }
static void register_cache_worker(struct work_struct *work)
{ … }
static void register_device_async(struct async_reg_args *args)
{ … }
static void *alloc_holder_object(struct cache_sb *sb)
{ … }
static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
const char *buffer, size_t size)
{ … }
struct pdev { … };
static ssize_t bch_pending_bdevs_cleanup(struct kobject *k,
struct kobj_attribute *attr,
const char *buffer,
size_t size)
{ … }
static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
{ … }
static struct notifier_block reboot = …;
static void bcache_exit(void)
{ … }
static void check_module_parameters(void)
{ … }
static int __init bcache_init(void)
{ … }
module_exit(bcache_exit);
module_init(…) …;
module_param(bch_cutoff_writeback, uint, 0);
MODULE_PARM_DESC(…) …;
module_param(bch_cutoff_writeback_sync, uint, 0);
MODULE_PARM_DESC(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;