Skip to content

Commit

Permalink
blk-cgroup: hold queue_lock when removing blkg->q_node
Browse files Browse the repository at this point in the history
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 <[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]>
  • Loading branch information
Ming Lei authored and axboe committed Aug 18, 2023
1 parent 6548fce commit c164c7b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c164c7b

Please sign in to comment.