blk-iocost: fix lockdep warning on blkcg->lock
authorMing Lei <ming.lei@redhat.com>
Tue, 3 Aug 2021 07:06:08 +0000 (15:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Sep 2021 08:09:22 +0000 (10:09 +0200)
commitc94d50979f20b0a62171d312af907c29f5ec4866
treef48545cd379a9273ee3d4f920ec4736d7ea25a33
parent6815e21fe28ddfe8f55b4ca53031957dcd65843a
blk-iocost: fix lockdep warning on blkcg->lock

[ Upstream commit 11431e26c9c43fa26f6b33ee1a90989f57b86024 ]

blkcg->lock depends on q->queue_lock which may depend on another driver
lock required in irq context, one example is dm-thin:

Chain exists of:
  &pool->lock#3 --> &q->queue_lock --> &blkcg->lock

 Possible interrupt unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&blkcg->lock);
                               local_irq_disable();
                               lock(&pool->lock#3);
                               lock(&q->queue_lock);
  <Interrupt>
    lock(&pool->lock#3);

Fix the issue by using spin_lock_irq(&blkcg->lock) in ioc_weight_write().

Cc: Tejun Heo <tj@kernel.org>
Reported-by: Bruno Goncalves <bgoncalv@redhat.com>
Link: https://lore.kernel.org/linux-block/CA+QYu4rzz6079ighEanS3Qq_Dmnczcf45ZoJoHKVLVATTo1e4Q@mail.gmail.com/T/#u
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20210803070608.1766400-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-iocost.c