diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-21 21:19:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-21 21:19:38 -0500 |
commit | 641203549a21ba6a701aecd05c3dfc969ec670cc (patch) | |
tree | 5e3d177c380ed811b5bf37e0bf9b8098416a9bc6 /drivers/md/bcache | |
parent | 404a47410c26a115123885977053e9a1a4460929 (diff) | |
parent | e93d12ae3be91d18b2a46deebb90a3f516db3d3c (diff) |
Merge branch 'for-4.5/drivers' of git://git.kernel.dk/linux-block
Pull block driver updates from Jens Axboe:
"This is the block driver pull request for 4.5, with the exception of
NVMe, which is in a separate branch and will be posted after this one.
This pull request contains:
- A set of bcache stability fixes, which have been acked by Kent.
These have been used and tested for more than a year by the
community, so it's about time that they got in.
- A set of drbd updates from the drbd team (Andreas, Lars, Philipp)
and Markus Elfring, Oleg Drokin.
- A set of fixes for xen blkback/front from the usual suspects, (Bob,
Konrad) as well as community based fixes from Kiri, Julien, and
Peng.
- A 2038 time fix for sx8 from Shraddha, with a fix from me.
- A small mtip32xx cleanup from Zhu Yanjun.
- A null_blk division fix from Arnd"
* 'for-4.5/drivers' of git://git.kernel.dk/linux-block: (71 commits)
null_blk: use sector_div instead of do_div
mtip32xx: restrict variables visible in current code module
xen/blkfront: Fix crash if backend doesn't follow the right states.
xen/blkback: Fix two memory leaks.
xen/blkback: make st_ statistics per ring
xen/blkfront: Handle non-indirect grant with 64KB pages
xen-blkfront: Introduce blkif_ring_get_request
xen-blkback: clear PF_NOFREEZE for xen_blkif_schedule()
xen/blkback: Free resources if connect_ring failed.
xen/blocks: Return -EXX instead of -1
xen/blkback: make pool of persistent grants and free pages per-queue
xen/blkback: get the number of hardware queues/rings from blkfront
xen/blkback: pseudo support for multi hardware queues/rings
xen/blkback: separate ring information out of struct xen_blkif
xen/blkfront: correct setting for xen_blkif_max_ring_order
xen/blkfront: make persistent grants pool per-queue
xen/blkfront: Remove duplicate setting of ->xbdev.
xen/blkfront: Cleanup of comments, fix unaligned variables, and syntax errors.
xen/blkfront: negotiate number of queues/rings to be used with backend
xen/blkfront: split per device io_lock
...
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r-- | drivers/md/bcache/btree.c | 5 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 16 | ||||
-rw-r--r-- | drivers/md/bcache/writeback.c | 37 | ||||
-rw-r--r-- | drivers/md/bcache/writeback.h | 3 |
4 files changed, 48 insertions, 13 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 83392f856dfd..22b9e34ceb75 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -1741,6 +1741,7 @@ static void bch_btree_gc(struct cache_set *c) | |||
1741 | do { | 1741 | do { |
1742 | ret = btree_root(gc_root, c, &op, &writes, &stats); | 1742 | ret = btree_root(gc_root, c, &op, &writes, &stats); |
1743 | closure_sync(&writes); | 1743 | closure_sync(&writes); |
1744 | cond_resched(); | ||
1744 | 1745 | ||
1745 | if (ret && ret != -EAGAIN) | 1746 | if (ret && ret != -EAGAIN) |
1746 | pr_warn("gc failed!"); | 1747 | pr_warn("gc failed!"); |
@@ -2162,8 +2163,10 @@ int bch_btree_insert_check_key(struct btree *b, struct btree_op *op, | |||
2162 | rw_lock(true, b, b->level); | 2163 | rw_lock(true, b, b->level); |
2163 | 2164 | ||
2164 | if (b->key.ptr[0] != btree_ptr || | 2165 | if (b->key.ptr[0] != btree_ptr || |
2165 | b->seq != seq + 1) | 2166 | b->seq != seq + 1) { |
2167 | op->lock = b->level; | ||
2166 | goto out; | 2168 | goto out; |
2169 | } | ||
2167 | } | 2170 | } |
2168 | 2171 | ||
2169 | SET_KEY_PTRS(check_key, 1); | 2172 | SET_KEY_PTRS(check_key, 1); |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 679a093a3bf6..8d0ead98eb6e 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -685,6 +685,8 @@ static void bcache_device_link(struct bcache_device *d, struct cache_set *c, | |||
685 | WARN(sysfs_create_link(&d->kobj, &c->kobj, "cache") || | 685 | WARN(sysfs_create_link(&d->kobj, &c->kobj, "cache") || |
686 | sysfs_create_link(&c->kobj, &d->kobj, d->name), | 686 | sysfs_create_link(&c->kobj, &d->kobj, d->name), |
687 | "Couldn't create device <-> cache set symlinks"); | 687 | "Couldn't create device <-> cache set symlinks"); |
688 | |||
689 | clear_bit(BCACHE_DEV_UNLINK_DONE, &d->flags); | ||
688 | } | 690 | } |
689 | 691 | ||
690 | static void bcache_device_detach(struct bcache_device *d) | 692 | static void bcache_device_detach(struct bcache_device *d) |
@@ -847,8 +849,11 @@ void bch_cached_dev_run(struct cached_dev *dc) | |||
847 | buf[SB_LABEL_SIZE] = '\0'; | 849 | buf[SB_LABEL_SIZE] = '\0'; |
848 | env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf); | 850 | env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf); |
849 | 851 | ||
850 | if (atomic_xchg(&dc->running, 1)) | 852 | if (atomic_xchg(&dc->running, 1)) { |
853 | kfree(env[1]); | ||
854 | kfree(env[2]); | ||
851 | return; | 855 | return; |
856 | } | ||
852 | 857 | ||
853 | if (!d->c && | 858 | if (!d->c && |
854 | BDEV_STATE(&dc->sb) != BDEV_STATE_NONE) { | 859 | BDEV_STATE(&dc->sb) != BDEV_STATE_NONE) { |
@@ -1933,6 +1938,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, | |||
1933 | else | 1938 | else |
1934 | err = "device busy"; | 1939 | err = "device busy"; |
1935 | mutex_unlock(&bch_register_lock); | 1940 | mutex_unlock(&bch_register_lock); |
1941 | if (attr == &ksysfs_register_quiet) | ||
1942 | goto out; | ||
1936 | } | 1943 | } |
1937 | goto err; | 1944 | goto err; |
1938 | } | 1945 | } |
@@ -1971,8 +1978,7 @@ out: | |||
1971 | err_close: | 1978 | err_close: |
1972 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); | 1979 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); |
1973 | err: | 1980 | err: |
1974 | if (attr != &ksysfs_register_quiet) | 1981 | pr_info("error opening %s: %s", path, err); |
1975 | pr_info("error opening %s: %s", path, err); | ||
1976 | ret = -EINVAL; | 1982 | ret = -EINVAL; |
1977 | goto out; | 1983 | goto out; |
1978 | } | 1984 | } |
@@ -2066,8 +2072,10 @@ static int __init bcache_init(void) | |||
2066 | closure_debug_init(); | 2072 | closure_debug_init(); |
2067 | 2073 | ||
2068 | bcache_major = register_blkdev(0, "bcache"); | 2074 | bcache_major = register_blkdev(0, "bcache"); |
2069 | if (bcache_major < 0) | 2075 | if (bcache_major < 0) { |
2076 | unregister_reboot_notifier(&reboot); | ||
2070 | return bcache_major; | 2077 | return bcache_major; |
2078 | } | ||
2071 | 2079 | ||
2072 | if (!(bcache_wq = create_workqueue("bcache")) || | 2080 | if (!(bcache_wq = create_workqueue("bcache")) || |
2073 | !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) || | 2081 | !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) || |
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index b23f88d9f18c..b9346cd9cda1 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c | |||
@@ -323,6 +323,10 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode, | |||
323 | 323 | ||
324 | static bool dirty_pred(struct keybuf *buf, struct bkey *k) | 324 | static bool dirty_pred(struct keybuf *buf, struct bkey *k) |
325 | { | 325 | { |
326 | struct cached_dev *dc = container_of(buf, struct cached_dev, writeback_keys); | ||
327 | |||
328 | BUG_ON(KEY_INODE(k) != dc->disk.id); | ||
329 | |||
326 | return KEY_DIRTY(k); | 330 | return KEY_DIRTY(k); |
327 | } | 331 | } |
328 | 332 | ||
@@ -372,11 +376,24 @@ next: | |||
372 | } | 376 | } |
373 | } | 377 | } |
374 | 378 | ||
379 | /* | ||
380 | * Returns true if we scanned the entire disk | ||
381 | */ | ||
375 | static bool refill_dirty(struct cached_dev *dc) | 382 | static bool refill_dirty(struct cached_dev *dc) |
376 | { | 383 | { |
377 | struct keybuf *buf = &dc->writeback_keys; | 384 | struct keybuf *buf = &dc->writeback_keys; |
385 | struct bkey start = KEY(dc->disk.id, 0, 0); | ||
378 | struct bkey end = KEY(dc->disk.id, MAX_KEY_OFFSET, 0); | 386 | struct bkey end = KEY(dc->disk.id, MAX_KEY_OFFSET, 0); |
379 | bool searched_from_start = false; | 387 | struct bkey start_pos; |
388 | |||
389 | /* | ||
390 | * make sure keybuf pos is inside the range for this disk - at bringup | ||
391 | * we might not be attached yet so this disk's inode nr isn't | ||
392 | * initialized then | ||
393 | */ | ||
394 | if (bkey_cmp(&buf->last_scanned, &start) < 0 || | ||
395 | bkey_cmp(&buf->last_scanned, &end) > 0) | ||
396 | buf->last_scanned = start; | ||
380 | 397 | ||
381 | if (dc->partial_stripes_expensive) { | 398 | if (dc->partial_stripes_expensive) { |
382 | refill_full_stripes(dc); | 399 | refill_full_stripes(dc); |
@@ -384,14 +401,20 @@ static bool refill_dirty(struct cached_dev *dc) | |||
384 | return false; | 401 | return false; |
385 | } | 402 | } |
386 | 403 | ||
387 | if (bkey_cmp(&buf->last_scanned, &end) >= 0) { | 404 | start_pos = buf->last_scanned; |
388 | buf->last_scanned = KEY(dc->disk.id, 0, 0); | ||
389 | searched_from_start = true; | ||
390 | } | ||
391 | |||
392 | bch_refill_keybuf(dc->disk.c, buf, &end, dirty_pred); | 405 | bch_refill_keybuf(dc->disk.c, buf, &end, dirty_pred); |
393 | 406 | ||
394 | return bkey_cmp(&buf->last_scanned, &end) >= 0 && searched_from_start; | 407 | if (bkey_cmp(&buf->last_scanned, &end) < 0) |
408 | return false; | ||
409 | |||
410 | /* | ||
411 | * If we get to the end start scanning again from the beginning, and | ||
412 | * only scan up to where we initially started scanning from: | ||
413 | */ | ||
414 | buf->last_scanned = start; | ||
415 | bch_refill_keybuf(dc->disk.c, buf, &start_pos, dirty_pred); | ||
416 | |||
417 | return bkey_cmp(&buf->last_scanned, &start_pos) >= 0; | ||
395 | } | 418 | } |
396 | 419 | ||
397 | static int bch_writeback_thread(void *arg) | 420 | static int bch_writeback_thread(void *arg) |
diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h index 0a9dab187b79..073a042aed24 100644 --- a/drivers/md/bcache/writeback.h +++ b/drivers/md/bcache/writeback.h | |||
@@ -63,7 +63,8 @@ static inline bool should_writeback(struct cached_dev *dc, struct bio *bio, | |||
63 | 63 | ||
64 | static inline void bch_writeback_queue(struct cached_dev *dc) | 64 | static inline void bch_writeback_queue(struct cached_dev *dc) |
65 | { | 65 | { |
66 | wake_up_process(dc->writeback_thread); | 66 | if (!IS_ERR_OR_NULL(dc->writeback_thread)) |
67 | wake_up_process(dc->writeback_thread); | ||
67 | } | 68 | } |
68 | 69 | ||
69 | static inline void bch_writeback_add(struct cached_dev *dc) | 70 | static inline void bch_writeback_add(struct cached_dev *dc) |