Skip to content

Commit

Permalink
cfq-iosched: don't call wbt_disable_default() with IRQs disabled
Browse files Browse the repository at this point in the history
wbt_disable_default() calls del_timer_sync() to wait for the wbt
timer to finish before disabling throttling. We can't do this with
IRQs disable. This fixes a lockdep splat on boot, if non-root
cgroups are used.

Reported-by: Gabriel C <nix.or.die@gmail.com>
Fixes: 87760e5 ("block: hook up writeback throttling")
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
axboe committed Feb 16, 2017
1 parent eeeefd4 commit 5d7f5ce
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3758,7 +3758,7 @@ static void cfq_init_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
}

#ifdef CONFIG_CFQ_GROUP_IOSCHED
static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
static bool check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
{
struct cfq_data *cfqd = cic_to_cfqd(cic);
struct cfq_queue *cfqq;
Expand All @@ -3775,15 +3775,7 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
* spuriously on a newly created cic but there's no harm.
*/
if (unlikely(!cfqd) || likely(cic->blkcg_serial_nr == serial_nr))
return;

/*
* If we have a non-root cgroup, we can depend on that to
* do proper throttling of writes. Turn off wbt for that
* case, if it was enabled by default.
*/
if (nonroot_cg)
wbt_disable_default(cfqd->queue);
return nonroot_cg;

/*
* Drop reference to queues. New queues will be assigned in new
Expand All @@ -3804,9 +3796,13 @@ static void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
}

cic->blkcg_serial_nr = serial_nr;
return nonroot_cg;
}
#else
static inline void check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio) { }
static inline bool check_blkcg_changed(struct cfq_io_cq *cic, struct bio *bio)
{
return false;
}
#endif /* CONFIG_CFQ_GROUP_IOSCHED */

static struct cfq_queue **
Expand Down Expand Up @@ -4448,11 +4444,12 @@ cfq_set_request(struct request_queue *q, struct request *rq, struct bio *bio,
const int rw = rq_data_dir(rq);
const bool is_sync = rq_is_sync(rq);
struct cfq_queue *cfqq;
bool disable_wbt;

spin_lock_irq(q->queue_lock);

check_ioprio_changed(cic, bio);
check_blkcg_changed(cic, bio);
disable_wbt = check_blkcg_changed(cic, bio);
new_queue:
cfqq = cic_to_cfqq(cic, is_sync);
if (!cfqq || cfqq == &cfqd->oom_cfqq) {
Expand Down Expand Up @@ -4488,6 +4485,10 @@ cfq_set_request(struct request_queue *q, struct request *rq, struct bio *bio,
rq->elv.priv[0] = cfqq;
rq->elv.priv[1] = cfqq->cfqg;
spin_unlock_irq(q->queue_lock);

if (disable_wbt)
wbt_disable_default(q);

return 0;
}

Expand Down

0 comments on commit 5d7f5ce

Please sign in to comment.