On 8/21/19 2:15 AM, Ming Lei wrote:
blk_mq_realloc_hw_ctxs() is called from blk_mq_init_allocated_queue() and blk_mq_update_nr_hw_queues(). For the former caller, the kobject isn't exposed to userspace yet. For the latter caller, sysfs/debugfs is un-registered before updating nr_hw_queues. On the other hand, commit 2f8f1336a48b ("blk-mq: always free hctx after request queue is freed") moves freeing hctx into queue's release handler, so there won't be race with queue release path too. So don't hold q->sysfs_lock in blk_mq_realloc_hw_ctxs().
How about mentioning that the locking at the start of blk_mq_update_nr_hw_queues() serializes all blk_mq_realloc_hw_ctxs() calls that happen after a queue has been registered in sysfs?
Anyway: Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>