linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node
@ 2023-08-17 14:17 Ming Lei
  2023-08-17 16:42 ` Tejun Heo
  2023-08-18  1:16 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2023-08-17 14:17 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Ming Lei, Yu Kuai, xiaoli feng, Chunyu Hu,
	Mike Snitzer, Tejun Heo

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 <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>
---
 block/blk-cgroup.c | 2 ++
 1 file changed, 2 insertions(+)

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);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node
  2023-08-17 14:17 [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node Ming Lei
@ 2023-08-17 16:42 ` Tejun Heo
  2023-08-18  1:16 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2023-08-17 16:42 UTC (permalink / raw)
  To: Ming Lei
  Cc: Jens Axboe, linux-block, Yu Kuai, xiaoli feng, Chunyu Hu,
	Mike Snitzer

On Thu, Aug 17, 2023 at 10:17:51PM +0800, Ming Lei wrote:
> 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 <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>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node
  2023-08-17 14:17 [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node Ming Lei
  2023-08-17 16:42 ` Tejun Heo
@ 2023-08-18  1:16 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-08-18  1:16 UTC (permalink / raw)
  To: Ming Lei
  Cc: linux-block, Yu Kuai, xiaoli feng, Chunyu Hu, Mike Snitzer,
	Tejun Heo


On Thu, 17 Aug 2023 22:17:51 +0800, Ming Lei wrote:
> 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,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-18  1:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17 14:17 [PATCH] blk-cgroup: hold queue_lock when removing blkg->q_node Ming Lei
2023-08-17 16:42 ` Tejun Heo
2023-08-18  1:16 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).