ioctl_loop06: update loopback block size validation
PATCH v2 1/1 ioctl_loop06: update loopback block size validation
The kernel commit 47dd6753 ("block/bdev: lift block size restrictions to 64k") now supports block sizes larger than PAGE_SIZE, with a new upper limit of BLK_MAX_BLOCK_SIZE (64K). But ioctl_loop06 still assumes that PAGE_SIZE is the maximum allowed block size, causing failures on newer kernels(>= 6.14):
ioctl_loop06.c:74: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: Using LOOP_CONFIGURE with block_size > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
This patch updates ioctl_loop06 to use BLK_MAX_BLOCK_SIZE instead of PAGE_SIZE for block size validation.
And, we give up the test size between (PAGE_SIZE, BLK_MAX_BLOCK_SIZE) even on old kernels becase it makes no sense.
--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +5 -3
@@ -17,6 +17,8 @@#include "lapi/loop.h" #include "tst_test.h" +#define BLK_MAX_BLOCK_SIZE 0x00010000/* SZ_64K */ +static char dev_path[1024 ];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;
@@ -31,7 +33,7 @@ static struct tcase { "Using LOOP_SET_BLOCK_SIZE with arg < 512"}, {&invalid_value,LOOP_SET_BLOCK_SIZE , - "Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE"}, + "Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_SET_BLOCK_SIZE, "Using LOOP_SET_BLOCK_SIZE with arg != power_of_2"},
@@ -40,7 +42,7 @@ static struct tcase { "Using LOOP_CONFIGURE with block_size < 512"}, {&invalid_value,LOOP_CONFIGURE , - "Using LOOP_CONFIGURE with block_size > PAGE_SIZE"}, + "Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_CONFIGURE, "Using LOOP_CONFIGURE with block_size != power_of_2"},
@@ -106,7 +108,7 @@ static void setup(void)tst_fill_file ("test.img" ,0 ,1024 ,1024 ); half_value =256 ; pg_size =getpagesize (); - invalid_value = pg_size *2 ; + invalid_value =BLK_MAX_BLOCK_SIZE +1 ; unalign_value = pg_size -1 ; dev_fd =SAFE_OPEN (dev_path,O_RDWR );
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 30 lines · Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to 64k") now supports block sizes larger thanPAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEis the maximum allowed block size, causing failures on newer kernels(>= 6.14):ioctl_loop06.c:74: TINFO: Using
LOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedlyThis patch updates
ioctl_loop06to useBLK_MAX_BLOCK_SIZEinstead ofPAGE_SIZEfor block size validation.And, we give up the test size between (
PAGE_SIZE,BLK_MAX_BLOCK_SIZE) even on old kernels becase it makes no sense.Signed-off-by Li Wang <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)testcases/kernel/syscalls/ioctl/ioctl_loop06.c +0
-0
testcases/kernel/syscalls/ioctl/ioctl_loop06.c line 20
Quoted 4 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-0@@ -17,6 +17,8 @@#include "lapi/loop.h" #include "tst_test.h" +#define BLK_MAX_BLOCK_SIZE 0x00010000/* SZ_64K */
Today its SZ_64K, tomorrow another value. If you have an ifdef check for kernel versions it may be good to do that. So if >= v6.15 then 64k othersize PAGE_SIZE is fine.
Quoted 23 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +3
-2+static char dev_path[1024 ];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;@@ -31,7 +33,7 @@ static struct tcase { "Using LOOP_SET_BLOCK_SIZE with arg < 512"}, {&invalid_value,LOOP_SET_BLOCK_SIZE , - "Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE"}, + "Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_SET_BLOCK_SIZE, "Using LOOP_SET_BLOCK_SIZE with arg != power_of_2"},@@ -40,7 +42,7 @@ static struct tcase { "Using LOOP_CONFIGURE with block_size < 512"}, {&invalid_value,LOOP_CONFIGURE , - "Using LOOP_CONFIGURE with block_size > PAGE_SIZE"}, + "Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_CONFIGURE, "Using LOOP_CONFIGURE with block_size != power_of_2"},
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static void setup(void) · line 111
Quoted 5 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-1@@ -106,7 +108,7 @@ static void setup(void)tst_fill_file ("test.img" ,0 ,1024 ,1024 ); half_value =256 ; pg_size =getpagesize (); - invalid_value = pg_size *2 ; + invalid_value =BLK_MAX_BLOCK_SIZE +1 ;
I'd use BLK_MAX_BLOCK_SIZE * 2 as we use power of 2 values;
Luis
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Luis,
Quoted 8 lines · Luis Chamberlain
Quoted 1 line · Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to64k")
Quoted 2 lines
now supports block sizes larger than
PAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEis the
Quoted 1 line
maximum allowed block size, causing failures on newer kernels(>= 6.14):
Well, this sounds like we need to go back to patch v1:
https://lists.linux.it/pipermail/ltp/2025-March/042599.html
Note: LTP has a function tst_kvercmp() for comparing kernel versions.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 ioctl_loop06: update loopback block size validation
The kernel commit 47dd6753 ("block/bdev: lift block size restrictions to 64k") now supports block sizes larger than PAGE_SIZE, with a new upper limit of BLK_MAX_BLOCK_SIZE (64K). But ioctl_loop06 still assumes that PAGE_SIZE is the maximum allowed block size, causing failures on newer kernels(>= 6.14):
ioctl_loop06.c:74: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: Using LOOP_CONFIGURE with block_size > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
This patch updates ioctl_loop06 to use BLK_MAX_BLOCK_SIZE instead of PAGE_SIZE for block size validation. Also adjust failure expectations based on the running kernel version.
---
Notes:
v2 --> v3:
* adding back the kernel version check to compare max value
* use BLK_MAX_BLOCK_SIZE * 2 as Luis suggestted
testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +5 -3
@@ -17,6 +17,8 @@#include "lapi/loop.h" #include "tst_test.h" +#define BLK_MAX_BLOCK_SIZE 0x00010000/* SZ_64K */ +static char dev_path[1024 ];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;
@@ -31,7 +33,7 @@ static struct tcase { "Using LOOP_SET_BLOCK_SIZE with arg < 512"}, {&invalid_value,LOOP_SET_BLOCK_SIZE , - "Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE"}, + "Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_SET_BLOCK_SIZE, "Using LOOP_SET_BLOCK_SIZE with arg != power_of_2"},
@@ -40,7 +42,7 @@ static struct tcase { "Using LOOP_CONFIGURE with block_size < 512"}, {&invalid_value,LOOP_CONFIGURE , - "Using LOOP_CONFIGURE with block_size > PAGE_SIZE"}, + "Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_CONFIGURE, "Using LOOP_CONFIGURE with block_size != power_of_2"},
@@ -106,8 +108,8 @@ static void setup(void)tst_fill_file ("test.img" ,0 ,1024 ,1024 ); half_value =256 ; pg_size =getpagesize (); - invalid_value = pg_size *2 ; unalign_value = pg_size -1 ; + invalid_value = (tst_kvercmp (6 ,14 ,0 ) <0 ) ? pg_size *2 :BLK_MAX_BLOCK_SIZE *2 ; dev_fd =SAFE_OPEN (dev_path,O_RDWR ); ret =ioctl (dev_fd,LOOP_SET_BLOCK_SIZE ,512 );
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/1 ioctl_loop06: update loopback block size validation
The kernel commit 47dd6753 ("block/bdev: lift block size restrictions to 64k") now supports block sizes larger than PAGE_SIZE, with a new upper limit of BLK_MAX_BLOCK_SIZE (64K). But ioctl_loop06 still assumes that PAGE_SIZE is the maximum allowed block size, causing failures on newer kernels(>= 6.14):
ioctl_loop06.c:74: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: Using LOOP_CONFIGURE with block_size > PAGE_SIZE ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
This patch updates ioctl_loop06 to use BLK_MAX_BLOCK_SIZE instead of PAGE_SIZE for block size validation.
And, dynamically sets bs based on BLK_MAX_BLOCK_SIZE, using 1024 bytes if it's below 1MB or scaling it otherwise. Ensures tst_fill_file() writes efficiently while maintaining compatibility across different kernel versions.
--- configure.ac | 1 + include/lapi/blkdev.h | 19 +++++++++++++++++++ .../kernel/syscalls/ioctl/ioctl_loop06.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 include/lapi/blkdev.h
configure.ac +1 -0
@@ -52,6 +52,7 @@ AC_CHECK_HEADERS_ONCE([ \ emmintrin.h \ ifaddrs.h \ keyutils.h \ + linux/blkdev.h \ linux/can.h \ linux/cgroupstats.h \ linux/cryptouser.h \
include/lapi/blkdev.h new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2025 Linux Test Project +* Li Wang <[email protected]> +*/ + +#ifndef LAPI_BLKDEV_H__ +#define LAPI_BLKDEV_H__ + +#ifdef HAVE_LINUX_BLKDEV_H +#include <linux/blkdev.h> +#endif + +/* Define BLK_MAX_BLOCK_SIZE for older kernels */ +#ifndef BLK_MAX_BLOCK_SIZE +#define BLK_MAX_BLOCK_SIZE 0x00010000/* 64K */ +#endif + +#endif /* LAPI_BLKDEV_H */
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +8 -4
@@ -14,7 +14,9 @@#include <unistd.h> #include <sys/types.h> #include <stdlib.h> +#include "lapi/blkdev.h" #include "lapi/loop.h" +#include "tst_fs.h" #include "tst_test.h" static char dev_path[1024 ];
@@ -31,7 +33,7 @@ static struct tcase { "Using LOOP_SET_BLOCK_SIZE with arg < 512"}, {&invalid_value,LOOP_SET_BLOCK_SIZE , - "Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE"}, + "Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_SET_BLOCK_SIZE, "Using LOOP_SET_BLOCK_SIZE with arg != power_of_2"},
@@ -40,7 +42,7 @@ static struct tcase { "Using LOOP_CONFIGURE with block_size < 512"}, {&invalid_value,LOOP_CONFIGURE , - "Using LOOP_CONFIGURE with block_size > PAGE_SIZE"}, + "Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_CONFIGURE, "Using LOOP_CONFIGURE with block_size != power_of_2"},
@@ -103,10 +105,12 @@ static void setup(void)if (dev_num <0 )tst_brk (TBROK ,"Failed to find free loop device" ); -tst_fill_file ("test.img" ,0 ,1024 ,1024 ); +size_t bs = (BLK_MAX_BLOCK_SIZE <TST_MB ) ?1024 :4 *BLK_MAX_BLOCK_SIZE /1024 ; +tst_fill_file ("test.img" ,0 , bs,1024 ); + half_value =256 ; pg_size =getpagesize (); - invalid_value = pg_size *2 ; + invalid_value =BLK_MAX_BLOCK_SIZE *2 ; unalign_value = pg_size -1 ; dev_fd =SAFE_OPEN (dev_path,O_RDWR );
Signature · 5 lines
2.48.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Li,
Quoted 11 lines
The kernel commit
47dd6753("block/bdev: lift block size restrictions to 64k") now supports block sizes larger thanPAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEis the maximum allowed block size, causing failures on newer kernels(>= 6.14):ioctl_loop06.c:74: TINFO: Using
LOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
Quoted 6 lines
This patch updates
ioctl_loop06to useBLK_MAX_BLOCK_SIZEinstead ofPAGE_SIZEfor block size validation.And, dynamically sets bs based on
BLK_MAX_BLOCK_SIZE, using 1024 bytes if it's below 1MB or scaling it otherwise. Ensurestst_fill_file()writes efficiently while maintaining compatibility across different kernel versions.
LGTM.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 14 lines · CEST Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to 64k") now supports block sizes larger thanPAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEis the maximum allowed block size, causing failures on newer kernels(>= 6.14):ioctl_loop06.c:74: TINFO: Using
LOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZEioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedlyThis patch updates
ioctl_loop06to useBLK_MAX_BLOCK_SIZEinstead ofPAGE_SIZEfor block size validation.
Quoted 8 lines
And, dynamically sets bs based on
BLK_MAX_BLOCK_SIZE, using 1024 bytes if it's below 1MB or scaling it otherwise. Ensurestst_fill_file()writes efficiently while maintaining compatibility across different kernel versions.Signed-off-by Li Wang <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>
tst_tmpdir.c:316: TINFO: Using /tmp/LTP_iocxHZLn0 as tmpdir (tmpfs filesystem)
tst_test.c:1905: TINFO: LTP version: 20250130
tst_test.c:1909: TINFO: Tested kernel: 6.15.0-rc1-1.ge4c97fd-default #1 SMP PREEMPT_DYNAMIC Mon Apr 7 21:58:09 UTC 2025 (e4c97fd) x86_64 tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution tst_test.c:1722: TINFO: Overall timeout per run is 0h 02m 00s
tst_device.c:98: TINFO: Found free device 1 '/dev/loop1'
ioctl_loop06_new.c:76: TINFO: Using LOOP_SET_BLOCK_SIZE with arg < 512
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
ioctl_loop06_new.c:76: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
ioctl_loop06_new.c:76: TINFO: Using LOOP_SET_BLOCK_SIZE with arg != power_of_2
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
ioctl_loop06_new.c:76: TINFO: Using LOOP_CONFIGURE with block_size < 512
tst_device.c:255: TINFO: ioctl return: 0: ECHILD (10)
tst_device.c:255: TINFO: ioctl return: 0: ECHILD (10)
tst_device.c:255: TINFO: ioctl return: -1: ENXIO (6)
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
ioctl_loop06_new.c:76: TINFO: Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
ioctl_loop06_new.c:76: TINFO: Using LOOP_CONFIGURE with block_size != power_of_2
ioctl_loop06_new.c:67: TPASS: Set block size failed as expected: EINVAL (22)
Summary:
passed 6 failed 0 broken 0 skipped 0
warnings 0
Quoted 92 lines
--- configure.ac | 1 + include/lapi/blkdev.h | 19 +++++++++++++++++++ .../kernel/syscalls/ioctl/ioctl_loop06.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 include/lapi/blkdev.hconfigure.ac +1
-0@@ -52,6 +52,7 @@ AC_CHECK_HEADERS_ONCE([ \ emmintrin.h \ ifaddrs.h \ keyutils.h \ + linux/blkdev.h \ linux/can.h \ linux/cgroupstats.h \ linux/cryptouser.h \include/lapi/blkdev.h new file +19
-0@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2025 Linux Test Project +* Li Wang <[email protected]> +*/ + +#ifndef LAPI_BLKDEV_H__ +#define LAPI_BLKDEV_H__ + +#ifdef HAVE_LINUX_BLKDEV_H +#include <linux/blkdev.h> +#endif + +/* Define BLK_MAX_BLOCK_SIZE for older kernels */ +#ifndef BLK_MAX_BLOCK_SIZE +#define BLK_MAX_BLOCK_SIZE 0x00010000/* 64K */ +#endif + +#endif /* LAPI_BLKDEV_H */ testcases/kernel/syscalls/ioctl/ioctl_loop06.c +8
-4@@ -14,7 +14,9 @@#include <unistd.h> #include <sys/types.h> #include <stdlib.h> +#include "lapi/blkdev.h" #include "lapi/loop.h" +#include "tst_fs.h" #include "tst_test.h" static char dev_path[1024 ];@@ -31,7 +33,7 @@ static struct tcase { "Using LOOP_SET_BLOCK_SIZE with arg < 512"}, {&invalid_value,LOOP_SET_BLOCK_SIZE , - "Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE"}, + "Using LOOP_SET_BLOCK_SIZE with arg > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_SET_BLOCK_SIZE, "Using LOOP_SET_BLOCK_SIZE with arg != power_of_2"},@@ -40,7 +42,7 @@ static struct tcase { "Using LOOP_CONFIGURE with block_size < 512"}, {&invalid_value,LOOP_CONFIGURE , - "Using LOOP_CONFIGURE with block_size > PAGE_SIZE"}, + "Using LOOP_CONFIGURE with block_size > BLK_MAX_BLOCK_SIZE"}, {&unalign_value, LOOP_CONFIGURE, "Using LOOP_CONFIGURE with block_size != power_of_2"},@@ -103,10 +105,12 @@ static void setup(void)if (dev_num <0 )tst_brk (TBROK ,"Failed to find free loop device" ); -tst_fill_file ("test.img" ,0 ,1024 ,1024 ); +size_t bs = (BLK_MAX_BLOCK_SIZE <TST_MB ) ?1024 :4 *BLK_MAX_BLOCK_SIZE /1024 ; +tst_fill_file ("test.img" ,0 , bs,1024 ); + half_value =256 ; pg_size =getpagesize (); - invalid_value = pg_size *2 ; + invalid_value =BLK_MAX_BLOCK_SIZE *2 ; unalign_value = pg_size -1 ; dev_fd =SAFE_OPEN (dev_path,O_RDWR );
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Avinesh, All,
Quoted 24 lines · Avinesh Kumar
Quoted 1 line · CEST Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to64k")
Quoted 2 lines
now supports block sizes larger than
PAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEis the
Quoted 3 lines
maximum allowed block size, causing failures on newer kernels(>= 6.14):
ioctl_loop06.c:74: TINFO: Using
LOOP_SET_BLOCK_SIZEwith arg >
PAGE_SIZEQuoted 3 lines
ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
...
ioctl_loop06.c:74: TINFO: UsingLOOP_CONFIGUREwithblock_size>
PAGE_SIZEQuoted 3 lines
ioctl_loop06.c:57: TFAIL: Set block size succeed unexpectedly
This patch updates
ioctl_loop06to useBLK_MAX_BLOCK_SIZEinstead of
PAGE_SIZEQuoted 3 lines
for block size validation.
And, dynamically sets bs based on
BLK_MAX_BLOCK_SIZE, using 1024 bytesif it's
Quoted 1 line
below 1MB or scaling it otherwise. Ensures
tst_fill_file()writesefficiently
Quoted 9 lines
Quoted 6 lines
while maintaining compatibility across different kernel versions.
Signed-off-by Li Wang <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Tested-by Avinesh Kumar <[email protected]>
Thanks for testing. I thought this one was merged, but when I checked the log, it was not.
Anyway, I pushed it now.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 9 lines · Li Wang
Hi Luis,
Quoted 5 lines · Luis Chamberlain
Quoted 1 line · Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to64k")
Quoted 2 lines
now supports block sizes larger than
PAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZE
Quoted 8 lines
Quoted 3 lines
is the
Quoted 1 line
maximum allowed block size, causing failures on newer kernels(>= 6.14):
Well, this sounds like we need to go back to patch v1:
https://lists.linux.it/pipermail/ltp/2025-March/042599.htmlNote: LTP has a function
tst_kvercmp()for comparing kernel versions.
Close.
BLK_MAX_BLOCK_SIZE may change in the future so the only real way to test for an invalid block size is having a check for linux/blkdev.h.
I see commit 7c84fa710f75 ("ioprio: use ioprio.h kernel header if it exists") is an example of using a kernel header file. I think similar thing can be done to use linux/blkdev.h and if you don't have HAVE_LINUX_BLKDEV_H then you can define BLK_MAX_BLOCK_SIZE to 64k for for older kernels.
A more appropriate invalid value would be BLK_MAX_BLOCK_SIZE * 2 as non power of 2 values will be outright disallowed.
Luis
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 24 lines · Luis Chamberlain
Quoted 9 lines · Li Wang
Hi Luis,
Quoted 5 lines · Luis Chamberlain
Quoted 1 line · Li Wang
The kernel commit
47dd6753("block/bdev: lift block size restrictions to64k")
Quoted 2 lines
now supports block sizes larger than
PAGE_SIZE, with a new upper limit ofBLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes thatPAGE_SIZEQuoted 8 lines
Quoted 3 lines
is the
Quoted 1 line
maximum allowed block size, causing failures on newer kernels(>= 6.14):
Well, this sounds like we need to go back to patch v1:
https://lists.linux.it/pipermail/ltp/2025-March/042599.htmlNote: LTP has a function
tst_kvercmp()for comparing kernel versions.Close.
BLK_MAX_BLOCK_SIZEmay change in the future so the only real way to test for an invalid block size is having a check forlinux/blkdev.h.
Quoted 8 lines
I see commit
7c84fa710f75("ioprio: useioprio.hkernel header if it exists") is an example of using a kernel header file. I think similar thing can be done to uselinux/blkdev.hand if you don't haveHAVE_LINUX_BLKDEV_Hthen you can defineBLK_MAX_BLOCK_SIZEto 64k for for older kernels.A more appropriate invalid value would be
BLK_MAX_BLOCK_SIZE* 2 as non power of 2 values will be outright disallowed.
While at it, be sure to scale tst_fill_file("test.img", 0, 1024, 1024) (I think that is bs=1024, count=1024, so 1 MiB file size) so that you take into consideration the BLK_MAX_BLOCK_SIZE so that the file size will be at least maybe 10 * BLK_MAX_BLOCK_SIZE or something sensible.
Because as soon as we can support a BLK_MAX_BLOCK_SIZE of 2 MiB this test will also fail again.
Luis
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 39 lines · Luis Chamberlain
Quoted 4 lines · Luis Chamberlain
Quoted 3 lines · Li Wang
Hi Luis,
On Fri, Mar 14, 2025 at 6:59 AM Luis Chamberlain <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines · Li Wang
Quoted 1 line
The kernel commit
47dd6753("block/bdev: lift block sizerestrictions to
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
64k")
Quoted 1 line
now supports block sizes larger than
PAGE_SIZE, with a new upperlimit of
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
BLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes that
PAGE_SIZEQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
is the
Quoted 1 line
maximum allowed block size, causing failures on newer kernels(>=
6.14):
Quoted 12 lines
Quoted 6 lines
Quoted 1 line
Well, this sounds like we need to go back to patch v1:
https://lists.linux.it/pipermail/ltp/2025-March/042599.htmlNote: LTP has a function
tst_kvercmp()for comparing kernel versions.Close.
BLK_MAX_BLOCK_SIZEmay change in the future so the only real way to test for an invalid block size is having a check forlinux/blkdev.h.Quoted 8 lines
I see commit
7c84fa710f75("ioprio: useioprio.hkernel header if it exists") is an example of using a kernel header file. I think similar thing can be done to uselinux/blkdev.hand if you don't haveHAVE_LINUX_BLKDEV_Hthen you can defineBLK_MAX_BLOCK_SIZEto 64k for for older kernels.A more appropriate invalid value would be
BLK_MAX_BLOCK_SIZE* 2 as non power of 2 values will be outright disallowed.
Quoted 8 lines
While at it, be sure to scale
tst_fill_file("test.img", 0, 1024, 1024)(I think that is bs=1024, count=1024, so 1 MiB file size) so that you take into consideration theBLK_MAX_BLOCK_SIZEso that the file size will be at least maybe 10 *BLK_MAX_BLOCK_SIZEor something sensible.Because as soon as we can support a
BLK_MAX_BLOCK_SIZEof 2 MiB this test will also fail again.
Make sense!! I will improve this in the next version, too.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 22 lines · Luis Chamberlain
Quoted 3 lines · Li Wang
Hi Luis,
On Fri, Mar 14, 2025 at 6:59 AM Luis Chamberlain <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines · Li Wang
Quoted 1 line
The kernel commit
47dd6753("block/bdev: lift block sizerestrictions to
Quoted 2 lines
Quoted 2 lines
64k")
Quoted 1 line
now supports block sizes larger than
PAGE_SIZE, with a new upperlimit of
Quoted 1 line
Quoted 1 line
Quoted 1 line
BLK_MAX_BLOCK_SIZE(64K). Butioctl_loop06still assumes that
PAGE_SIZEQuoted 2 lines
Quoted 2 lines
is the
Quoted 1 line
maximum allowed block size, causing failures on newer kernels(>=
6.14):
Quoted 5 lines
Quoted 1 line
Well, this sounds like we need to go back to patch v1:
https://lists.linux.it/pipermail/ltp/2025-March/042599.html
Quoted 7 lines
Quoted 1 line
Note: LTP has a function
tst_kvercmp()for comparing kernel versions.Close.
BLK_MAX_BLOCK_SIZEmay change in the future so the only real way to test for an invalid block size is having a check forlinux/blkdev.h.
Good point.
Quoted 6 lines
I see commit
7c84fa710f75("ioprio: useioprio.hkernel header if it exists") is an example of using a kernel header file. I think similar thing can be done to uselinux/blkdev.hand if you don't haveHAVE_LINUX_BLKDEV_Hthen you can defineBLK_MAX_BLOCK_SIZEto 64k for for older kernels.
To precise, if BLK_MAX_BLOCK_SIZE is undefined (in blkdev.h) in older kernel (e.g. kernel-6.12) then we define it to 64k.
Quoted 4 lines
A more appropriate invalid value would be
BLK_MAX_BLOCK_SIZE* 2 as non power of 2 values will be outright disallowed.
Agreed. Thanks for reviewing.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp