Commit ae0d40ff authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

loop: always update discard settings in loop_reconfigure_limits

Simplify loop_reconfigure_limits by always updating the discard limits.
This adds a little more work to loop_set_block_size, but doesn't change
the outcome as the discard flag won't change.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240617060532.127975-6-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c9055b44
...@@ -975,8 +975,7 @@ loop_set_status_from_info(struct loop_device *lo, ...@@ -975,8 +975,7 @@ loop_set_status_from_info(struct loop_device *lo,
return 0; return 0;
} }
static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize, static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize)
bool update_discard_settings)
{ {
struct queue_limits lim; struct queue_limits lim;
...@@ -984,8 +983,7 @@ static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize, ...@@ -984,8 +983,7 @@ static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize,
lim.logical_block_size = bsize; lim.logical_block_size = bsize;
lim.physical_block_size = bsize; lim.physical_block_size = bsize;
lim.io_min = bsize; lim.io_min = bsize;
if (update_discard_settings) loop_config_discard(lo, &lim);
loop_config_discard(lo, &lim);
return queue_limits_commit_update(lo->lo_queue, &lim); return queue_limits_commit_update(lo->lo_queue, &lim);
} }
...@@ -1086,7 +1084,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, ...@@ -1086,7 +1084,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
else else
bsize = 512; bsize = 512;
error = loop_reconfigure_limits(lo, bsize, true); error = loop_reconfigure_limits(lo, bsize);
if (WARN_ON_ONCE(error)) if (WARN_ON_ONCE(error))
goto out_unlock; goto out_unlock;
...@@ -1496,7 +1494,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg) ...@@ -1496,7 +1494,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
invalidate_bdev(lo->lo_device); invalidate_bdev(lo->lo_device);
blk_mq_freeze_queue(lo->lo_queue); blk_mq_freeze_queue(lo->lo_queue);
err = loop_reconfigure_limits(lo, arg, false); err = loop_reconfigure_limits(lo, arg);
loop_update_dio(lo); loop_update_dio(lo);
blk_mq_unfreeze_queue(lo->lo_queue); blk_mq_unfreeze_queue(lo->lo_queue);
......
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