blk-mq: Replace tags->lock with SRCU for tag iterators
authorMing Lei <ming.lei@redhat.com>
Sat, 30 Aug 2025 02:18:23 +0000 (10:18 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Sep 2025 14:05:32 +0000 (08:05 -0600)
commit995412e23bb2560a73db444e4c60bf5826b33aaa
treedf981486297691db37ade27e326ca25d4b413f60
parent135b8521f21d4d4d4fde74e73b80d8e4d417e20a
blk-mq: Replace tags->lock with SRCU for tag iterators

Replace the spinlock in blk_mq_find_and_get_req() with an SRCU read lock
around the tag iterators.

This is done by:

- Holding the SRCU read lock in blk_mq_queue_tag_busy_iter(),
blk_mq_tagset_busy_iter(), and blk_mq_hctx_has_requests().

- Removing the now-redundant tags->lock from blk_mq_find_and_get_req().

This change fixes lockup issue in scsi_host_busy() in case of shost->host_blocked.

Also avoids big tags->lock when reading disk sysfs attribute `inflight`.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq-tag.c
block/blk-mq.c