aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-wbt.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2018-07-03 11:14:59 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-09 11:07:54 -0400
commitc1c80384c8f47021a01a0cc42894a06bed2b801b (patch)
treee3fb3b3ddf6c58eea32d49989875ca39c0ba382c /block/blk-wbt.c
parenta79050434b45959f397042080fd1d70ffa9bd9df (diff)
block: remove external dependency on wbt_flags
We don't really need to save this stuff in the core block code, we can just pass the bio back into the helpers later on to derive the same flags and update the rq->wbt_flags appropriately. Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-wbt.c')
-rw-r--r--block/blk-wbt.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 6fe20fb823e4..461a9af11efe 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -549,41 +549,66 @@ static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio)
549 } 549 }
550} 550}
551 551
552static enum wbt_flags bio_to_wbt_flags(struct rq_wb *rwb, struct bio *bio)
553{
554 enum wbt_flags flags = 0;
555
556 if (bio_op(bio) == REQ_OP_READ) {
557 flags = WBT_READ;
558 } else if (wbt_should_throttle(rwb, bio)) {
559 if (current_is_kswapd())
560 flags |= WBT_KSWAPD;
561 if (bio_op(bio) == REQ_OP_DISCARD)
562 flags |= WBT_DISCARD;
563 flags |= WBT_TRACKED;
564 }
565 return flags;
566}
567
568static void wbt_cleanup(struct rq_qos *rqos, struct bio *bio)
569{
570 struct rq_wb *rwb = RQWB(rqos);
571 enum wbt_flags flags = bio_to_wbt_flags(rwb, bio);
572 __wbt_done(rqos, flags);
573}
574
552/* 575/*
553 * Returns true if the IO request should be accounted, false if not. 576 * Returns true if the IO request should be accounted, false if not.
554 * May sleep, if we have exceeded the writeback limits. Caller can pass 577 * May sleep, if we have exceeded the writeback limits. Caller can pass
555 * in an irq held spinlock, if it holds one when calling this function. 578 * in an irq held spinlock, if it holds one when calling this function.
556 * If we do sleep, we'll release and re-grab it. 579 * If we do sleep, we'll release and re-grab it.
557 */ 580 */
558static enum wbt_flags wbt_wait(struct rq_qos *rqos, struct bio *bio, 581static void wbt_wait(struct rq_qos *rqos, struct bio *bio, spinlock_t *lock)
559 spinlock_t *lock)
560{ 582{
561 struct rq_wb *rwb = RQWB(rqos); 583 struct rq_wb *rwb = RQWB(rqos);
562 enum wbt_flags ret = 0; 584 enum wbt_flags flags;
563 585
564 if (!rwb_enabled(rwb)) 586 if (!rwb_enabled(rwb))
565 return 0; 587 return;
566 588
567 if (bio_op(bio) == REQ_OP_READ) 589 flags = bio_to_wbt_flags(rwb, bio);
568 ret = WBT_READ;
569 590
570 if (!wbt_should_throttle(rwb, bio)) { 591 if (!wbt_should_throttle(rwb, bio)) {
571 if (ret & WBT_READ) 592 if (flags & WBT_READ)
572 wb_timestamp(rwb, &rwb->last_issue); 593 wb_timestamp(rwb, &rwb->last_issue);
573 return ret; 594 return;
574 } 595 }
575 596
576 if (current_is_kswapd()) 597 if (current_is_kswapd())
577 ret |= WBT_KSWAPD; 598 flags |= WBT_KSWAPD;
578 if (bio_op(bio) == REQ_OP_DISCARD) 599 if (bio_op(bio) == REQ_OP_DISCARD)
579 ret |= WBT_DISCARD; 600 flags |= WBT_DISCARD;
580 601
581 __wbt_wait(rwb, ret, bio->bi_opf, lock); 602 __wbt_wait(rwb, flags, bio->bi_opf, lock);
582 603
583 if (!blk_stat_is_active(rwb->cb)) 604 if (!blk_stat_is_active(rwb->cb))
584 rwb_arm_timer(rwb); 605 rwb_arm_timer(rwb);
606}
585 607
586 return ret | WBT_TRACKED; 608static void wbt_track(struct rq_qos *rqos, struct request *rq, struct bio *bio)
609{
610 struct rq_wb *rwb = RQWB(rqos);
611 rq->wbt_flags |= bio_to_wbt_flags(rwb, bio);
587} 612}
588 613
589void wbt_issue(struct rq_qos *rqos, struct request *rq) 614void wbt_issue(struct rq_qos *rqos, struct request *rq)
@@ -707,9 +732,10 @@ EXPORT_SYMBOL_GPL(wbt_disable_default);
707static struct rq_qos_ops wbt_rqos_ops = { 732static struct rq_qos_ops wbt_rqos_ops = {
708 .throttle = wbt_wait, 733 .throttle = wbt_wait,
709 .issue = wbt_issue, 734 .issue = wbt_issue,
735 .track = wbt_track,
710 .requeue = wbt_requeue, 736 .requeue = wbt_requeue,
711 .done = wbt_done, 737 .done = wbt_done,
712 .cleanup = __wbt_done, 738 .cleanup = wbt_cleanup,
713 .exit = wbt_exit, 739 .exit = wbt_exit,
714}; 740};
715 741