block: two fixes on recent elevator change
cover block: two fixes on recent elevator change
Hello Jens,
The 1st patch fixes one hang in del_gendisk().
The 2nd patch fixes one race in case that add_disk() fails.
Thanks,
Ming
Ming Lei (2):
block: don't quiesce queue for calling elevator_set_none()
block: move removing elevator after deleting disk->queue_kobj
block/blk-sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Signature · 1 line
2.47.0
PATCH 1/2 block: don't quiesce queue for calling elevator_set_none()
blk_mq_freeze_queue() can't be called on quiesced queue, otherwise it may never return if there is any queued requests.
Fix it by removing quiesce queue around elevator_set_none() because elevator_switch() does quiesce queue in case that we need to switch to none really.
--- block/blk-sysfs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
block/blk-sysfs.c +1 -4
@@ -948,11 +948,8 @@ void blk_unregister_queue(struct gendisk *disk)blk_mq_sysfs_unregister (disk);blk_crypto_sysfs_unregister (disk); -if (queue_is_mq (q)) { -blk_mq_quiesce_queue (q); +if (queue_is_mq (q))elevator_set_none (q); -blk_mq_unquiesce_queue (q); - }mutex_lock (&q->sysfs_lock);disk_unregister_independent_access_ranges (disk);
Signature · 1 line
2.47.0
Re: [PATCH 1/2] block: don't quiesce queue for calling elevator_set_none()
Quoted 9 lines · Ming Lei
blk_mq_freeze_queue()can't be called on quiesced queue, otherwise it may never return if there is any queued requests.Fix it by removing quiesce queue around
elevator_set_none()becauseelevator_switch()does quiesce queue in case that we need to switch to none really.Fixes 1e44bedbc921 ("block: unifying elevator change")Signed-off-by Ming Lei <[email protected]>
Maybe you should add a link to the issue this commit fixed. I just saw Shinichiro reproduced it here [1].
[1] https://lore.kernel.org/all/mlycu6p6zl5z5mmqau7otbfw35kcvnajpsnm3hokpfnafc3bwh@m5dp43ypdfpz/
Otherwise changes look good to me:
Re: [PATCH 1/2] block: don't quiesce queue for calling elevator_set_none()
In reply to Ming LeiLooks good:
PATCH 2/2 block: move removing elevator after deleting disk->queue_kobj
In reply to Ming LeiWhen blk_unregister_queue() is called from add_disk() failure path, there is race in registering/unregistering elevator queue kobject from the two code paths, because commit 559dc11143eb ("block: move elv_register[unregister]_queue out of elevator_lock") moves elevator queue register/unregister out of elevator lock.
Fix the race by removing elevator after deleting disk->queue_kobj, because kobject_del(&disk->queue_kobj) drains in-progress sysfs show()/store() of all attributes.
--- block/blk-sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
block/blk-sysfs.c +3 -3
@@ -948,9 +948,6 @@ void blk_unregister_queue(struct gendisk *disk)blk_mq_sysfs_unregister (disk);blk_crypto_sysfs_unregister (disk); -if (queue_is_mq (q)) -elevator_set_none (q); -mutex_lock (&q->sysfs_lock);disk_unregister_independent_access_ranges (disk);mutex_unlock (&q->sysfs_lock);
@@ -959,5 +956,8 @@ void blk_unregister_queue(struct gendisk *disk)kobject_uevent (&disk->queue_kobj,KOBJ_REMOVE );kobject_del (&disk->queue_kobj); +if (queue_is_mq (q)) +elevator_set_none (q); +blk_debugfs_remove (disk); }
Signature · 1 line
2.47.0
Re: [PATCH 2/2] block: move removing elevator after deleting disk->queue_kobj
Quoted 6 lines · Ming Lei
When
blk_unregister_queue()is called fromadd_disk()failure path, there is race in registering/unregistering elevator queue kobject from the two code paths, because commit559dc11143eb("block: move elv_register[unregister]_queue out ofelevator_lock") moves elevator queue register/unregister out of elevator lock.
Quoted 8 lines
Fix the race by removing elevator after deleting
disk->queue_kobj, becausekobject_del(&disk->queue_kobj)drains in-progress sysfs show()/store() of all attributes.Fixes 559dc11143eb ("block: move elv_register[unregister]_queue out of elevator_lock")Reported-by Nilay Shroff <[email protected]>Suggested-by Nilay Shroff <[email protected]>Signed-off-by Ming Lei <[email protected]>
Looks good to me:
Re: [PATCH 2/2] block: move removing elevator after deleting disk->queue_kobj
In reply to Ming LeiLooks good:
Quoted 8 lines · Ming Lei
The 1st patch fixes one hang in
del_gendisk().The 2nd patch fixes one race in case that
add_disk()fails.Thanks,
Ming[...]
Applied, thanks!
[1/2] block: don't quiesce queue for calling elevator_set_none()
commit: 8336d18c6b57a603aaa4db76bbf4f8cb08acfa5e
[2/2] block: move removing elevator after deleting disk->queue_kobj
commit: 824afb9b04648ea11531fc9047923ec07e7a943dBest regards,
Signature · 1 line
Jens Axboe