Commit 0fbcf579 authored by Martijn Coenen's avatar Martijn Coenen Committed by Jens Axboe
Browse files

loop: Only freeze block queue when needed.



__loop_update_dio() can be called as a part of loop_set_fd(), when the
block queue is not yet up and running; avoid freezing the block queue in
that case, since that is an expensive operation.

Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarMartijn Coenen <maco@android.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7e81f99a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
	 * LO_FLAGS_READ_ONLY, both are set from kernel, and losetup
	 * will get updated by ioctl(LOOP_GET_STATUS)
	 */
	if (lo->lo_state == Lo_bound)
		blk_mq_freeze_queue(lo->lo_queue);
	lo->use_dio = use_dio;
	if (use_dio) {
@@ -223,6 +224,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
		blk_queue_flag_set(QUEUE_FLAG_NOMERGES, lo->lo_queue);
		lo->lo_flags &= ~LO_FLAGS_DIRECT_IO;
	}
	if (lo->lo_state == Lo_bound)
		blk_mq_unfreeze_queue(lo->lo_queue);
}