]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
block: Fix list corruption of blk stats callback list
authorJan Kara <jack@suse.cz>
Tue, 11 Apr 2017 09:29:01 +0000 (11:29 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 11 Apr 2017 14:09:14 +0000 (08:09 -0600)
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>
block/blk-wbt.c

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