1
0
Fork 0

block: Fix list corruption of blk stats callback list

When CFQ calls wbt_disable_default(), it will call
blk_stat_remove_callback() to stop gathering IO statistics for the
purposes of writeback throttling. Later, when request_queue is
unregistered, wbt_exit() will call blk_stat_remove_callback() again
which will try to delete callback from the list again and possibly cause
list corruption.

Fix the problem by making wbt_disable_default() called wbt_exit() which
is properly guarded against being called multiple times.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
hifive-unleashed-5.1
Jan Kara 2017-04-11 11:29:01 +02:00 committed by Jens Axboe
parent f5c0b0910a
commit 3f19cd23f3
1 changed files with 4 additions and 8 deletions

View File

@ -653,19 +653,15 @@ void wbt_set_write_cache(struct rq_wb *rwb, bool write_cache_on)
rwb->wc = write_cache_on; rwb->wc = write_cache_on;
} }
/* /*
* Disable wbt, if enabled by default. Only called from CFQ, if we have * Disable wbt, if enabled by default. Only called from CFQ.
* cgroups enabled
*/ */
void wbt_disable_default(struct request_queue *q) void wbt_disable_default(struct request_queue *q)
{ {
struct rq_wb *rwb = q->rq_wb; struct rq_wb *rwb = q->rq_wb;
if (rwb && rwb->enable_state == WBT_STATE_ON_DEFAULT) { if (rwb && rwb->enable_state == WBT_STATE_ON_DEFAULT)
blk_stat_remove_callback(q, rwb->cb); wbt_exit(q);
rwb->win_nsec = rwb->min_lat_nsec = 0;
wbt_update_limits(rwb);
}
} }
EXPORT_SYMBOL_GPL(wbt_disable_default); EXPORT_SYMBOL_GPL(wbt_disable_default);