Skip to contentSkip to conversation

loop: Increase bsize variable from unsigned short to unsigned int

PATCH Superseded Li Wang 4 participants 8 messages Aug 27, 2024 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 loop: Increase bsize variable from unsigned short to unsigned int

This change allows the loopback driver to handle larger block sizes and increases the consistency of data types used within the driver. Especially to mactch the struct queue_limits.logical_block_size type.

Also, this is to get rid of the 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

---
 drivers/block/loop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/loop.c +3 -3
index 78a7bb28defe..86cc3b19faae 100644
@@ -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;
@@ -977,7 +977,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 */
@@ -986,7 +986,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;
Signature · 1 line
2.46.0
author
#1 lore raw

Adding Jens Axboe and [email protected] ML.

Quoted 67 lines · Li Wang

This change allows the loopback driver to handle larger block sizes and increases the consistency of data types used within the driver. Especially to mactch the struct queue_limits.logical_block_size type.

Also, this is to get rid of the 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

---
 drivers/block/loop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/loop.c +1 -1
index 78a7bb28defe..86cc3b19faae 100644
@@ -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;
drivers/block/loop.c +2 -2
@@ -977,7 +977,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 */
@@ -986,7 +986,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;

--
2.46.0

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#2 lore raw
In reply to Li Wang
Quoted 12 lines · Li Wang

This change allows the loopback driver to handle larger block sizes and increases the consistency of data types used within the driver. Especially to mactch the struct queue_limits.logical_block_size type.

Also, this is to get rid of the 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

Quoted 6 lines

Looks OK to me.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 1/1
#3 lore raw
In reply to Li Wang
Quoted 4 lines · Li Wang

This change allows the loopback driver to handle larger block sizes and increases the consistency of data types used within the driver. Especially to mactch the struct queue_limits.logical_block_size type.

^^ small typo here, extra 'c' in "match"

Quoted 9 lines

Also, this is to get rid of the 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

Quoted 6 lines
#4 lore raw
In reply to Li Wang

On 27/08/2024 04:22, Li Wang wrote:

+linux-block, Jens

Quoted 1 line

This change allows the loopback driver to handle larger block sizes

larger than what? PAGE_SIZE?

Quoted 52 lines

and increases the consistency of data types used within the driver. Especially to mactch the struct queue_limits.logical_block_size type.

Also, this is to get rid of the 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

---
  drivers/block/loop.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/loop.c +3 -3
index 78a7bb28defe..86cc3b19faae 100644
@@ -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;
@@ -977,7 +977,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 */
@@ -986,7 +986,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;
author
#5 lore raw
Quoted 8 lines · John Garry

On 27/08/2024 04:22, Li Wang wrote:

+linux-block, Jens

Quoted 1 line

This change allows the loopback driver to handle larger block sizes

larger than what? PAGE_SIZE?

Yes, system should return EINVAL when the tested bsize is larger than PAGE_SIZE. But due to the loop_reconfigure_limits() cast it to 'unsined short' that never gets an expected error when testing invalid logical block size.

That's why LTP/ioctl_loop06 failed on a system with 64k (ppc64le) pagesize (since kernel-v6.11-rc1 with patches):

9423c653fe6110 ("loop: Don't bother validating blocksize") fe3d508ba95bc6 ("block: Validate logical block size in blk_validate_limits()")

--
Regards,
Li Wang

#6 lore raw
Quoted 11 lines · Li Wang
Quoted 8 lines · John Garry

On 27/08/2024 04:22, Li Wang wrote:

+linux-block, Jens

Quoted 1 line

This change allows the loopback driver to handle larger block sizes

larger than what? PAGE_SIZE?

Yes,

Please then explicitly mention that

Quoted 11 lines

system should return EINVAL when the tested bsize is larger than PAGE_SIZE. But due to the loop_reconfigure_limits() cast it to 'unsined short' that never gets an expected error when testing invalid logical block size.> That's why LTP/ioctl_loop06 failed on a system with 64k (ppc64le) pagesize (since kernel-v6.11-rc1 with patches):

9423c653fe6110 ("loop: Don't bother validating blocksize") fe3d508ba95bc6 ("block: Validate logical block size in blk_validate_limits()")

I feel that you should be adding a fixes tag, but it seems that those commits only expose the issue, and whatever introduced unsigned short usage was not right. Maybe you can just get this included for 6.11, where 9423c653fe6110 was introduced.

Thanks,
John

author
#7 lore raw
Quoted 7 lines · John Garry
Quoted 6 lines · Li Wang
Quoted 5 lines · John Garry

On 27/08/2024 04:22, Li Wang wrote:

+linux-block, Jens

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

This change allows the loopback driver to handle larger block sizes

larger than what? PAGE_SIZE?

Yes,

Please then explicitly mention that

Sure.

Quoted 13 lines
Quoted 12 lines

system should return EINVAL when the tested bsize is larger than PAGE_SIZE. But due to the loop_reconfigure_limits() cast it to 'unsined short' that never gets an expected error when testing invalid logical block size.> That's why LTP/ioctl_loop06 failed on a system with 64k (ppc64le) pagesize (since kernel-v6.11-rc1 with patches):

9423c653fe6110 ("loop: Don't bother validating blocksize") fe3d508ba95bc6 ("block: Validate logical block size in blk_validate_limits()")

Quoted 4 lines

I feel that you should be adding a fixes tag, but it seems that those commits only expose the issue, and whatever introduced unsigned short usage was not right. Maybe you can just get this included for 6.11, where 9423c653fe6110 was introduced.

Ok, we can mention that two commits exposed the problem since v6.11-rc1. I will send V2 including that. Thanks!

Signature · 2 lines
Regards,
Li Wang