diff options
36 files changed, 175 insertions, 127 deletions
diff --git a/drivers/md/bcache/acl.c b/drivers/md/bcache/acl.c index aaec01208042..64d56165fea3 100644 --- a/drivers/md/bcache/acl.c +++ b/drivers/md/bcache/acl.c @@ -133,6 +133,7 @@ fail: struct posix_acl *bch_get_acl(struct inode *inode, int type) { + struct cache_set *c = inode->i_sb->s_fs_info; int name_index; char *value = NULL; struct posix_acl *acl; @@ -148,12 +149,12 @@ struct posix_acl *bch_get_acl(struct inode *inode, int type) default: BUG(); } - ret = bch_xattr_get(inode, "", NULL, 0, name_index); + ret = bch_xattr_get(c, inode, "", NULL, 0, name_index); if (ret > 0) { value = kmalloc(ret, GFP_KERNEL); if (!value) return ERR_PTR(-ENOMEM); - ret = bch_xattr_get(inode, "", value, + ret = bch_xattr_get(c, inode, "", value, ret, name_index); } if (ret > 0) @@ -172,6 +173,7 @@ struct posix_acl *bch_get_acl(struct inode *inode, int type) int bch_set_acl(struct inode *inode, struct posix_acl *acl, int type) { + struct cache_set *c = inode->i_sb->s_fs_info; int name_index; void *value = NULL; size_t size = 0; @@ -209,7 +211,7 @@ int bch_set_acl(struct inode *inode, struct posix_acl *acl, int type) return (int)PTR_ERR(value); } - ret = bch_xattr_set(inode, "", value, size, 0, name_index); + ret = bch_xattr_set(c, inode, "", value, size, 0, name_index); kfree(value); diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index 6982687d3f40..cff750c00852 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -68,6 +68,7 @@ #include <linux/blkdev.h> #include <linux/kthread.h> +#include <linux/math64.h> #include <linux/random.h> #include <linux/rcupdate.h> #include <trace/events/bcache.h> diff --git a/drivers/md/bcache/alloc.h b/drivers/md/bcache/alloc.h index 532c15493a52..ac83e4f22d0e 100644 --- a/drivers/md/bcache/alloc.h +++ b/drivers/md/bcache/alloc.h @@ -9,6 +9,17 @@ struct cache; struct cache_set; struct cache_group; +static inline size_t prios_per_bucket(const struct cache *ca) +{ + return (bucket_bytes(ca) - sizeof(struct prio_set)) / + sizeof(struct bucket_disk); +} + +static inline size_t prio_buckets(const struct cache *ca) +{ + return DIV_ROUND_UP((size_t) (ca)->mi.nbuckets, prios_per_bucket(ca)); +} + void bch_cache_group_remove_cache(struct cache_group *, struct cache *); void bch_cache_group_add_cache(struct cache_group *, struct cache *); diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 36bcca3538b1..9a43a69af422 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -175,6 +175,7 @@ * - updates to non leaf nodes just happen synchronously (see btree_split()). */ +#undef pr_fmt #define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__ #include <linux/bug.h> @@ -190,6 +191,7 @@ #include <linux/rhashtable.h> #include <linux/rwsem.h> #include <linux/seqlock.h> +#include <linux/shrinker.h> #include <linux/types.h> #include <linux/workqueue.h> @@ -821,25 +823,9 @@ static inline unsigned bucket_bytes(const struct cache *ca) return ca->mi.bucket_size << 9; } -static inline unsigned block_bytes(struct cache_set *c) +static inline unsigned block_bytes(const struct cache_set *c) { return c->sb.block_size << 9; } -#define prios_per_bucket(ca) \ - ((bucket_bytes(ca) - sizeof(struct prio_set)) / \ - sizeof(struct bucket_disk)) -#define prio_buckets(ca) \ - DIV_ROUND_UP((size_t) (ca)->mi.nbuckets, prios_per_bucket(ca)) - -/* Forward declarations */ - -long bch_cache_set_ioctl(struct cache_set *, unsigned, void __user *); -long bch_chardev_ioctl(struct file *, unsigned, unsigned long); - -void bch_debug_exit(void); -int bch_debug_init(void); -void bch_fs_exit(void); -int bch_fs_init(void); - #endif /* _BCACHE_H */ diff --git a/drivers/md/bcache/bkey_methods.h b/drivers/md/bcache/bkey_methods.h index c4e80efb869a..0e305ebc02cb 100644 --- a/drivers/md/bcache/bkey_methods.h +++ b/drivers/md/bcache/bkey_methods.h @@ -1,6 +1,8 @@ #ifndef _BCACHE_BKEY_METHODS_H #define _BCACHE_BKEY_METHODS_H +#include "bkey.h" + #define DEF_BTREE_ID(kwd, val, name) BKEY_TYPE_##kwd = val, enum bkey_type { diff --git a/drivers/md/bcache/blockdev_types.h b/drivers/md/bcache/blockdev_types.h index 67dd4dec868b..3254917003d5 100644 --- a/drivers/md/bcache/blockdev_types.h +++ b/drivers/md/bcache/blockdev_types.h @@ -44,7 +44,7 @@ struct io { struct hlist_node hash; struct list_head lru; - unsigned long jiffies; + unsigned long last_io; unsigned sequential; sector_t last; }; diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index 94600a9a8e42..34880952ea41 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c @@ -1541,7 +1541,7 @@ void bch_btree_node_iter_init(struct btree_node_iter *iter, bool strictly_greater, bool is_extents) { struct bset_tree *t; - struct bkey_packed p, *packed_search; + struct bkey_packed p, *packed_search = NULL; EBUG_ON(bkey_cmp(search, b->data->min_key) < 0); bset_aux_tree_verify(b); diff --git a/drivers/md/bcache/btree_gc.c b/drivers/md/bcache/btree_gc.c index a00785189ffe..8417187561f4 100644 --- a/drivers/md/bcache/btree_gc.c +++ b/drivers/md/bcache/btree_gc.c @@ -25,7 +25,6 @@ #include <linux/freezer.h> #include <linux/kthread.h> #include <linux/rcupdate.h> -#include <linux/delay.h> #include <trace/events/bcache.h> struct range_checks { diff --git a/drivers/md/bcache/btree_types.h b/drivers/md/bcache/btree_types.h index 3632a04e517a..4e936cc09b06 100644 --- a/drivers/md/bcache/btree_types.h +++ b/drivers/md/bcache/btree_types.h @@ -2,6 +2,7 @@ #define _BCACHE_BTREE_TYPES_H #include <linux/bcache.h> +#include <linux/kernel.h> #include <linux/list.h> #include <linux/rhashtable.h> #include <linux/semaphore.h> diff --git a/drivers/md/bcache/buckets.c b/drivers/md/bcache/buckets.c index 1e617dbc61d8..3398b255053a 100644 --- a/drivers/md/bcache/buckets.c +++ b/drivers/md/bcache/buckets.c @@ -67,6 +67,7 @@ #include "btree_gc.h" #include "buckets.h" +#include <linux/preempt.h> #include <trace/events/bcache.h> #ifdef DEBUG_BUCKETS diff --git a/drivers/md/bcache/chardev.c b/drivers/md/bcache/chardev.c index f1874211e94b..0b020c84a050 100644 --- a/drivers/md/bcache/chardev.c +++ b/drivers/md/bcache/chardev.c @@ -302,7 +302,7 @@ long bch_cache_set_ioctl(struct cache_set *c, unsigned cmd, void __user *arg) } } -long bch_chardev_ioctl(struct file *filp, unsigned cmd, unsigned long v) +static long bch_chardev_ioctl(struct file *filp, unsigned cmd, unsigned long v) { struct cache_set *c = filp->private_data; void __user *arg = (void __user *) v; @@ -311,3 +311,9 @@ long bch_chardev_ioctl(struct file *filp, unsigned cmd, unsigned long v) ? bch_cache_set_ioctl(c, cmd, arg) : bch_global_ioctl(cmd, arg); } + +const struct file_operations bch_chardev_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = bch_chardev_ioctl, + .open = nonseekable_open, +}; diff --git a/drivers/md/bcache/chardev.h b/drivers/md/bcache/chardev.h new file mode 100644 index 000000000000..657bf2b1b164 --- /dev/null +++ b/drivers/md/bcache/chardev.h @@ -0,0 +1,7 @@ +#ifndef _BCACHE_CHARDEV_H +#define _BCACHE_CHARDEV_H + +long bch_cache_set_ioctl(struct cache_set *, unsigned, void __user *); +extern const struct file_operations bch_chardev_fops; + +#endif /* _BCACHE_CHARDEV_H */ diff --git a/drivers/md/bcache/checksum.h b/drivers/md/bcache/checksum.h index 740ddf691825..196b7e8c52ca 100644 --- a/drivers/md/bcache/checksum.h +++ b/drivers/md/bcache/checksum.h @@ -1,6 +1,8 @@ #ifndef _BCACHE_CHECKSUM_H #define _BCACHE_CHECKSUM_H +#include "btree_types.h" + u64 bch_crc64_update(u64, const void *, size_t); u64 bch_checksum_update(unsigned, u64, const void *, size_t); diff --git a/drivers/md/bcache/clock_types.h b/drivers/md/bcache/clock_types.h index 346466a9f987..4a02f4671603 100644 --- a/drivers/md/bcache/clock_types.h +++ b/drivers/md/bcache/clock_types.h @@ -1,6 +1,8 @@ #ifndef _BCACHE_CLOCK_TYPES_H #define _BCACHE_CLOCK_TYPES_H +#include "util.h" + #define NR_IO_TIMERS 8 /* diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c index 5705cc328499..f6f4dd99ba66 100644 --- a/drivers/md/bcache/closure.c +++ b/drivers/md/bcache/closure.c @@ -208,6 +208,3 @@ void __init closure_debug_init(void) } #endif - -MODULE_AUTHOR("Kent Overstreet <koverstreet@google.com>"); -MODULE_LICENSE("GPL"); diff --git a/drivers/md/bcache/debug.h b/drivers/md/bcache/debug.h index c8f3ae64bd7d..a3635e609436 100644 --- a/drivers/md/bcache/debug.h +++ b/drivers/md/bcache/debug.h @@ -59,4 +59,7 @@ static inline void bch_debug_exit_cache_set(struct cache_set *c) {} static inline void bch_debug_init_cache_set(struct cache_set *c) {} #endif +void bch_debug_exit(void); +int bch_debug_init(void); + #endif diff --git a/drivers/md/bcache/dirent.c b/drivers/md/bcache/dirent.c index b7fc5ca92f32..920ad2f7d263 100644 --- a/drivers/md/bcache/dirent.c +++ b/drivers/md/bcache/dirent.c @@ -8,6 +8,8 @@ #include "keylist.h" #include "str_hash.h" +#include <linux/dcache.h> + static unsigned dirent_name_bytes(struct bkey_s_c_dirent d) { unsigned len = bkey_val_bytes(d.k) - sizeof(struct bch_dirent); @@ -170,10 +172,9 @@ static struct bkey_i_dirent *dirent_create_key(u8 type, return dirent; } -int bch_dirent_create(struct inode *dir, u8 type, +int bch_dirent_create(struct cache_set *c, struct inode *dir, u8 type, const struct qstr *name, u64 dst_inum) { - struct cache_set *c = dir->i_sb->s_fs_info; struct bch_inode_info *ei = to_bch_ei(dir); struct bkey_i_dirent *dirent; int ret; @@ -345,9 +346,9 @@ err: return ret; } -int bch_dirent_delete(struct inode *dir, const struct qstr *name) +int bch_dirent_delete(struct cache_set *c, struct inode *dir, + const struct qstr *name) { - struct cache_set *c = dir->i_sb->s_fs_info; struct bch_inode_info *ei = to_bch_ei(dir); return bch_hash_delete(dirent_hash_desc, &ei->str_hash, @@ -355,9 +356,9 @@ int bch_dirent_delete(struct inode *dir, const struct qstr *name) &ei->journal_seq, name); } -u64 bch_dirent_lookup(struct inode *dir, const struct qstr *name) +u64 bch_dirent_lookup(struct cache_set *c, struct inode *dir, + const struct qstr *name) { - struct cache_set *c = dir->i_sb->s_fs_info; struct bch_inode_info *ei = to_bch_ei(dir); struct btree_iter iter; struct bkey_s_c k; @@ -396,11 +397,10 @@ int bch_empty_dir(struct cache_set *c, u64 dir_inum) return ret; } -int bch_readdir(struct file *file, struct dir_context *ctx) +int bch_readdir(struct cache_set *c, struct file *file, + struct dir_context *ctx) { struct inode *inode = file_inode(file); - struct super_block *sb = inode->i_sb; - struct cache_set *c = sb->s_fs_info; struct btree_iter iter; struct bkey_s_c k; struct bkey_s_c_dirent dirent; diff --git a/drivers/md/bcache/dirent.h b/drivers/md/bcache/dirent.h index d6597da2949b..e18089ba7243 100644 --- a/drivers/md/bcache/dirent.h +++ b/drivers/md/bcache/dirent.h @@ -8,8 +8,9 @@ struct file; struct dir_context; struct cache_set; -int bch_dirent_create(struct inode *, u8, const struct qstr *, u64); -int bch_dirent_delete(struct inode *, const struct qstr *); +int bch_dirent_create(struct cache_set *c, struct inode *, u8, + const struct qstr *, u64); +int bch_dirent_delete(struct cache_set *c, struct inode *, const struct qstr *); enum bch_rename_mode { BCH_RENAME, @@ -22,9 +23,10 @@ int bch_dirent_rename(struct cache_set *, struct inode *, const struct qstr *, u64 *, enum bch_rename_mode); -u64 bch_dirent_lookup(struct inode *, const struct qstr *); +u64 bch_dirent_lookup(struct cache_set *c, struct inode *, + const struct qstr *); int bch_empty_dir(struct cache_set *, u64); -int bch_readdir(struct file *, struct dir_context *); +int bch_readdir(struct cache_set *, struct file *, struct dir_context *); #endif /* _BCACHE_DIRENT_H */ diff --git a/drivers/md/bcache/extents.h b/drivers/md/bcache/extents.h index 2dc644680dbc..43aeeefac4a3 100644 --- a/drivers/md/bcache/extents.h +++ b/drivers/md/bcache/extents.h @@ -1,15 +1,15 @@ #ifndef _BCACHE_EXTENTS_H #define _BCACHE_EXTENTS_H +#include "bcache.h" #include "bkey.h" #include <linux/bcache.h> -struct bch_replace_info; -union bch_extent_crc; -struct btree_iter; +struct btree_node_iter; struct btree_insert; struct btree_insert_entry; +struct extent_insert_hook; struct btree_nr_keys bch_key_sort_fix_overlapping(struct bset *, struct btree *, diff --git a/drivers/md/bcache/fs.c b/drivers/md/bcache/fs.c index 5e07681b2612..1f01e48882df 100644 --- a/drivers/md/bcache/fs.c +++ b/drivers/md/bcache/fs.c @@ -3,6 +3,7 @@ #include "acl.h" #include "btree_update.h" #include "buckets.h" +#include "chardev.h" #include "dirent.h" #include "extents.h" #include "fs.h" @@ -271,7 +272,7 @@ static int bch_vfs_dirent_create(struct cache_set *c, struct inode *dir, { int ret; - ret = bch_dirent_create(dir, type, name, dst->i_ino); + ret = bch_dirent_create(c, dir, type, name, dst->i_ino); if (unlikely(ret)) return ret; @@ -315,10 +316,11 @@ static int __bch_create(struct inode *dir, struct dentry *dentry, static struct dentry *bch_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { + struct cache_set *c = dir->i_sb->s_fs_info; struct inode *inode = NULL; u64 inum; - inum = bch_dirent_lookup(dir, &dentry->d_name); + inum = bch_dirent_lookup(c, dir, &dentry->d_name); if (inum) inode = bch_vfs_inode_get(dir->i_sb, inum); @@ -372,7 +374,7 @@ static int bch_unlink(struct inode *dir, struct dentry *dentry) lockdep_assert_held(&inode->i_rwsem); - ret = bch_dirent_delete(dir, &dentry->d_name); + ret = bch_dirent_delete(c, dir, &dentry->d_name); if (ret) return ret; @@ -913,12 +915,22 @@ static long bch_compat_fs_ioctl(struct file *file, unsigned int cmd, unsigned lo } #endif +/* Directories: */ + static loff_t bch_dir_llseek(struct file *file, loff_t offset, int whence) { return generic_file_llseek_size(file, offset, whence, S64_MAX, S64_MAX); } +static int bch_vfs_readdir(struct file *file, struct dir_context *ctx) +{ + struct inode *inode = file_inode(file); + struct cache_set *c = inode->i_sb->s_fs_info; + + return bch_readdir(c, file, ctx); +} + static const struct file_operations bch_file_operations = { .llseek = bch_llseek, .read_iter = generic_file_read_iter, @@ -963,7 +975,7 @@ static const struct inode_operations bch_dir_inode_operations = { static const struct file_operations bch_dir_file_operations = { .llseek = bch_dir_llseek, .read = generic_read_dir, - .iterate = bch_readdir, + .iterate = bch_vfs_readdir, .fsync = bch_fsync, .unlocked_ioctl = bch_fs_ioctl, #ifdef CONFIG_COMPAT diff --git a/drivers/md/bcache/fs.h b/drivers/md/bcache/fs.h index e8f627c6ba45..c98202417fde 100644 --- a/drivers/md/bcache/fs.h +++ b/drivers/md/bcache/fs.h @@ -43,4 +43,7 @@ int __must_check __bch_write_inode(struct cache_set *, struct bch_inode_info *, int __must_check bch_write_inode(struct cache_set *, struct bch_inode_info *); +void bch_fs_exit(void); +int bch_fs_init(void); + #endif /* _BCACHE_FS_H */ diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 636f0e9231f3..ffc957368fc5 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -280,7 +280,7 @@ bch_journal_seq_blacklisted_new(struct journal *j, u64 seq) int bch_journal_seq_should_ignore(struct cache_set *c, u64 seq, struct btree *b) { struct journal *j = &c->journal; - struct journal_seq_blacklist *bl; + struct journal_seq_blacklist *bl = NULL; struct blacklisted_node *n; u64 journal_seq, i; int ret = 0; diff --git a/drivers/md/bcache/journal.h b/drivers/md/bcache/journal.h index e338ffe3fb56..759ed60961a7 100644 --- a/drivers/md/bcache/journal.h +++ b/drivers/md/bcache/journal.h @@ -108,6 +108,8 @@ * nodes that are pinning the oldest journal entries first. */ +#include <linux/hash.h> + #include "journal_types.h" static inline struct jset_entry *jset_keys_next(struct jset_entry *j) diff --git a/drivers/md/bcache/move.c b/drivers/md/bcache/move.c index fcc094d70887..f3ab9e8360d9 100644 --- a/drivers/md/bcache/move.c +++ b/drivers/md/bcache/move.c @@ -8,6 +8,8 @@ #include "super.h" #include "keylist.h" +#include <linux/ioprio.h> + #include <trace/events/bcache.h> static struct bch_extent_ptr *bkey_find_ptr(struct cache_set *c, @@ -198,7 +200,7 @@ static void moving_io_destructor(struct closure *cl) static void moving_error(struct moving_context *ctxt, unsigned flag) { atomic_inc(&ctxt->error_count); - atomic_or(flag, &ctxt->error_flags); + //atomic_or(flag, &ctxt->error_flags); } static void moving_io_after_write(struct closure *cl) diff --git a/drivers/md/bcache/opts.c b/drivers/md/bcache/opts.c index 249dd5d91a98..60a2a4d1a5ae 100644 --- a/drivers/md/bcache/opts.c +++ b/drivers/md/bcache/opts.c @@ -4,16 +4,6 @@ #include "opts.h" #include "util.h" -const char * const bch_bool_opt[] = { - "0", - "1", - NULL -}; - -const char * const bch_uint_opt[] = { - NULL -}; - const char * const bch_error_actions[] = { "continue", "remount-ro", @@ -43,6 +33,42 @@ const char * const bch_str_hash_types[] = { NULL }; +const char * const bch_cache_replacement_policies[] = { + "lru", + "fifo", + "random", + NULL +}; + +/* Default is -1; we skip past it for struct cached_dev's cache mode */ +const char * const bch_cache_modes[] = { + "default", + "writethrough", + "writeback", + "writearound", + "none", + NULL +}; + +const char * const bch_cache_state[] = { + "active", + "readonly", + "failed", + "spare", + NULL +}; + + +const char * const bch_bool_opt[] = { + "0", + "1", + NULL +}; + +const char * const bch_uint_opt[] = { + NULL +}; + enum bch_opts { #define CACHE_SET_OPT(_name, _choices, _min, _max, _sb_opt, _perm) \ Opt_##_name, diff --git a/drivers/md/bcache/opts.h b/drivers/md/bcache/opts.h index 1d19ac62915c..fe0de7ca0b6a 100644 --- a/drivers/md/bcache/opts.h +++ b/drivers/md/bcache/opts.h @@ -6,6 +6,14 @@ #include <linux/log2.h> #include <linux/string.h> +extern const char * const bch_error_actions[]; +extern const char * const bch_csum_types[]; +extern const char * const bch_compression_types[]; +extern const char * const bch_str_hash_types[]; +extern const char * const bch_cache_replacement_policies[]; +extern const char * const bch_cache_modes[]; +extern const char * const bch_cache_state[]; + /* * Mount options; we also store defaults in the superblock. * @@ -20,10 +28,6 @@ extern const char * const bch_bool_opt[]; extern const char * const bch_uint_opt[]; -extern const char * const bch_error_actions[]; -extern const char * const bch_csum_types[]; -extern const char * const bch_compression_types[]; -extern const char * const bch_str_hash_types[]; /* dummy option, for options that aren't stored in the superblock */ LE64_BITMASK(NO_SB_OPT, struct cache_sb, flags, 0, 0); diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 66bca3ee71da..b41d4720ad6c 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -134,7 +134,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio, int rw) hlist_for_each_entry(i, iohash(dc, bio->bi_iter.bi_sector), hash) if (i->last == bio->bi_iter.bi_sector && - time_before(jiffies, i->jiffies)) + time_before(jiffies, i->last_io)) goto found; i = list_first_entry(&dc->io_lru, struct io, lru); @@ -146,7 +146,7 @@ found: i->sequential += bio->bi_iter.bi_size; i->last = bio_end_sector(bio); - i->jiffies = jiffies + msecs_to_jiffies(5000); + i->last_io = jiffies + msecs_to_jiffies(5000); task->sequential_io = i->sequential; hlist_del(&i->hash); diff --git a/drivers/md/bcache/siphash.c b/drivers/md/bcache/siphash.c index 0c6f7f3ec819..5ba80b52b7c1 100644 --- a/drivers/md/bcache/siphash.c +++ b/drivers/md/bcache/siphash.c @@ -47,7 +47,7 @@ //#include <sys/systm.h> #include <asm/byteorder.h> -#include <asm/string.h> +#include <linux/string.h> #include "siphash.h" diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 71ab21ad876f..5f6a85e3c63a 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -13,11 +13,13 @@ #include "btree_gc.h" #include "btree_update.h" #include "btree_io.h" +#include "chardev.h" #include "checksum.h" #include "clock.h" #include "compress.h" #include "debug.h" #include "error.h" +#include "fs.h" #include "fs-gc.h" #include "inode.h" #include "io.h" @@ -942,19 +944,15 @@ static void cache_set_free(struct cache_set *c) void bch_cache_set_release(struct kobject *kobj) { struct cache_set *c = container_of(kobj, struct cache_set, kobj); - - /* - * This needs to happen after we've closed the block devices - i.e. - * after all the caches have exited, which happens when they all drop - * their refs on c->kobj: - */ - if (c->stop_completion) - complete(c->stop_completion); + struct completion *stop_completion = c->stop_completion; bch_notify_cache_set_stopped(c); bch_info(c, "stopped"); cache_set_free(c); + + if (stop_completion) + complete(stop_completion); } /* @@ -1264,7 +1262,7 @@ static const char *run_cache_set(struct cache_set *c) time64_t now; LIST_HEAD(journal); struct jset *j; - int ret; + int ret = -EINVAL; lockdep_assert_held(&bch_register_lock); BUG_ON(test_bit(CACHE_SET_RUNNING, &c->flags)); @@ -1692,9 +1690,6 @@ static void bch_cache_free_work(struct work_struct *work) free_super(&ca->disk_sb); - if (c) - kobject_put(&c->kobj); - /* * bch_cache_stop can be called in the middle of initialization * of the struct cache object. @@ -1719,6 +1714,9 @@ static void bch_cache_free_work(struct work_struct *work) free_fifo(&ca->free[i]); kobject_put(&ca->kobj); + + if (c) + kobject_put(&c->kobj); } static void bch_cache_percpu_ref_release(struct percpu_ref *ref) @@ -2448,12 +2446,6 @@ static void bcache_exit(void) unregister_reboot_notifier(&reboot); } -static const struct file_operations bch_chardev_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = bch_chardev_ioctl, - .open = nonseekable_open, -}; - static int __init bcache_init(void) { static const struct attribute *files[] = { diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 40d006b477ad..58a712594c66 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -24,31 +24,6 @@ #include <linux/blkdev.h> #include <linux/sort.h> -static const char * const cache_replacement_policies[] = { - "lru", - "fifo", - "random", - NULL -}; - -/* Default is -1; we skip past it for struct cached_dev's cache mode */ -static const char * const bch_cache_modes[] = { - "default", - "writethrough", - "writeback", - "writearound", - "none", - NULL -}; - -static const char * const bch_cache_state[] = { - "active", - "readonly", - "failed", - "spare", - NULL -}; - write_attribute(attach); write_attribute(detach); write_attribute(unregister); @@ -1237,7 +1212,7 @@ SHOW(bch_cache) if (attr == &sysfs_cache_replacement_policy) return bch_snprint_string_list(buf, PAGE_SIZE, - cache_replacement_policies, + bch_cache_replacement_policies, ca->mi.replacement); sysfs_print(tier, ca->mi.tier); @@ -1281,7 +1256,7 @@ STORE(__bch_cache) } if (attr == &sysfs_cache_replacement_policy) { - ssize_t v = bch_read_string_list(buf, cache_replacement_policies); + ssize_t v = bch_read_string_list(buf, bch_cache_replacement_policies); if (v < 0) return v; diff --git a/drivers/md/bcache/tier.c b/drivers/md/bcache/tier.c index b8516e8c6871..2b568e1f8c33 100644 --- a/drivers/md/bcache/tier.c +++ b/drivers/md/bcache/tier.c @@ -10,7 +10,6 @@ #include "move.h" #include "tier.h" -#include <linux/delay.h> #include <linux/freezer.h> #include <linux/kthread.h> #include <trace/events/bcache.h> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 1d21223a5f0e..5f8165935e56 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -77,7 +77,7 @@ STRTO_H(strtouint, unsigned int) STRTO_H(strtoll, long long) STRTO_H(strtoull, unsigned long long) -ssize_t bch_hprint(char *buf, int64_t v) +ssize_t bch_hprint(char *buf, s64 v) { static const char units[] = "?kMGTPEZY"; char dec[4] = ""; diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 115188f5c23b..2b171a13c8b6 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -8,6 +8,7 @@ #include <linux/kernel.h> #include <linux/llist.h> #include <linux/ratelimit.h> +#include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/workqueue.h> @@ -315,7 +316,7 @@ static inline int bch_strtoul_h(const char *cp, long *res) : type_is(var, char *) ? "%s\n" \ : "%i\n", var) -ssize_t bch_hprint(char *buf, int64_t v); +ssize_t bch_hprint(char *buf, s64 v); bool bch_is_zero(const void *, size_t); @@ -416,7 +417,7 @@ read_attribute(name ## _last_ ## frequency_units) struct bch_ratelimit { /* Next time we want to do some work, in nanoseconds */ - uint64_t next; + u64 next; /* * Rate at which we want to do work, in units per nanosecond diff --git a/drivers/md/bcache/xattr.c b/drivers/md/bcache/xattr.c index 002994eae758..e9e0a9a7512f 100644 --- a/drivers/md/bcache/xattr.c +++ b/drivers/md/bcache/xattr.c @@ -162,10 +162,9 @@ const struct bkey_ops bch_bkey_xattr_ops = { .val_to_text = bch_xattr_to_text, }; -int bch_xattr_get(struct inode *inode, const char *name, - void *buffer, size_t size, int type) +int bch_xattr_get(struct cache_set *c, struct inode *inode, + const char *name, void *buffer, size_t size, int type) { - struct cache_set *c = inode->i_sb->s_fs_info; struct bch_inode_info *ei = to_bch_ei(inode); struct btree_iter iter; struct bkey_s_c k; @@ -191,12 +190,11 @@ int bch_xattr_get(struct inode *inode, const char *name, return ret; } -int bch_xattr_set(struct inode *inode, const char *name, - const void *value, size_t size, +int bch_xattr_set(struct cache_set *c, struct inode *inode, + const char *name, const void *value, size_t size, int flags, int type) { struct bch_inode_info *ei = to_bch_ei(inode); - struct cache_set *c = inode->i_sb->s_fs_info; struct xattr_search_key search = X_SEARCH(type, name, strlen(name)); int ret; @@ -311,7 +309,9 @@ static int bch_xattr_get_handler(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size) { - return bch_xattr_get(inode, name, buffer, size, handler->flags); + struct cache_set *c = inode->i_sb->s_fs_info; + + return bch_xattr_get(c, inode, name, buffer, size, handler->flags); } static int bch_xattr_set_handler(const struct xattr_handler *handler, @@ -319,7 +319,9 @@ static int bch_xattr_set_handler(const struct xattr_handler *handler, const char *name, const void *value, size_t size, int flags) { - return bch_xattr_set(inode, name, value, size, flags, + struct cache_set *c = inode->i_sb->s_fs_info; + + return bch_xattr_set(c, inode, name, value, size, flags, handler->flags); } diff --git a/drivers/md/bcache/xattr.h b/drivers/md/bcache/xattr.h index 5e40f13fd11e..54eb920d0c39 100644 --- a/drivers/md/bcache/xattr.h +++ b/drivers/md/bcache/xattr.h @@ -6,8 +6,10 @@ extern const struct bkey_ops bch_bkey_xattr_ops; struct dentry; struct xattr_handler; -int bch_xattr_get(struct inode *, const char *, void *, size_t, int); -int bch_xattr_set(struct inode *, const char *, const void *, size_t, int, int); +int bch_xattr_get(struct cache_set *, struct inode *, + const char *, void *, size_t, int); +int bch_xattr_set(struct cache_set *, struct inode *, + const char *, const void *, size_t, int, int); ssize_t bch_xattr_list(struct dentry *, char *, size_t); extern const struct xattr_handler *bch_xattr_handlers[]; diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h index c794ce4879bd..f09a44a6c1b1 100644 --- a/include/uapi/linux/bcache.h +++ b/include/uapi/linux/bcache.h @@ -115,6 +115,8 @@ struct bkey { #elif defined (__BIG_ENDIAN_BITFIELD) __u8 needs_whiteout:1, format:7; +#else +#error edit for your odd byteorder. #endif /* Type of the value */ @@ -432,13 +434,15 @@ struct bch_extent_ptr { } __attribute__((packed, aligned(8))); union bch_extent_entry { -#if defined(__LITTLE_ENDIAN__) || BITS_PER_LONG == 64 +#if defined(__LITTLE_ENDIAN) || __BITS_PER_LONG == 64 unsigned long type; -#elif BITS_PER_LONG == 32 +#elif __BITS_PER_LONG == 32 struct { unsigned long pad; unsigned long type; }; +#else +#error edit for your odd byteorder. #endif struct bch_extent_crc32 crc32; struct bch_extent_crc64 crc64; @@ -668,6 +672,7 @@ LE64_BITMASK(CACHE_STATE, struct cache_member, f1, 0, 4) #define CACHE_RO 1U #define CACHE_FAILED 2U #define CACHE_SPARE 3U +#define CACHE_STATE_NR 4U LE64_BITMASK(CACHE_TIER, struct cache_member, f1, 4, 8) #define CACHE_TIERS 4U @@ -681,6 +686,7 @@ LE64_BITMASK(CACHE_REPLACEMENT, struct cache_member, f1, 26, 30) #define CACHE_REPLACEMENT_LRU 0U #define CACHE_REPLACEMENT_FIFO 1U #define CACHE_REPLACEMENT_RANDOM 2U +#define CACHE_REPLACEMENT_NR 3U LE64_BITMASK(CACHE_DISCARD, struct cache_member, f1, 30, 31); |