Commit 1fe0b1ac authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

loop: only freeze the queue in __loop_clr_fd when needed

->release is only called after all outstanding I/O has completed, so only
freeze the queue when clearing the backing file of a live loop device.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Tested-by: default avatarDarrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20220330052917.2566582-11-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 46dc9674
...@@ -1139,7 +1139,12 @@ static void __loop_clr_fd(struct loop_device *lo, bool release) ...@@ -1139,7 +1139,12 @@ static void __loop_clr_fd(struct loop_device *lo, bool release)
if (test_bit(QUEUE_FLAG_WC, &lo->lo_queue->queue_flags)) if (test_bit(QUEUE_FLAG_WC, &lo->lo_queue->queue_flags))
blk_queue_write_cache(lo->lo_queue, false, false); blk_queue_write_cache(lo->lo_queue, false, false);
/* freeze request queue during the transition */ /*
* Freeze the request queue when unbinding on a live file descriptor and
* thus an open device. When called from ->release we are guaranteed
* that there is no I/O in progress already.
*/
if (!release)
blk_mq_freeze_queue(lo->lo_queue); blk_mq_freeze_queue(lo->lo_queue);
destroy_workqueue(lo->workqueue); destroy_workqueue(lo->workqueue);
...@@ -1165,6 +1170,7 @@ static void __loop_clr_fd(struct loop_device *lo, bool release) ...@@ -1165,6 +1170,7 @@ static void __loop_clr_fd(struct loop_device *lo, bool release)
mapping_set_gfp_mask(filp->f_mapping, gfp); mapping_set_gfp_mask(filp->f_mapping, gfp);
/* This is safe: open() is still holding a reference. */ /* This is safe: open() is still holding a reference. */
module_put(THIS_MODULE); module_put(THIS_MODULE);
if (!release)
blk_mq_unfreeze_queue(lo->lo_queue); blk_mq_unfreeze_queue(lo->lo_queue);
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE); disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment