Commit 97dd4a43 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

loop: fold loop_update_rotational into loop_reconfigure_limits

This prepares for moving the rotational flag into the queue_limits and
also fixes it for the case where the loop device is backed by a block
device.
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-9-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4ce37fe0
...@@ -916,24 +916,6 @@ static void loop_free_idle_workers_timer(struct timer_list *timer) ...@@ -916,24 +916,6 @@ static void loop_free_idle_workers_timer(struct timer_list *timer)
return loop_free_idle_workers(lo, false); return loop_free_idle_workers(lo, false);
} }
static void loop_update_rotational(struct loop_device *lo)
{
struct file *file = lo->lo_backing_file;
struct inode *file_inode = file->f_mapping->host;
struct block_device *file_bdev = file_inode->i_sb->s_bdev;
struct request_queue *q = lo->lo_queue;
bool nonrot = true;
/* not all filesystems (e.g. tmpfs) have a sb->s_bdev */
if (file_bdev)
nonrot = bdev_nonrot(file_bdev);
if (nonrot)
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
else
blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
}
/** /**
* loop_set_status_from_info - configure device from loop_info * loop_set_status_from_info - configure device from loop_info
* @lo: struct loop_device to configure * @lo: struct loop_device to configure
...@@ -1003,6 +985,10 @@ static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize) ...@@ -1003,6 +985,10 @@ 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 (!backing_bdev || bdev_nonrot(backing_bdev))
blk_queue_flag_set(QUEUE_FLAG_NONROT, lo->lo_queue);
else
blk_queue_flag_clear(QUEUE_FLAG_NONROT, lo->lo_queue);
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);
} }
...@@ -1099,7 +1085,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, ...@@ -1099,7 +1085,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
if (WARN_ON_ONCE(error)) if (WARN_ON_ONCE(error))
goto out_unlock; goto out_unlock;
loop_update_rotational(lo);
loop_update_dio(lo); loop_update_dio(lo);
loop_sysfs_init(lo); loop_sysfs_init(lo);
......
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