[Devel] [PATCH RHEL7 COMMIT] ms/block: fix leak of q->rq_wb

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 30 18:57:14 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 cf42855276f34f04e77bfd5c2f9b0adc44eda36c
Author: Omar Sandoval <osandov at fb.com>
Date:   Wed Oct 30 18:57:12 2019 +0300

    ms/block: fix leak of q->rq_wb
    
    CONFIG_DEBUG_TEST_DRIVER_REMOVE found a possible leak of q->rq_wb when a
    request queue is reregistered. This has been a problem since wbt was
    introduced, but the WARN_ON(!list_empty(&stats->callbacks)) in the
    blk-stat rework exposed it. Fix it by cleaning up wbt when we unregister
    the queue.
    
    Fixes: 87760e5eef35 ("block: hook up writeback throttling")
    Signed-off-by: Omar Sandoval <osandov at fb.com>
    Signed-off-by: Jens Axboe <axboe at fb.com>
    
    Decided to backport during investigation of
    https://jira.sw.ru/browse/PSBM-99021
    
    (cherry picked from commit 02ba8893ac9aa34fcb4ce2a9baef5615b190335a)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 block/blk-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index ed5c71a8e84f..7aebab0ced19 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -587,7 +587,6 @@ static void blk_release_queue(struct kobject *kobj)
 	struct request_queue *q =
 		container_of(kobj, struct request_queue, kobj);
 
-	wbt_exit(q);
 	if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags))
 		blk_stat_remove_callback(q, q->poll_cb);
 	blk_stat_free_callback(q->poll_cb);
@@ -753,6 +752,8 @@ void blk_unregister_queue(struct gendisk *disk)
 	queue_flag_clear(QUEUE_FLAG_REGISTERED, q);
 	spin_unlock_irq(q->queue_lock);
 
+	wbt_exit(q);
+
 	/*
 	 * Remove the sysfs attributes before unregistering the queue data
 	 * structures that can be modified through sysfs.



More information about the Devel mailing list