Skip to content

Commit c164c7b

Browse files
Ming Leiaxboe
authored andcommitted
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: f1c006f ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()") Cc: Yu Kuai <yukuai3@huawei.com> Cc: xiaoli feng <xifeng@redhat.com> Cc: Chunyu Hu <chuhu@redhat.com> Cc: Mike Snitzer <snitzer@kernel.org> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Ming Lei <ming.lei@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20230817141751.1128970-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6548fce commit c164c7b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

block/blk-cgroup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ static void blkg_free_workfn(struct work_struct *work)
136136
blkcg_policy[i]->pd_free_fn(blkg->pd[i]);
137137
if (blkg->parent)
138138
blkg_put(blkg->parent);
139+
spin_lock_irq(&q->queue_lock);
139140
list_del_init(&blkg->q_node);
141+
spin_unlock_irq(&q->queue_lock);
140142
mutex_unlock(&q->blkcg_mutex);
141143

142144
blk_put_queue(q);

0 commit comments

Comments
 (0)