Skip to contentSkip to conversation

ioctl_loop06: Update block size validation to align with kver

PATCH In review Li Wang 1 participant 2 messages Mar 10, 2025 – Mar 11, 2025

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 ioctl_loop06: Update block size validation to align with kver

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.

---
 testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +5 -3
index 573871bc1..321754108 100644
@@ -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 + 1;
 
 	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