bcache: md conversion
Subsystems (5)
cover bcache: md conversion
The consensus from LSF was that bcache need not invent a new interface when md and dm can both do the job. As mentioned in patch 7 this series aims to be a minimal conversion. Other refactoring items like deprecating register_lock for mddev->reconfig_mutex are deferred.
This supports assembly of an already established cache array:
mdadm -A /dev/md/bcache /dev/sd[ab]
...will create the /dev/md/bcache container and a subarray representing the cache volume. "Flash-only", or backing-device only volumes were not tested. "Create" support and hot-add/hot-remove come later.
Note:
* When attempting to test with small loopback devices (100MB), assembly soft locks in bcache_journal_read(). That hang went away with larger devices, so there seems to be minimum component device size that needs to be considered in the tooling.
---
Dan Williams (7):
bcache: compile fix
bcache: disable lockdep, enable CONFIG_BCACHE=m
bcache: drop select COMPACTION
bcache: fix symlink removal
bcache: move to drivers/md/
bcache: uplevel allocation of 'cached_dev' and 'cache'
md: add bcache personality
drivers/block/Kconfig | 2
drivers/block/Makefile | 1
drivers/md/Kconfig | 14 +
drivers/md/Makefile | 1
drivers/md/bcache/Kconfig | 3
drivers/md/bcache/Makefile | 2
drivers/md/bcache/alloc.c | 0
drivers/md/bcache/bcache.h | 39 ++++
drivers/md/bcache/bset.c | 0
drivers/md/bcache/bset.h | 0
drivers/md/bcache/btree.c | 18 --
drivers/md/bcache/btree.h | 0
drivers/md/bcache/debug.c | 0
drivers/md/bcache/debug.h | 0
drivers/md/bcache/io.c | 0
drivers/md/bcache/journal.c | 0
drivers/md/bcache/journal.h | 0
drivers/md/bcache/md.c | 374 ++++++++++++++++++++++++++++++++++++
drivers/md/bcache/request.c | 24 +-
drivers/md/bcache/request.h | 0
drivers/md/bcache/stats.c | 0
drivers/md/bcache/stats.h | 0
drivers/md/bcache/super.c | 394 +++++++++-----------------------------
drivers/md/bcache/sysfs.c | 49 -----
drivers/md/bcache/sysfs.h | 0
drivers/md/bcache/trace.c | 0
drivers/md/bcache/util.c | 2
drivers/md/bcache/util.h | 3
drivers/md/bcache/writeback.c | 0
kernel/lockdep.c | 1
30 files changed, 539 insertions(+), 388 deletions(-)
rename drivers/{block/bcache/Kconfig => md/bcache/Kconfig} (95%)
rename drivers/{block/bcache/Makefile => md/bcache/Makefile} (77%)
rename drivers/{block/bcache/alloc.c => md/bcache/alloc.c} (100%)
rename drivers/{block/bcache/bcache.h => md/bcache/bcache.h} (94%)
rename drivers/{block/bcache/bset.c => md/bcache/bset.c} (100%)
rename drivers/{block/bcache/bset.h => md/bcache/bset.h} (100%)
rename drivers/{block/bcache/btree.c => md/bcache/btree.c} (99%)
rename drivers/{block/bcache/btree.h => md/bcache/btree.h} (100%)
rename drivers/{block/bcache/debug.c => md/bcache/debug.c} (100%)
rename drivers/{block/bcache/debug.h => md/bcache/debug.h} (100%)
rename drivers/{block/bcache/io.c => md/bcache/io.c} (100%)
rename drivers/{block/bcache/journal.c => md/bcache/journal.c} (100%)
rename drivers/{block/bcache/journal.h => md/bcache/journal.h} (100%)
create mode 100644 drivers/md/bcache/md.c
rename drivers/{block/bcache/request.c => md/bcache/request.c} (98%)
rename drivers/{block/bcache/request.h => md/bcache/request.h} (100%)
rename drivers/{block/bcache/stats.c => md/bcache/stats.c} (100%)
rename drivers/{block/bcache/stats.h => md/bcache/stats.h} (100%)
rename drivers/{block/bcache/super.c => md/bcache/super.c} (83%)
rename drivers/{block/bcache/sysfs.c => md/bcache/sysfs.c} (95%)
rename drivers/{block/bcache/sysfs.h => md/bcache/sysfs.h} (100%)
rename drivers/{block/bcache/trace.c => md/bcache/trace.c} (100%)
rename drivers/{block/bcache/util.c => md/bcache/util.c} (99%)
rename drivers/{block/bcache/util.h => md/bcache/util.h} (99%)
rename drivers/{block/bcache/writeback.c => md/bcache/writeback.c} (100%)A message that is not in the archive (sent off-list or not yet received): 20120511194327.25770.79292.stgit-p8uTFz9XbKgaePuBGzJMJzMJUdESFZ8XQQ4Iyu8u01E@public.gmane.org
RFC PATCH 1/7 bcache: compile fix
dynamic_fault bits have been removed.
--- drivers/block/bcache/util.c | 2 -- drivers/block/bcache/util.h | 3 --- 2 files changed, 5 deletions(-)
drivers/block/bcache/util.c +0 -2
@@ -6,8 +6,6 @@#include <linux/seq_file.h> #include <linux/types.h> -#include <linux/dynamic_fault.h> -#include "util.h" #define simple_strtoint (c, end, base) simple_strtol(c, end, base)
drivers/block/bcache/util.h +0 -3
@@ -597,9 +597,6 @@ unsigned __bio_max_sectors(struct bio *bio, struct block_device *bdev,int bio_alloc_pages (struct bio *bio,gfp_t gfp); -#define bio_alloc_pages (...) \ - (dynamic_fault() ? -ENOMEM : bio_alloc_pages(__VA_ARGS__)) -static inline unsigned bio_max_sectors (struct bio *bio) {return __bio_max_sectors (bio, bio->bi_bdev, bio->bi_sector);
RFC PATCH 2/7 bcache: disable lockdep, enable CONFIG_BCACHE=m
In reply to a message not in the archiveOf course checkpatch rightly complains:
ERROR: lockdep_no_validate class is reserved for device->mutex.
...so this is only hack for debugging.
Without this compiling as a module is not possible because the calls to __up_write() cause:
ERROR: "call_rwsem_wake" [drivers/block/bcache/bcache.ko] undefined!
...because __up_write is an internal rwsem detail.
lockdep_no_validate at least makes it explicit that lockdep support is a work-in-progress.
Not-signed-off-by... need a better workaround
--- drivers/block/bcache/btree.c | 18 ++++-------------- kernel/lockdep.c | 1 + 2 files changed, 5 insertions(+), 14 deletions(-)
drivers/block/bcache/btree.c +4 -14
@@ -538,6 +538,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c,return NULL ;init_rwsem (&b->lock); +lockdep_set_novalidate_class (&b->lock);INIT_LIST_HEAD (&b->list);INIT_DELAYED_WORK (&b->work, btree_write_work); b->c = c;
@@ -1116,9 +1117,7 @@ static struct btree *btree_gc_alloc(struct btree *b, struct bkey *k, b->prio_blocked++;btree_free (n, op); -__up_write (&n->lock); - -rwsem_release (&b->lock.dep_map,1 , _THIS_IP_); +up_write (&n->lock); }return b;
@@ -1218,7 +1217,7 @@ static void btree_gc_coalesce(struct btree *b, struct btree_op *op, }btree_free (r->b, op); -__up_write (&r->b->lock); +up_write (&r->b->lock);pr_debug ("coalesced %u nodes" , nodes);
@@ -1244,7 +1243,7 @@ static int btree_gc_recurse(struct btree *b, struct btree_op *op,btree_write (r, true,NULL ); } -__up_write (&r->lock); +up_write (&r->lock); }int ret =0 , stale;
@@ -1260,15 +1259,6 @@ static int btree_gc_recurse(struct btree *b, struct btree_op *op,break ; } -/* -* Fake out lockdep, because I'm a terrible person: it's just -* not possible to express our lock ordering to lockdep, because -* lockdep works at most in terms of a small fixed number of -* subclasses, and we're just iterating through all of them in a -* fixed order. -*/ -rwsem_release (&r->b->lock.dep_map,1 , _THIS_IP_); - r->keys =0 ; stale =btree_gc_mark (r->b, &r->keys, gc);
kernel/lockdep.c +1 -0
@@ -2997,6 +2997,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,EXPORT_SYMBOL_GPL (lockdep_init_map);struct lock_class_key __lockdep_no_validate__; +EXPORT_SYMBOL_GPL (__lockdep_no_validate__);/* * This gets called for every mutex_lock*()/spin_lock*() operation.
RFC PATCH 3/7 bcache: drop select COMPACTION
In reply to a message not in the archiveIt's not a build dependency, although it may be strongly recommended.
--- drivers/block/bcache/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/block/bcache/Kconfig +0 -1
@@ -1,7 +1,6 @@ config BCACHE tristate "Block device as cache" - select COMPACTION select CLOSURES ---help--- Allows a block device to be used as cache for other devices; uses
RFC PATCH 4/7 bcache: fix symlink removal
In reply to a message not in the archivesymlinks need to be removed prior to the kobject being deleted, otherwise we get:
WARNING: at fs/sysfs/inode.c:323 sysfs_hash_and_remove+0xa9/0xb0() Hardware name: Bochs sysfs: can not remove 'cache', no directory
--- drivers/block/bcache/super.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/block/bcache/super.c +9 -6
@@ -747,9 +747,6 @@ static void bcache_device_detach(struct bcache_device *d)atomic_set (&d->detaching,0 ); } -sysfs_remove_link (&d->c->kobj, d->name); -sysfs_remove_link (&d->kobj,"cache" ); - d->c->devices[d->id] =NULL ;closure_put (&d->c->caching); d->c =NULL ;
@@ -1049,10 +1046,13 @@ static void cached_dev_free(struct closure *cl)static void cached_dev_flush (struct closure *cl) { - struct cached_dev *d = container_of(cl, struct cached_dev, disk.cl); + struct cached_dev *cd = container_of(cl, struct cached_dev, disk.cl); +struct bcache_device *d = &cd->disk; -destroy_cache_accounting (&d->accounting); -kobject_del (&d->disk.kobj); +destroy_cache_accounting (&cd->accounting); +sysfs_remove_link (&d->kobj, d->name); +sysfs_remove_link (&d->kobj,"cache" ); +kobject_del (&d->kobj);continue_at (cl, cached_dev_free, system_wq); }
@@ -1175,6 +1175,9 @@ static void flash_dev_free(struct closure *cl)static void flash_dev_flush (struct closure *cl) { struct bcache_device *d = container_of(cl, struct bcache_device, cl); + +sysfs_remove_link (&d->c->kobj, d->name); +sysfs_remove_link (&d->kobj,"cache" );kobject_del (&d->kobj);continue_at (cl, flash_dev_free, system_wq); }
RFC PATCH 5/7 bcache: move to drivers/md/
In reply to a message not in the archiveThis is in preparation for being exposed as a md or dm device. The rationale is that userspace tooling already knows how to generically manipulate these composite block devices, so there is not much motivation to add new bcache-specific tooling.
As seen with raid there is precedent for md and dm to share a common personality backend and separate the frontend virtual block device presentation.
---
drivers/block/Kconfig | 2 --
drivers/block/Makefile | 1 -
drivers/md/Kconfig | 2 ++
drivers/md/Makefile | 1 +
drivers/md/bcache/Kconfig | 0
drivers/md/bcache/Makefile | 0
drivers/md/bcache/alloc.c | 0
drivers/md/bcache/bcache.h | 0
drivers/md/bcache/bset.c | 0
drivers/md/bcache/bset.h | 0
drivers/md/bcache/btree.c | 0
drivers/md/bcache/btree.h | 0
drivers/md/bcache/debug.c | 0
drivers/md/bcache/debug.h | 0
drivers/md/bcache/io.c | 0
drivers/md/bcache/journal.c | 0
drivers/md/bcache/journal.h | 0
drivers/md/bcache/request.c | 0
drivers/md/bcache/request.h | 0
drivers/md/bcache/stats.c | 0
drivers/md/bcache/stats.h | 0
drivers/md/bcache/super.c | 0
drivers/md/bcache/sysfs.c | 0
drivers/md/bcache/sysfs.h | 0
drivers/md/bcache/trace.c | 0
drivers/md/bcache/util.c | 0
drivers/md/bcache/util.h | 0
drivers/md/bcache/writeback.c | 0
28 files changed, 3 insertions(+), 3 deletions(-)
rename drivers/{block/bcache/Kconfig => md/bcache/Kconfig} (100%)
rename drivers/{block/bcache/Makefile => md/bcache/Makefile} (100%)
rename drivers/{block/bcache/alloc.c => md/bcache/alloc.c} (100%)
rename drivers/{block/bcache/bcache.h => md/bcache/bcache.h} (100%)
rename drivers/{block/bcache/bset.c => md/bcache/bset.c} (100%)
rename drivers/{block/bcache/bset.h => md/bcache/bset.h} (100%)
rename drivers/{block/bcache/btree.c => md/bcache/btree.c} (100%)
rename drivers/{block/bcache/btree.h => md/bcache/btree.h} (100%)
rename drivers/{block/bcache/debug.c => md/bcache/debug.c} (100%)
rename drivers/{block/bcache/debug.h => md/bcache/debug.h} (100%)
rename drivers/{block/bcache/io.c => md/bcache/io.c} (100%)
rename drivers/{block/bcache/journal.c => md/bcache/journal.c} (100%)
rename drivers/{block/bcache/journal.h => md/bcache/journal.h} (100%)
rename drivers/{block/bcache/request.c => md/bcache/request.c} (100%)
rename drivers/{block/bcache/request.h => md/bcache/request.h} (100%)
rename drivers/{block/bcache/stats.c => md/bcache/stats.c} (100%)
rename drivers/{block/bcache/stats.h => md/bcache/stats.h} (100%)
rename drivers/{block/bcache/super.c => md/bcache/super.c} (100%)
rename drivers/{block/bcache/sysfs.c => md/bcache/sysfs.c} (100%)
rename drivers/{block/bcache/sysfs.h => md/bcache/sysfs.h} (100%)
rename drivers/{block/bcache/trace.c => md/bcache/trace.c} (100%)
rename drivers/{block/bcache/util.c => md/bcache/util.c} (100%)
rename drivers/{block/bcache/util.h => md/bcache/util.h} (100%)
rename drivers/{block/bcache/writeback.c => md/bcache/writeback.c} (100%)drivers/block/Kconfig +0 -2
@@ -526,8 +526,6 @@ config VIRTIO_BLK This is the virtual block driver for virtio. It can be used with lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. -source "drivers/block/bcache/Kconfig" - config BLK_DEV_HD bool "Very old hard disk (MFM/RLL/IDE) driver" depends on HAVE_IDE
drivers/block/Makefile +0 -1
@@ -41,6 +41,5 @@ obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/ obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ obj-$(CONFIG_BLK_DEV_RBD) += rbd.o obj-$(CONFIG_BLK_DEV_PCIESSD_MTIP32XX) += mtip32xx/ -obj-$(CONFIG_BCACHE) += bcache/ swim_mod-y := swim.o swim_asm.o
drivers/md/Kconfig +2 -0
@@ -185,6 +185,8 @@ config MD_FAULTY In unsure, say N. +source "drivers/md/bcache/Kconfig" + config BLK_DEV_DM tristate "Device mapper support" ---help---
drivers/md/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_MD_RAID10) += raid10.o obj-$(CONFIG_MD_RAID456) += raid456.o obj-$(CONFIG_MD_MULTIPATH) += multipath.o obj-$(CONFIG_MD_FAULTY) += faulty.o +obj-$(CONFIG_BCACHE) += bcache/ obj-$(CONFIG_BLK_DEV_MD) += md-mod.o obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o obj-$(CONFIG_DM_BUFIO) += dm-bufio.o
drivers/md/bcache/Kconfig renamed from drivers/block/bcache/Kconfig +0 -0
drivers/md/bcache/Makefile renamed from drivers/block/bcache/Makefile +0 -0
drivers/md/bcache/alloc.c renamed from drivers/block/bcache/alloc.c +0 -0
drivers/md/bcache/bcache.h renamed from drivers/block/bcache/bcache.h +0 -0
drivers/md/bcache/bset.c renamed from drivers/block/bcache/bset.c +0 -0
drivers/md/bcache/bset.h renamed from drivers/block/bcache/bset.h +0 -0
drivers/md/bcache/btree.c renamed from drivers/block/bcache/btree.c +0 -0
drivers/md/bcache/btree.h renamed from drivers/block/bcache/btree.h +0 -0
drivers/md/bcache/debug.c renamed from drivers/block/bcache/debug.c +0 -0
drivers/md/bcache/debug.h renamed from drivers/block/bcache/debug.h +0 -0
drivers/md/bcache/io.c renamed from drivers/block/bcache/io.c +0 -0
drivers/md/bcache/journal.c renamed from drivers/block/bcache/journal.c +0 -0
drivers/md/bcache/journal.h renamed from drivers/block/bcache/journal.h +0 -0
drivers/md/bcache/request.c renamed from drivers/block/bcache/request.c +0 -0
drivers/md/bcache/request.h renamed from drivers/block/bcache/request.h +0 -0
drivers/md/bcache/stats.c renamed from drivers/block/bcache/stats.c +0 -0
drivers/md/bcache/stats.h renamed from drivers/block/bcache/stats.h +0 -0
drivers/md/bcache/super.c renamed from drivers/block/bcache/super.c +0 -0
drivers/md/bcache/sysfs.c renamed from drivers/block/bcache/sysfs.c +0 -0
drivers/md/bcache/sysfs.h renamed from drivers/block/bcache/sysfs.h +0 -0
drivers/md/bcache/trace.c renamed from drivers/block/bcache/trace.c +0 -0
drivers/md/bcache/util.c renamed from drivers/block/bcache/util.c +0 -0
drivers/md/bcache/util.h renamed from drivers/block/bcache/util.h +0 -0
drivers/md/bcache/writeback.c renamed from drivers/block/bcache/writeback.c +0 -0
RFC PATCH 6/7 bcache: uplevel allocation of 'cached_dev' and 'cache'
In reply to a message not in the archiveThis is prepartion to enable a container_of() relationship between these and a 'rdev' for the md conversion (or a dm_dev for an eventual dm skin).
--- drivers/md/bcache/super.c | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/md/bcache/super.c +24 -22
@@ -1057,11 +1057,9 @@ static void cached_dev_flush(struct closure *cl)continue_at (cl, cached_dev_free, system_wq); } -static struct cached_dev *cached_dev_alloc (unsigned block_size) +static int cached_dev_init (struct cached_dev *d,unsigned block_size) { -struct cached_dev *d =kzalloc (sizeof (struct cached_dev ),GFP_KERNEL ); -if (!d) -return NULL ; +int err;closure_init (&d->disk.cl,NULL );set_closure_fn (&d->disk.cl, cached_dev_flush, system_wq);
@@ -1093,29 +1091,28 @@ static struct cached_dev *cached_dev_alloc(unsigned block_size)bcache_writeback_init_cached_dev (d); + err = -ENOMEM ; d->bio_passthrough =mempool_create_slab_pool (32 , passthrough_cache);if (!d->bio_passthrough) goto err; -return d; +return 0 ; err:bcache_device_stop (&d->disk); -return NULL ; +return err; }/* Cached device - bcache superblock */ static const char *register_bdev (struct cache_sb *sb,struct page *sb_page, -struct block_device *bdev) +struct block_device *bdev,struct cached_dev *d) {char name[BDEVNAME_SIZE ];const char *err ="cannot allocate memory" ;struct gendisk *g;struct cache_set *c; -struct cached_dev *d =cached_dev_alloc (sb->block_size <<9 ); - -if (!d) +if (!d ||cached_dev_init (d, sb->block_size <<9 ) !=0 )return err;memcpy (&d->sb, sb,sizeof (struct cache_sb ));
@@ -1729,13 +1726,13 @@ static void cache_free(struct kobject *kobj)module_put (THIS_MODULE ); } -static struct cache *cache_alloc (struct cache_sb *sb) +static int cache_alloc (struct cache_sb *sb,struct cache *c) {size_t free;struct bucket *b; -struct cache *c =kzalloc (sizeof (struct cache ),GFP_KERNEL ); +if (!c) -return NULL ; +return -ENOMEM ;__module_get (THIS_MODULE );cache_kobject_init (c);
@@ -1779,19 +1776,19 @@ static struct cache *cache_alloc(struct cache_sb *sb)if (alloc_discards (c)) goto err; -return c; +return 0 ; err:kobject_put (&c->kobj); -return NULL ; +return -ENOMEM ; }static const char *register_cache (struct cache_sb *sb,struct page *sb_page, -struct block_device *bdev) +struct block_device *bdev,struct cache *c) {char name[BDEVNAME_SIZE ];const char *err ="cannot allocate memory" ; -struct cache *c =cache_alloc (sb); -if (!c) + +if (cache_alloc (sb, c) !=0 )return err; c->sb_bio.bi_io_vec[0 ].bv_page = sb_page;
@@ -1867,10 +1864,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,if (err) goto err_close; -if (sb->version ==CACHE_BACKING_DEV ) - err =register_bdev (sb, sb_page, bdev); -else - err =register_cache (sb, sb_page, bdev); +if (sb->version ==CACHE_BACKING_DEV ) { +struct cached_dev *d =kzalloc (sizeof (*d),GFP_KERNEL ); + + err =register_bdev (sb, sb_page, bdev, d); + }else { +struct cache *c =kzalloc (sizeof (*c),GFP_KERNEL ); + + err =register_cache (sb, sb_page, bdev, c); + }if (err) {/* register_(bdev|cache) will only return an error if they
RFC PATCH 7/7 md: add bcache personality
In reply to a message not in the archiveExpose bcache as a md personality. Since bcache already depends on userpsace assembly, allow it to borrow all the discovery and assembly mechanisms that have grown up around mdadm. Userpace requests raid-level "bcache", or "11" (0xb), when starting an array. "Backing device" vs "cache device" is determined by slot number whereby the backing device slot is the highest number index.
This attempts to be a minimal conversion, but reconciling the gendisk and kobject relationships with md contributed to the bulk of the thrash. The removal of the balance of the duplicated functionality comes later. Also note that functionality like flash-only volume creation and flash-only resize are temporarily removed until they can be re-implemented via the upper layer (md or dm). Another todo item is detaching devices from cache sets via md hot disk add/remove.
The sysfs topology is easier to navigate now. The bcache attributes no longer pop up up under individual block devices. Instead bcache membership of an individual block device can be determined the same as raid membership, i.e. by following:
/sys/block/<blockdev>/holders/<mddev>
From there the layout is:
/sys/block/<mddev>/md/bcache : cache set attributes /sys/block/<mddev>/md/rd[0..N-1]/bcache : cache device device attributes /sys/block/<mddev>/md/rdN/bcache : backing device attributes
Global listing of all bcache volumes available via /proc/mdstat or /sys/block/*/md/bcache (rather than /sys/fs/bcache).
--- drivers/md/Kconfig | 12 + drivers/md/bcache/Kconfig | 2 drivers/md/bcache/Makefile | 2 drivers/md/bcache/bcache.h | 39 ++++ drivers/md/bcache/md.c | 374 +++++++++++++++++++++++++++++++++++++++++++ drivers/md/bcache/request.c | 24 +-- drivers/md/bcache/super.c | 359 +++++++++-------------------------------- drivers/md/bcache/sysfs.c | 49 ------ 8 files changed, 511 insertions(+), 350 deletions(-) create mode 100644 drivers/md/bcache/md.c
drivers/md/Kconfig +12 -0
@@ -185,6 +185,18 @@ config MD_FAULTY In unsure, say N. +config MD_BCACHE + tristate "Caching mode for MD" + depends on BLK_DEV_MD + select BCACHE + help + The "md_bcache" module allows for an md device that + establishes a cache hierarchy of high iops and/or bandwidth + block device(s) to a slower block device. Assembly of arrays + of this personality require userspace assistance, i.e. arrays + with this format are treated as "external" metadata, see + MDADM(8) + source "drivers/md/bcache/Kconfig" config BLK_DEV_DM
drivers/md/bcache/Kconfig +1 -1
@@ -1,6 +1,6 @@ config BCACHE - tristate "Block device as cache" + tristate select CLOSURES ---help--- Allows a block device to be used as cache for other devices; uses
drivers/md/bcache/Makefile +2 -0
@@ -1,8 +1,10 @@ ccflags-y += -std=gnu99 obj-$(CONFIG_BCACHE) += bcache.o +obj-$(CONFIG_MD_BCACHE) += md_bcache.o bcache-y := alloc.o btree.o bset.o io.o journal.o\ writeback.o request.o super.o debug.o util.o trace.o stats.o +md_bcache-y := md.o CFLAGS_request.o += -Iblock
drivers/md/bcache/bcache.h +39 -0
@@ -1,5 +1,7 @@ +#ifndef pr_fmt#define pr_fmt (fmt) "bcache: %s() " fmt "\n", __func__ +#endif #include <linux/bio.h> #include <linux/blktrace_api.h>
@@ -297,6 +299,7 @@ struct cached_dev {unsigned writeback_rate_d_term;unsigned writeback_rate_p_term_inverse;unsigned writeback_rate_d_smooth; +void (*release)(struct cached_dev *); };struct cache {
@@ -375,6 +378,7 @@ struct cache {atomic_long_t meta_sectors_written;atomic_long_t btree_sectors_written;atomic_long_t sectors_written; +void (*release)(struct cache *); };struct gc_stat {
@@ -387,6 +391,26 @@ struct gc_stat {unsigned in_use;/* percent */ }; +struct uuid_entry { +union { +struct { +uint8_t uuid[16 ]; +uint8_t label[32 ]; +uint32_t first_reg; +uint32_t last_reg; +uint32_t invalidated; + +uint32_t flags; +/* Size of flash only volumes */ +uint64_t sectors; + }; + +uint8_t pad[128 ]; + }; +}; + +BITMASK(UUID_FLASH_ONLY, struct uuid_entry, flags, 0, 1); +struct cache_set {struct closure cl;
@@ -837,3 +861,18 @@ void bcache_request_exit(void);int bcache_request_init (void );void bcache_btree_exit (void );int bcache_btree_init (void ); + +int bcache_flash_dev_run (struct cache_set *,struct uuid_entry *,struct bcache_device *); +const char *bcache_register_cache (struct cache_sb *,struct page *,struct block_device *, +struct kobject *,struct cache *,struct kobject *); +const char *bcache_register_bdev (struct cache_sb *,struct page *,struct block_device *, +struct kobject *,struct cached_dev *); +const char *bcache_read_super (struct cache_sb *,struct block_device *,struct page **); +void bcache_cached_dev_make_request (struct bcache_device *d,struct bio *bio); +void bcache_flash_dev_make_request (struct bcache_device *d,struct bio *bio); +int bcache_cached_dev_attach (struct cached_dev *d,struct cache_set *c); +int bcache_cached_dev_congested (void *data,int bits); +int bcache_flash_dev_congested (void *data,int bits); +void bcache_cached_dev_run (struct cached_dev *); +void bcache_device_stop (struct bcache_device *); +void bcache_cache_set_stop (struct cache_set *);
drivers/md/bcache/md.c new file +374 -0
374 lines not on this page · raw message
drivers/md/bcache/request.c +9 -15
@@ -1228,11 +1228,10 @@ skip: s->skip = true; } -static void cached_dev_make_request (struct request_queue *q,struct bio *bio) +void bcache_cached_dev_make_request (struct bcache_device *d,struct bio *bio) { -struct search *s; -struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; struct cached_dev *dc = container_of(d, struct cached_dev, disk); +struct search *s; bio->bi_bdev = dc->bdev; bio->bi_sector +=16 ;
@@ -1247,6 +1246,7 @@ static void cached_dev_make_request(struct request_queue *q, struct bio *bio) }else bio_passthrough (dc, bio); } +EXPORT_SYMBOL_GPL (bcache_cached_dev_make_request);static int cached_dev_ioctl (struct bcache_device *d,fmode_t mode,unsigned int cmd,unsigned long arg)
@@ -1255,7 +1255,7 @@ static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode,return __blkdev_driver_ioctl (dc->bdev, mode, cmd, arg); } -static int cached_dev_congested (void *data,int bits) +int bcache_cached_dev_congested (void *data,int bits) {struct bcache_device *d = data; struct cached_dev *dc = container_of(d, struct cached_dev, disk);
@@ -1278,13 +1278,10 @@ static int cached_dev_congested(void *data, int bits)return ret; } +EXPORT_SYMBOL_GPL (bcache_cached_dev_congested);void cached_dev_request_init (struct cached_dev *d) { -struct gendisk *g = d->disk.disk; - - g->queue->make_request_fn = cached_dev_make_request; - g->queue->backing_dev_info.congested_fn = cached_dev_congested; d->disk.cache_miss = cached_dev_cache_miss; d->disk.ioctl = cached_dev_ioctl; }
@@ -1398,10 +1395,9 @@ static void flash_dev_req_nodata(struct search *s)continue_at (&s->cl, flash_dev_bio_complete,NULL ); } -static void flash_dev_make_request (struct request_queue *q,struct bio *bio) +void bcache_flash_dev_make_request (struct bcache_device *d,struct bio *bio) {struct search *s; -struct bcache_device *d = bio->bi_bdev->bd_disk->private_data; s =do_bio_hook (bio, d);trace_bcache_request_start (&s->op, bio);
@@ -1410,6 +1406,7 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio) bio->bi_rw &REQ_WRITE ? flash_dev_write : flash_dev_read)(s); } +EXPORT_SYMBOL_GPL (bcache_flash_dev_make_request);static int flash_dev_ioctl (struct bcache_device *d,fmode_t mode,unsigned int cmd,unsigned long arg)
@@ -1417,7 +1414,7 @@ static int flash_dev_ioctl(struct bcache_device *d, fmode_t mode,return -ENOTTY ; } -static int flash_dev_congested (void *data,int bits) +int bcache_flash_dev_congested (void *data,int bits) {struct bcache_device *d = data;struct request_queue *q;
@@ -1431,13 +1428,10 @@ static int flash_dev_congested(void *data, int bits)return ret; } +EXPORT_SYMBOL_GPL (bcache_flash_dev_congested);void flash_dev_request_init (struct bcache_device *d) { -struct gendisk *g = d->disk; - - g->queue->make_request_fn = flash_dev_make_request; - g->queue->backing_dev_info.congested_fn = flash_dev_congested; d->cache_miss = flash_dev_cache_miss; d->ioctl = flash_dev_ioctl; }
drivers/md/bcache/super.c +74 -285
652 lines not on this page · raw message
drivers/md/bcache/sysfs.c +0 -49
118 lines not on this page · raw message
Re: [RFC PATCH 7/7] md: add bcache personality
Quoted 3 lines · Dan Williams
"Backing
device" vs "cache device" is determined by slot number whereby the backing device slot is the highest number index.
That needs fixing. We used to do things by slot number long ago, and it turned out to create lots of races on reconfiguring slot indexes and moving devices around on rebuilds and stuff like that. I would have to see us undo that fix when it comes to bcache.
Signature · 6 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD http://people.redhat.com/dledford Infiniband specific RPMs available at http://people.redhat.com/dledford/Infiniband
Re: [RFC PATCH 7/7] md: add bcache personality
Quoted 9 lines · Doug Ledford
Quoted 3 lines · Dan Williams
"Backing
device" vs "cache device" is determined by slot number whereby the backing device slot is the highest number index.That needs fixing. We used to do things by slot number long ago, and it turned out to create lots of races on reconfiguring slot indexes and moving devices around on rebuilds and stuff like that. I would have to see us undo that fix when it comes to bcache.
Yeah, that hack should be easy to remove and userspace can look at the sysfs attributes to determine the device's role.
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 83 lines · Dan Williams
The consensus from LSF was that bcache need not invent a new interface when md and dm can both do the job. As mentioned in patch 7 this series aims to be a minimal conversion. Other refactoring items like deprecating
register_lockformddev->reconfig_mutexare deferred.This supports assembly of an already established cache array:
mdadm -A
/dev/md/bcache/dev/sd[ab]...will create the
/dev/md/bcachecontainer and a subarray representing the cache volume. "Flash-only", or backing-device only volumes were not tested. "Create" support and hot-add/hot-remove come later.Note:
* When attempting to test with small loopback devices (100MB), assembly soft locks inbcache_journal_read(). That hang went away with larger devices, so there seems to be minimum component device size that needs to be considered in the tooling.---
Dan Williams (7):
bcache: compile fix
bcache: disable lockdep, enableCONFIG_BCACHE=m
bcache: drop select COMPACTION
bcache: fix symlink removal
bcache: move todrivers/md/
bcache: uplevel allocation of 'cached_dev' and 'cache'
md: add bcache personalitydrivers/block/Kconfig | 2
drivers/block/Makefile | 1
drivers/md/Kconfig | 14 +
drivers/md/Makefile | 1
drivers/md/bcache/Kconfig | 3
drivers/md/bcache/Makefile | 2
drivers/md/bcache/alloc.c | 0
drivers/md/bcache/bcache.h | 39 ++++drivers/md/bcache/bset.c | 0 drivers/md/bcache/bset.h | 0 drivers/md/bcache/btree.c | 18 -- drivers/md/bcache/btree.h | 0 drivers/md/bcache/debug.c | 0 drivers/md/bcache/debug.h | 0drivers/md/bcache/io.c | 0
drivers/md/bcache/journal.c| 0drivers/md/bcache/journal.h| 0
drivers/md/bcache/md.c | 374 ++++++++++++++++++++++++++++++++++++drivers/md/bcache/request.c| 24 +-drivers/md/bcache/request.h| 0drivers/md/bcache/stats.c | 0 drivers/md/bcache/stats.h | 0 drivers/md/bcache/super.c | 394 +++++++++----------------------------- drivers/md/bcache/sysfs.c | 49 ----- drivers/md/bcache/sysfs.h | 0 drivers/md/bcache/trace.c | 0 drivers/md/bcache/util.c | 2 drivers/md/bcache/util.h | 3 drivers/md/bcache/writeback.c | 0 kernel/lockdep.c | 1 30 files changed, 539 insertions(+), 388 deletions(-)rename
drivers/{block/bcache/Kconfig=> md/bcache/Kconfig} (95%) renamedrivers/{block/bcache/Makefile=> md/bcache/Makefile} (77%) renamedrivers/{block/bcache/alloc.c=>md/bcache/alloc.c} (100%) renamedrivers/{block/bcache/bcache.h=>md/bcache/bcache.h} (94%) renamedrivers/{block/bcache/bset.c=>md/bcache/bset.c} (100%) renamedrivers/{block/bcache/bset.h=>md/bcache/bset.h} (100%) renamedrivers/{block/bcache/btree.c=>md/bcache/btree.c} (99%) renamedrivers/{block/bcache/btree.h=>md/bcache/btree.h} (100%) renamedrivers/{block/bcache/debug.c=>md/bcache/debug.c} (100%) renamedrivers/{block/bcache/debug.h=>md/bcache/debug.h} (100%) renamedrivers/{block/bcache/io.c=>md/bcache/io.c} (100%) renamedrivers/{block/bcache/journal.c=>md/bcache/journal.c} (100%) renamedrivers/{block/bcache/journal.h=>md/bcache/journal.h} (100%) create mode 100644drivers/md/bcache/md.c
renamedrivers/{block/bcache/request.c=>md/bcache/request.c} (98%) renamedrivers/{block/bcache/request.h=>md/bcache/request.h} (100%) renamedrivers/{block/bcache/stats.c=>md/bcache/stats.c} (100%) renamedrivers/{block/bcache/stats.h=>md/bcache/stats.h} (100%) renamedrivers/{block/bcache/super.c=>md/bcache/super.c} (83%) renamedrivers/{block/bcache/sysfs.c=>md/bcache/sysfs.c} (95%) renamedrivers/{block/bcache/sysfs.h=>md/bcache/sysfs.h} (100%)
Quoted 8 lines
rename
drivers/{block/bcache/trace.c=>md/bcache/trace.c} (100%) renamedrivers/{block/bcache/util.c=>md/bcache/util.c} (99%) renamedrivers/{block/bcache/util.h=>md/bcache/util.h} (99%) renamedrivers/{block/bcache/writeback.c=>md/bcache/writeback.c} (100%) --
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
This is very interesting,
I will play around with these this weekend. :)
Joseph.
Signature · 3 lines
Founder | Director | VP Research Orion Virtualisation Solutions | www.orionvm.com.au | Phone: 1300 56 99 52 | Mobile: 0428 754 846
Quoted 4 lines · Dan Williams
The consensus from LSF was that bcache need not invent a new interface when md and dm can both do the job. As mentioned in patch 7 this series aims to be a minimal conversion. Other refactoring items like deprecating
register_lockformddev->reconfig_mutexare deferred.
Awesome! I just applied the first 6 - the lockdep fix especially was exactly what I'd been looking for. I need to dig in to the patch that does the actual md conversion more and play with it... also need to look at how refcounting works.
Quoted 8 lines
This supports assembly of an already established cache array:
mdadm -A
/dev/md/bcache/dev/sd[ab]...will create the
/dev/md/bcachecontainer and a subarray representing the cache volume. "Flash-only", or backing-device only volumes were not tested. "Create" support and hot-add/hot-remove come later.
Quoted 5 lines
Note:
* When attempting to test with small loopback devices (100MB), assembly soft locks inbcache_journal_read(). That hang went away with larger devices, so there seems to be minimum component device size that needs to be considered in the tooling.
Curious. I normally use a 256 mb cache for vm testing and I haven't seen anything like that in ages, wonder what you found. Will investigate.
Quoted 13 lines · Dan Williams
The consensus from LSF was that bcache need not invent a new interface when md and dm can both do the job. As mentioned in patch 7 this series aims to be a minimal conversion. Other refactoring items like deprecating
register_lockformddev->reconfig_mutexare deferred.This supports assembly of an already established cache array:
mdadm -A
/dev/md/bcache/dev/sd[ab]...will create the
/dev/md/bcachecontainer and a subarray representing the cache volume. "Flash-only", or backing-device only volumes were not tested. "Create" support and hot-add/hot-remove come later.
Quoted 5 lines
Note:
* When attempting to test with small loopback devices (100MB), assembly soft locks inbcache_journal_read(). That hang went away with larger devices, so there seems to be minimum component device size that needs to be considered in the tooling.
Is there any plan to separate the on-disk layout (per-device headers, etc) from the logic for the purpose of reuse? I can think of at least one case where this would be extremely useful: integration in BtrFS.
BtrFS already has its own methods for making sure a group of devices are all present when the filesystem is mounted, so it doesn't really need the formatting of the backing device bcache does to prevent it from being mounted solo. Putting bcache under BtrFS would be silly in the same way as putting it under a raid array, but bcache can't be put on top of BtrFS.
Logically, in looking at BtrFS' architecture, a cache would likely fit best at the 'block group' level, which IIUC would be roughly equivalent to the recommended 'over raid, under lvm' method of using bcache.