Skip to content

Commit dd7de37

Browse files
YuKuai-huaweiaxboe
authored andcommitted
block: fix blktrace debugfs entries leakage
Commit 99d055b ("block: remove per-disk debugfs files in blk_unregister_queue") moves blk_trace_shutdown() from blk_release_queue() to blk_unregister_queue(), this is safe if blktrace is created through sysfs, however, there is a regression in corner case. blktrace can still be enabled after del_gendisk() through ioctl if the disk is opened before del_gendisk(), and if blktrace is not shutdown through ioctl before closing the disk, debugfs entries will be leaked. Fix this problem by shutdown blktrace in disk_release(), this is safe because blk_trace_remove() is reentrant. Fixes: 99d055b ("block: remove per-disk debugfs files in blk_unregister_queue") Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent db59133 commit dd7de37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

block/genhd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include <linux/pm_runtime.h>
2626
#include <linux/badblocks.h>
2727
#include <linux/part_stat.h>
28-
#include "blk-throttle.h"
28+
#include <linux/blktrace_api.h>
2929

30+
#include "blk-throttle.h"
3031
#include "blk.h"
3132
#include "blk-mq-sched.h"
3233
#include "blk-rq-qos.h"
@@ -1147,6 +1148,8 @@ static void disk_release(struct device *dev)
11471148
might_sleep();
11481149
WARN_ON_ONCE(disk_live(disk));
11491150

1151+
blk_trace_remove(disk->queue);
1152+
11501153
/*
11511154
* To undo the all initialization from blk_mq_init_allocated_queue in
11521155
* case of a probe failure where add_disk is never called we have to

0 commit comments

Comments
 (0)