aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/request.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-14 18:32:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-14 18:32:19 -0500
commite2c5923c349c1738fe8fda980874d93f6fb2e5b6 (patch)
treeb97a90170c45211bcc437761653aa8016c34afcd /drivers/md/bcache/request.c
parentabc36be236358162202e86ad88616ff95a755101 (diff)
parenta04b5de5050ab8b891128eb2c47a0916fe8622e1 (diff)
Merge branch 'for-4.15/block' of git://git.kernel.dk/linux-block
Pull core block layer updates from Jens Axboe: "This is the main pull request for block storage for 4.15-rc1. Nothing out of the ordinary in here, and no API changes or anything like that. Just various new features for drivers, core changes, etc. In particular, this pull request contains: - A patch series from Bart, closing the whole on blk/scsi-mq queue quescing. - A series from Christoph, building towards hidden gendisks (for multipath) and ability to move bio chains around. - NVMe - Support for native multipath for NVMe (Christoph). - Userspace notifications for AENs (Keith). - Command side-effects support (Keith). - SGL support (Chaitanya Kulkarni) - FC fixes and improvements (James Smart) - Lots of fixes and tweaks (Various) - bcache - New maintainer (Michael Lyle) - Writeback control improvements (Michael) - Various fixes (Coly, Elena, Eric, Liang, et al) - lightnvm updates, mostly centered around the pblk interface (Javier, Hans, and Rakesh). - Removal of unused bio/bvec kmap atomic interfaces (me, Christoph) - Writeback series that fix the much discussed hundreds of millions of sync-all units. This goes all the way, as discussed previously (me). - Fix for missing wakeup on writeback timer adjustments (Yafang Shao). - Fix laptop mode on blk-mq (me). - {mq,name} tupple lookup for IO schedulers, allowing us to have alias names. This means you can use 'deadline' on both !mq and on mq (where it's called mq-deadline). (me). - blktrace race fix, oopsing on sg load (me). - blk-mq optimizations (me). - Obscure waitqueue race fix for kyber (Omar). - NBD fixes (Josef). - Disable writeback throttling by default on bfq, like we do on cfq (Luca Miccio). - Series from Ming that enable us to treat flush requests on blk-mq like any other request. This is a really nice cleanup. - Series from Ming that improves merging on blk-mq with schedulers, getting us closer to flipping the switch on scsi-mq again. - BFQ updates (Paolo). - blk-mq atomic flags memory ordering fixes (Peter Z). - Loop cgroup support (Shaohua). - Lots of minor fixes from lots of different folks, both for core and driver code" * 'for-4.15/block' of git://git.kernel.dk/linux-block: (294 commits) nvme: fix visibility of "uuid" ns attribute blk-mq: fixup some comment typos and lengths ide: ide-atapi: fix compile error with defining macro DEBUG blk-mq: improve tag waiting setup for non-shared tags brd: remove unused brd_mutex blk-mq: only run the hardware queue if IO is pending block: avoid null pointer dereference on null disk fs: guard_bio_eod() needs to consider partitions xtensa/simdisk: fix compile error nvme: expose subsys attribute to sysfs nvme: create 'slaves' and 'holders' entries for hidden controllers block: create 'slaves' and 'holders' entries for hidden gendisks nvme: also expose the namespace identification sysfs files for mpath nodes nvme: implement multipath access to nvme subsystems nvme: track shared namespaces nvme: introduce a nvme_ns_ids structure nvme: track subsystems block, nvme: Introduce blk_mq_req_flags_t block, scsi: Make SCSI quiesce and resume work reliably block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag ...
Diffstat (limited to 'drivers/md/bcache/request.c')
-rw-r--r--drivers/md/bcache/request.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 3475d6628e21..3a7aed7282b2 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -27,12 +27,12 @@ struct kmem_cache *bch_search_cache;
27 27
28static void bch_data_insert_start(struct closure *); 28static void bch_data_insert_start(struct closure *);
29 29
30static unsigned cache_mode(struct cached_dev *dc, struct bio *bio) 30static unsigned cache_mode(struct cached_dev *dc)
31{ 31{
32 return BDEV_CACHE_MODE(&dc->sb); 32 return BDEV_CACHE_MODE(&dc->sb);
33} 33}
34 34
35static bool verify(struct cached_dev *dc, struct bio *bio) 35static bool verify(struct cached_dev *dc)
36{ 36{
37 return dc->verify; 37 return dc->verify;
38} 38}
@@ -370,7 +370,7 @@ static struct hlist_head *iohash(struct cached_dev *dc, uint64_t k)
370static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) 370static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
371{ 371{
372 struct cache_set *c = dc->disk.c; 372 struct cache_set *c = dc->disk.c;
373 unsigned mode = cache_mode(dc, bio); 373 unsigned mode = cache_mode(dc);
374 unsigned sectors, congested = bch_get_congested(c); 374 unsigned sectors, congested = bch_get_congested(c);
375 struct task_struct *task = current; 375 struct task_struct *task = current;
376 struct io *i; 376 struct io *i;
@@ -385,6 +385,14 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
385 op_is_write(bio_op(bio)))) 385 op_is_write(bio_op(bio))))
386 goto skip; 386 goto skip;
387 387
388 /*
389 * Flag for bypass if the IO is for read-ahead or background,
390 * unless the read-ahead request is for metadata (eg, for gfs2).
391 */
392 if (bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND) &&
393 !(bio->bi_opf & REQ_META))
394 goto skip;
395
388 if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) || 396 if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) ||
389 bio_sectors(bio) & (c->sb.block_size - 1)) { 397 bio_sectors(bio) & (c->sb.block_size - 1)) {
390 pr_debug("skipping unaligned io"); 398 pr_debug("skipping unaligned io");
@@ -463,6 +471,7 @@ struct search {
463 unsigned recoverable:1; 471 unsigned recoverable:1;
464 unsigned write:1; 472 unsigned write:1;
465 unsigned read_dirty_data:1; 473 unsigned read_dirty_data:1;
474 unsigned cache_missed:1;
466 475
467 unsigned long start_time; 476 unsigned long start_time;
468 477
@@ -649,6 +658,7 @@ static inline struct search *search_alloc(struct bio *bio,
649 658
650 s->orig_bio = bio; 659 s->orig_bio = bio;
651 s->cache_miss = NULL; 660 s->cache_miss = NULL;
661 s->cache_missed = 0;
652 s->d = d; 662 s->d = d;
653 s->recoverable = 1; 663 s->recoverable = 1;
654 s->write = op_is_write(bio_op(bio)); 664 s->write = op_is_write(bio_op(bio));
@@ -698,8 +708,16 @@ static void cached_dev_read_error(struct closure *cl)
698{ 708{
699 struct search *s = container_of(cl, struct search, cl); 709 struct search *s = container_of(cl, struct search, cl);
700 struct bio *bio = &s->bio.bio; 710 struct bio *bio = &s->bio.bio;
711 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
701 712
702 if (s->recoverable) { 713 /*
714 * If cache device is dirty (dc->has_dirty is non-zero), then
715 * recovery a failed read request from cached device may get a
716 * stale data back. So read failure recovery is only permitted
717 * when cache device is clean.
718 */
719 if (s->recoverable &&
720 (dc && !atomic_read(&dc->has_dirty))) {
703 /* Retry from the backing device: */ 721 /* Retry from the backing device: */
704 trace_bcache_read_retry(s->orig_bio); 722 trace_bcache_read_retry(s->orig_bio);
705 723
@@ -740,7 +758,7 @@ static void cached_dev_read_done(struct closure *cl)
740 s->cache_miss = NULL; 758 s->cache_miss = NULL;
741 } 759 }
742 760
743 if (verify(dc, &s->bio.bio) && s->recoverable && !s->read_dirty_data) 761 if (verify(dc) && s->recoverable && !s->read_dirty_data)
744 bch_data_verify(dc, s->orig_bio); 762 bch_data_verify(dc, s->orig_bio);
745 763
746 bio_complete(s); 764 bio_complete(s);
@@ -760,12 +778,12 @@ static void cached_dev_read_done_bh(struct closure *cl)
760 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); 778 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
761 779
762 bch_mark_cache_accounting(s->iop.c, s->d, 780 bch_mark_cache_accounting(s->iop.c, s->d,
763 !s->cache_miss, s->iop.bypass); 781 !s->cache_missed, s->iop.bypass);
764 trace_bcache_read(s->orig_bio, !s->cache_miss, s->iop.bypass); 782 trace_bcache_read(s->orig_bio, !s->cache_miss, s->iop.bypass);
765 783
766 if (s->iop.status) 784 if (s->iop.status)
767 continue_at_nobarrier(cl, cached_dev_read_error, bcache_wq); 785 continue_at_nobarrier(cl, cached_dev_read_error, bcache_wq);
768 else if (s->iop.bio || verify(dc, &s->bio.bio)) 786 else if (s->iop.bio || verify(dc))
769 continue_at_nobarrier(cl, cached_dev_read_done, bcache_wq); 787 continue_at_nobarrier(cl, cached_dev_read_done, bcache_wq);
770 else 788 else
771 continue_at_nobarrier(cl, cached_dev_bio_complete, NULL); 789 continue_at_nobarrier(cl, cached_dev_bio_complete, NULL);
@@ -779,6 +797,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
779 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); 797 struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
780 struct bio *miss, *cache_bio; 798 struct bio *miss, *cache_bio;
781 799
800 s->cache_missed = 1;
801
782 if (s->cache_miss || s->iop.bypass) { 802 if (s->cache_miss || s->iop.bypass) {
783 miss = bio_next_split(bio, sectors, GFP_NOIO, s->d->bio_split); 803 miss = bio_next_split(bio, sectors, GFP_NOIO, s->d->bio_split);
784 ret = miss == bio ? MAP_DONE : MAP_CONTINUE; 804 ret = miss == bio ? MAP_DONE : MAP_CONTINUE;
@@ -892,7 +912,7 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
892 s->iop.bypass = true; 912 s->iop.bypass = true;
893 913
894 if (should_writeback(dc, s->orig_bio, 914 if (should_writeback(dc, s->orig_bio,
895 cache_mode(dc, bio), 915 cache_mode(dc),
896 s->iop.bypass)) { 916 s->iop.bypass)) {
897 s->iop.bypass = false; 917 s->iop.bypass = false;
898 s->iop.writeback = true; 918 s->iop.writeback = true;