]> git.baikalelectronics.ru Git - kernel.git/commit
block: don't protect submit_bio_checks by q_usage_counter
authorMing Lei <ming.lei@redhat.com>
Tue, 4 Jan 2022 13:42:23 +0000 (21:42 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 10 Jan 2022 01:54:52 +0000 (18:54 -0700)
commitf5716f288dbb8b05ebe7ec0883e0c1bfb0497ca7
treef5e954af14ed82e4023395d58c0c0073624da116
parent5e066d934462ff8e4ce0ce5dab1be6265059c6df
block: don't protect submit_bio_checks by q_usage_counter

Commit 643f56aac381 ("block: call submit_bio_checks under q_usage_counter")
uses q_usage_counter to protect submit_bio_checks for avoiding IO after
disk is deleted by del_gendisk().

Turns out the protection isn't necessary, because once
blk_mq_freeze_queue_wait() in del_gendisk() returns:

1) all in-flight IO has been done

2) all new IO will be failed in __bio_queue_enter() because
   q_usage_counter is dead, and GD_DEAD is set

3) both disk and request queue instance are safe since caller of
submit_bio() guarantees that the disk can't be closed.

Once submit_bio_checks() needn't the protection of q_usage_counter, we can
move submit_bio_checks before calling blk_mq_submit_bio() and
->submit_bio(). With this change, we needn't to throttle queue with
holding one allocated request, then precise driver tag or request won't be
wasted in throttling. Meantime we can unify the bio check for both bio
based and request based driver.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220104134223.590803-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-mq.c