Skip to content

Commit 97dd4a4

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4ce37fe commit 97dd4a4

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

drivers/block/loop.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -916,24 +916,6 @@ static void loop_free_idle_workers_timer(struct timer_list *timer)
916916
return loop_free_idle_workers(lo, false);
917917
}
918918

919-
static void loop_update_rotational(struct loop_device *lo)
920-
{
921-
struct file *file = lo->lo_backing_file;
922-
struct inode *file_inode = file->f_mapping->host;
923-
struct block_device *file_bdev = file_inode->i_sb->s_bdev;
924-
struct request_queue *q = lo->lo_queue;
925-
bool nonrot = true;
926-
927-
/* not all filesystems (e.g. tmpfs) have a sb->s_bdev */
928-
if (file_bdev)
929-
nonrot = bdev_nonrot(file_bdev);
930-
931-
if (nonrot)
932-
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
933-
else
934-
blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
935-
}
936-
937919
/**
938920
* loop_set_status_from_info - configure device from loop_info
939921
* @lo: struct loop_device to configure
@@ -1003,6 +985,10 @@ static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize)
1003985
lim.logical_block_size = bsize;
1004986
lim.physical_block_size = bsize;
1005987
lim.io_min = bsize;
988+
if (!backing_bdev || bdev_nonrot(backing_bdev))
989+
blk_queue_flag_set(QUEUE_FLAG_NONROT, lo->lo_queue);
990+
else
991+
blk_queue_flag_clear(QUEUE_FLAG_NONROT, lo->lo_queue);
1006992
loop_config_discard(lo, &lim);
1007993
return queue_limits_commit_update(lo->lo_queue, &lim);
1008994
}
@@ -1099,7 +1085,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
10991085
if (WARN_ON_ONCE(error))
11001086
goto out_unlock;
11011087

1102-
loop_update_rotational(lo);
11031088
loop_update_dio(lo);
11041089
loop_sysfs_init(lo);
11051090

0 commit comments

Comments
 (0)