aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMing Lei <[email protected]>2023-08-17 22:17:51 +0800
committerJens Axboe <[email protected]>2023-08-18 15:00:39 -0600
commitc164c7bc9775be7bcc68754bb3431fce5823822e (patch)
treecc6fd414ca4c5b6b912b9b645b3c208508e7f545
parent6548fce05803262ab43241b61dee3e2982486e4b (diff)
blk-cgroup: hold queue_lock when removing blkg->q_node
When blkg is removed from q->blkg_list from blkg_free_workfn(), queue_lock has to be held, otherwise, all kinds of bugs(list corruption, hard lockup, ..) can be triggered from blkg_destroy_all(). Fixes: f1c006f1c685 ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()") Cc: Yu Kuai <[email protected]> Cc: xiaoli feng <[email protected]> Cc: Chunyu Hu <[email protected]> Cc: Mike Snitzer <[email protected]> Cc: Tejun Heo <[email protected]> Signed-off-by: Ming Lei <[email protected]> Acked-by: Tejun Heo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--block/blk-cgroup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index fc49be622e05..9faafcd10e17 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -136,7 +136,9 @@ static void blkg_free_workfn(struct work_struct *work)
blkcg_policy[i]->pd_free_fn(blkg->pd[i]);
if (blkg->parent)
blkg_put(blkg->parent);
+ spin_lock_irq(&q->queue_lock);
list_del_init(&blkg->q_node);
+ spin_unlock_irq(&q->queue_lock);
mutex_unlock(&q->blkcg_mutex);
blk_put_queue(q);