Skip to contentSkip to conversation

blk-cgroup: hold queue_lock when removing blkg->q_node

PATCH Applied Ming Lei 3 participants 3 messages Aug 17, 2023 – Aug 18, 2023

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 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]>
---
 block/blk-cgroup.c | 2 ++
 1 file changed, 2 insertions(+)
block/blk-cgroup.c +2 -0
index fc49be622e05..9faafcd10e17 100644
@@ -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);
Signature · 1 line
2.40.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ming Lei

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]>

Thanks.

Signature · 1 line
tejun
maintainer Applied
#2 lore raw
In reply to Ming Lei
Quoted 5 lines · Ming Lei

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().

Applied, thanks!

[1/1] blk-cgroup: hold queue_lock when removing blkg->q_node

      commit: 94254d59c0d22ecf9fdd1a18dd03652fc6be19e5

Best regards,

Signature · 1 line
Jens Axboe