diff options
Diffstat (limited to 'drivers/md/bcache/request.c')
-rw-r--r-- | drivers/md/bcache/request.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 932300f18973..f645da61189a 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -510,6 +510,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) | |||
510 | unsigned mode = cache_mode(dc, bio); | 510 | unsigned mode = cache_mode(dc, bio); |
511 | unsigned sectors, congested = bch_get_congested(c); | 511 | unsigned sectors, congested = bch_get_congested(c); |
512 | struct task_struct *task = current; | 512 | struct task_struct *task = current; |
513 | struct io *i; | ||
513 | 514 | ||
514 | if (atomic_read(&dc->disk.detaching) || | 515 | if (atomic_read(&dc->disk.detaching) || |
515 | c->gc_stats.in_use > CUTOFF_CACHE_ADD || | 516 | c->gc_stats.in_use > CUTOFF_CACHE_ADD || |
@@ -536,38 +537,30 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) | |||
536 | (bio->bi_rw & REQ_SYNC)) | 537 | (bio->bi_rw & REQ_SYNC)) |
537 | goto rescale; | 538 | goto rescale; |
538 | 539 | ||
539 | if (dc->sequential_merge) { | 540 | spin_lock(&dc->io_lock); |
540 | struct io *i; | ||
541 | 541 | ||
542 | spin_lock(&dc->io_lock); | 542 | hlist_for_each_entry(i, iohash(dc, bio->bi_sector), hash) |
543 | if (i->last == bio->bi_sector && | ||
544 | time_before(jiffies, i->jiffies)) | ||
545 | goto found; | ||
543 | 546 | ||
544 | hlist_for_each_entry(i, iohash(dc, bio->bi_sector), hash) | 547 | i = list_first_entry(&dc->io_lru, struct io, lru); |
545 | if (i->last == bio->bi_sector && | ||
546 | time_before(jiffies, i->jiffies)) | ||
547 | goto found; | ||
548 | 548 | ||
549 | i = list_first_entry(&dc->io_lru, struct io, lru); | 549 | add_sequential(task); |
550 | 550 | i->sequential = 0; | |
551 | add_sequential(task); | ||
552 | i->sequential = 0; | ||
553 | found: | 551 | found: |
554 | if (i->sequential + bio->bi_size > i->sequential) | 552 | if (i->sequential + bio->bi_size > i->sequential) |
555 | i->sequential += bio->bi_size; | 553 | i->sequential += bio->bi_size; |
556 | |||
557 | i->last = bio_end_sector(bio); | ||
558 | i->jiffies = jiffies + msecs_to_jiffies(5000); | ||
559 | task->sequential_io = i->sequential; | ||
560 | 554 | ||
561 | hlist_del(&i->hash); | 555 | i->last = bio_end_sector(bio); |
562 | hlist_add_head(&i->hash, iohash(dc, i->last)); | 556 | i->jiffies = jiffies + msecs_to_jiffies(5000); |
563 | list_move_tail(&i->lru, &dc->io_lru); | 557 | task->sequential_io = i->sequential; |
564 | 558 | ||
565 | spin_unlock(&dc->io_lock); | 559 | hlist_del(&i->hash); |
566 | } else { | 560 | hlist_add_head(&i->hash, iohash(dc, i->last)); |
567 | task->sequential_io = bio->bi_size; | 561 | list_move_tail(&i->lru, &dc->io_lru); |
568 | 562 | ||
569 | add_sequential(task); | 563 | spin_unlock(&dc->io_lock); |
570 | } | ||
571 | 564 | ||
572 | sectors = max(task->sequential_io, | 565 | sectors = max(task->sequential_io, |
573 | task->sequential_io_avg) >> 9; | 566 | task->sequential_io_avg) >> 9; |