diff mbox series

[V3] loop: fix type of block size

Message ID 20241109022744.1126003-1-ming.lei@redhat.com (mailing list archive)
State New
Headers show
Series [V3] loop: fix type of block size | expand

Commit Message

Ming Lei Nov. 9, 2024, 2:27 a.m. UTC
From: Li Wang <liwang@redhat.com>

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 473516b36193 ("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.

Fixes: 473516b36193 ("loop: use the atomic queue limits update API")
Cc: John Garry <john.g.garry@oracle.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
(improve commit log & add fixes tag)
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
V3:
	- improve commit log
	- add fixes tag

 drivers/block/loop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jens Axboe Nov. 10, 2024, 3:07 a.m. UTC | #1
On Sat, 09 Nov 2024 10:27:44 +0800, Ming Lei wrote:
> 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 473516b36193 ("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:
> 
> [...]

Applied, thanks!

[1/1] loop: fix type of block size
      commit: 8e604cac499248c75ad3a26695a743ff879ded5c

Best regards,
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index f21f4254b038..fe9bb4fb5f1b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -173,7 +173,7 @@  static loff_t get_loop_size(struct loop_device *lo, struct file *file)
 static bool lo_bdev_can_use_dio(struct loop_device *lo,
 		struct block_device *backing_bdev)
 {
-	unsigned short sb_bsize = bdev_logical_block_size(backing_bdev);
+	unsigned int sb_bsize = bdev_logical_block_size(backing_bdev);
 
 	if (queue_logical_block_size(lo->lo_queue) < sb_bsize)
 		return false;
@@ -976,7 +976,7 @@  loop_set_status_from_info(struct loop_device *lo,
 	return 0;
 }
 
-static unsigned short loop_default_blocksize(struct loop_device *lo,
+static unsigned int loop_default_blocksize(struct loop_device *lo,
 		struct block_device *backing_bdev)
 {
 	/* In case of direct I/O, match underlying block size */
@@ -985,7 +985,7 @@  static unsigned short loop_default_blocksize(struct loop_device *lo,
 	return SECTOR_SIZE;
 }
 
-static int loop_reconfigure_limits(struct loop_device *lo, unsigned short bsize)
+static int loop_reconfigure_limits(struct loop_device *lo, unsigned int bsize)
 {
 	struct file *file = lo->lo_backing_file;
 	struct inode *inode = file->f_mapping->host;