summaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-02-08 07:35:14 +0100
committerJens Axboe <axboe@kernel.dk>2023-02-09 16:10:45 +0100
commitc43332fe028c252a2a28e46be70a530f64fc3c9d (patch)
treea92d675fb0c4f51de51836f9665f0398b6fc8fe3 /block/blk-throttle.c
parentMerge branch 'md-next' of https://git.kernel.org/pub/scm/linux/kernel/git/son... (diff)
downloadlinux-c43332fe028c252a2a28e46be70a530f64fc3c9d.tar.xz
linux-c43332fe028c252a2a28e46be70a530f64fc3c9d.zip
blk-cgroup: delay calling blkcg_exit_disk until disk_release
While del_gendisk ensures there is no outstanding I/O on the queue, it can't prevent block layer users from building new I/O. This leads to a NULL ->root_blkg reference in bio_associate_blkg when allocating a new bio on a shut down file system. Delay freeing the blk-cgroup subsystems from del_gendisk until disk_release to make sure the blkg and throttle information is still avaŃ–lable for bio submitters, even if those bios will immediately fail. This now can cause a case where disk_release is called on a disk that hasn't been added. That's mostly harmless, except for a case in blk_throttl_exit that now needs to check for a NULL ->td pointer. Fixes: 178fa7d49815 ("blk-cgroup: delay blk-cgroup initialization until add_disk") Reported-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20230208063514.171485-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-throttle.c')
-rw-r--r--block/blk-throttle.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 902203bdddb4..e7bd7050d684 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -2411,7 +2411,8 @@ void blk_throtl_exit(struct gendisk *disk)
{
struct request_queue *q = disk->queue;
- BUG_ON(!q->td);
+ if (!q->td)
+ return;
del_timer_sync(&q->td->service_queue.pending_timer);
throtl_shutdown_wq(q);
blkcg_deactivate_policy(disk, &blkcg_policy_throtl);