[Devel] [PATCH RHEL7 COMMIT] ms/block: Fix list corruption of blk stats callback list

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 30 18:57:15 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-1062.4.1.vz7.115.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.4.1.vz7.115.3
------>
commit e90ff4e929596cda9a0e596e340087b55744f6ee
Author: Jan Kara <jack at suse.cz>
Date:   Wed Oct 30 18:57:13 2019 +0300

    ms/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 at suse.cz>
    Signed-off-by: Jens Axboe <axboe at fb.com>
    
    https://jira.sw.ru/browse/PSBM-99021
    
    (cherry picked from commit 3f19cd23f3a9420fe7bd98ad41d05e45fa6d4d47)
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 block/blk-wbt.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 554f4ee970c7..67f0c9e6451f 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -648,19 +648,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) {
-		blk_stat_remove_callback(q, rwb->cb);
-		rwb->win_nsec = rwb->min_lat_nsec = 0;
-		wbt_update_limits(rwb);
-	}
+	if (rwb)
+		wbt_exit(q);
 }
 EXPORT_SYMBOL_GPL(wbt_disable_default);
 



More information about the Devel mailing list