Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 456ce3aa authored by Martijn Coenen's avatar Martijn Coenen Committed by Alistair Delva
Browse files

UPSTREAM: loop: Only change blocksize when needed.



Return early in loop_set_block_size() if the requested block size is
identical to the one we already have; this avoids expensive calls to
freeze the block queue.

Bug: 148607611
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartijn Coenen <maco@android.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
(cherry picked from commit 7e81f99afd91c937f0e66dc135e26c1c4f78b003)
Change-Id: I61778680579dbfeeb193133527a3926d376e0bac
parent 182b38fc
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1490,16 +1490,16 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
	if (arg < 512 || arg > PAGE_SIZE || !is_power_of_2(arg))
		return -EINVAL;

	if (lo->lo_queue->limits.logical_block_size != arg) {
	if (lo->lo_queue->limits.logical_block_size == arg)
		return 0;

	sync_blockdev(lo->lo_device);
	kill_bdev(lo->lo_device);
	}

	blk_mq_freeze_queue(lo->lo_queue);

	/* kill_bdev should have truncated all the pages */
	if (lo->lo_queue->limits.logical_block_size != arg &&
			lo->lo_device->bd_inode->i_mapping->nrpages) {
	if (lo->lo_device->bd_inode->i_mapping->nrpages) {
		err = -EAGAIN;
		pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
			__func__, lo->lo_number, lo->lo_file_name,