Skip to content

Commit 8e604ca

Browse files
wangli5665axboe
authored andcommitted
loop: fix type of block size
PAGE_SIZE may be 64K, and the max block size can be PAGE_SIZE, so any variable for holding block size can't be defined as 'unsigned short'. Unfortunately commit 473516b ("loop: use the atomic queue limits update API") passes 'bsize' with type of 'unsigned short' to loop_reconfigure_limits(), and causes LTP/ioctl_loop06 test failure: 12 ioctl_loop06.c:76: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE 13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly ... 18 ioctl_loop06.c:76: TINFO: Using LOOP_CONFIGURE with block_size > PAGE_SIZE 19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly Fixes the issue by defining 'block size' variable with 'unsigned int', which is aligned with block layer's definition. (improve commit log & add fixes tag) Fixes: 473516b ("loop: use the atomic queue limits update API") Cc: John Garry <[email protected]> Cc: Stefan Hajnoczi <[email protected]> Cc: Christoph Hellwig <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Jan Stancek <[email protected]> Signed-off-by: Li Wang <[email protected]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 357e1b7 commit 8e604ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/block/loop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static loff_t get_loop_size(struct loop_device *lo, struct file *file)
173173
static bool lo_bdev_can_use_dio(struct loop_device *lo,
174174
struct block_device *backing_bdev)
175175
{
176-
unsigned short sb_bsize = bdev_logical_block_size(backing_bdev);
176+
unsigned int sb_bsize = bdev_logical_block_size(backing_bdev);
177177

178178
if (queue_logical_block_size(lo->lo_queue) < sb_bsize)
179179
return false;
@@ -976,7 +976,7 @@ loop_set_status_from_info(struct loop_device *lo,
976976
return 0;
977977
}
978978

979-
static unsigned short loop_default_blocksize(struct loop_device *lo,
979+
static unsigned int loop_default_blocksize(struct loop_device *lo,
980980
struct block_device *backing_bdev)
981981
{
982982
/* In case of direct I/O, match underlying block size */
@@ -985,7 +985,7 @@ static unsigned short loop_default_blocksize(struct loop_device *lo,
985985
return SECTOR_SIZE;
986986
}
987987

988-
static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize)
988+
static int loop_reconfigure_limits(struct loop_device *lo, unsigned int bsize)
989989
{
990990
struct file *file = lo->lo_backing_file;
991991
struct inode *inode = file->f_mapping->host;

0 commit comments

Comments
 (0)