Re: [PATCH 2/2] blk-mq: ensure a q_usage_counter reference is held when splitting bios

Ming Lei
2024-01-11T22:23:10Z

On Thu, Jan 11, 2024 at 02:57:05PM +0100, Christoph Hellwig wrote:
> q_usage_counter is the only thing preventing us from the limits changing
> under us in __bio_split_to_limits, but blk_mq_submit_bio doesn't hold it.

Can you share why the limits change matters wrt. split? If queue is
live, both new and old one are supposed to work, such as, we don't
freeze queue when changing `max_sectors_kb` via sysfs.

>
> Change __submit_bio to always acquire the q_usage_counter counter before
> branching out into bio vs request based helper, and let blk_mq_submit_bio
> tell it if it consumed the reference by handing it off to the request.
>
> Fixes: 9d497e2941c3 ("block: don't protect submit_bio_checks by q_usage_counter")

The above tag looks wrong, the logic change is actually from commit

900e08075202 ("block: move queue enter logic into blk_mq_submit_bio()")

And commit 9d497e2941c3 doesn't move q_usage_counter from
blk_mq_submit_bio() or bio split.

Thanks,
Ming