[LTP] [PATCH 2/4] syscalls/io_uring: Add test for partial vector operations
Sachin Sant
sachinp@linux.ibm.com
Wed May 6 20:37:48 CEST 2026
Add new test case io_uring05.c to validate vectored I/O operations
using partial vector sets with different file offsets.
The test performs:
- IORING_OP_WRITEV: Write first half using first 2 vectors at offset 0
- IORING_OP_WRITEV: Write second half using next 2 vectors at offset 2048
- IORING_OP_READV: Read entire file using all 4 vectors
- Data integrity verification across all vectors
This validates that io_uring correctly handles partial vector operations
and maintains data integrity when using different vector subsets with
specific file offsets.
Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/io_uring/.gitignore | 1 +
.../kernel/syscalls/io_uring/io_uring05.c | 94 +++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 testcases/kernel/syscalls/io_uring/io_uring05.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 6b047b5fd..bab0e8f3b 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1905,6 +1905,7 @@ io_uring01 io_uring01
io_uring02 io_uring02
io_uring03 io_uring03
io_uring04 io_uring04
+io_uring05 io_uring05
# Tests below may cause kernel memory leak
perf_event_open03 perf_event_open03
diff --git a/testcases/kernel/syscalls/io_uring/.gitignore b/testcases/kernel/syscalls/io_uring/.gitignore
index 36cd24662..bce7048cd 100644
--- a/testcases/kernel/syscalls/io_uring/.gitignore
+++ b/testcases/kernel/syscalls/io_uring/.gitignore
@@ -2,3 +2,4 @@
/io_uring02
/io_uring03
/io_uring04
+/io_uring05
diff --git a/testcases/kernel/syscalls/io_uring/io_uring05.c b/testcases/kernel/syscalls/io_uring/io_uring05.c
new file mode 100644
index 000000000..ded990c41
--- /dev/null
+++ b/testcases/kernel/syscalls/io_uring/io_uring05.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 IBM
+ * Author: Sachin Sant <sachinp@linux.ibm.com>
+ */
+/*\
+ *
+ * Test partial vector operations with IORING_OP_READV and IORING_OP_WRITEV.
+ *
+ * This test validates vectored I/O operations using partial vector sets
+ * and different file offsets. It performs:
+ * 1. IORING_OP_WRITEV - Writing first half using first 2 vectors at offset 0
+ * 2. IORING_OP_WRITEV - Writing second half using next 2 vectors at offset
+ * 2048
+ * 3. IORING_OP_READV - Reading entire file using all 4 vectors
+ * 4. Data integrity verification across all vectors
+ */
+
+#include "io_uring_common.h"
+
+#define TEST_FILE "io_uring_test_file"
+#define QUEUE_DEPTH 2
+#define NUM_VECS 4
+#define VEC_SIZE 1024
+
+static struct iovec *write_iovs, *read_iovs;
+static struct io_uring_submit s;
+static sigset_t sig;
+
+static void run(void)
+{
+ int fd = -1;
+ int half_size = 2 * VEC_SIZE;
+
+ io_uring_init_iovec_pattern(write_iovs, NUM_VECS, 'A', 1);
+ io_uring_clear_iovec(read_iovs, NUM_VECS);
+
+ fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT | O_TRUNC, 0644);
+
+ tst_res(TINFO, "Writing first half using first 2 vectors at offset 0");
+ /* Write first half using first 2 vectors at offset 0 */
+ io_uring_do_vec_io_op(&s, fd, IORING_OP_WRITEV, write_iovs, 2, 0,
+ half_size, &sig);
+
+ tst_res(TINFO,
+ "Writing second half using next 2 vectors at offset %d",
+ half_size);
+ /* Write second half using next 2 vectors at offset half_size */
+ io_uring_do_vec_io_op(&s, fd, IORING_OP_WRITEV, &write_iovs[2], 2,
+ half_size, half_size, &sig);
+
+ SAFE_FSYNC(fd);
+
+ tst_res(TINFO, "Reading entire file using all 4 vectors");
+ /* Read back entire file using all 4 vectors */
+ io_uring_do_vec_io_op(&s, fd, IORING_OP_READV, read_iovs, NUM_VECS, 0,
+ NUM_VECS * VEC_SIZE, &sig);
+
+ io_uring_verify_iovec(write_iovs, read_iovs, NUM_VECS);
+
+ SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+ io_uring_setup_supported_by_kernel();
+ sigemptyset(&sig);
+ memset(&s, 0, sizeof(s));
+ io_uring_setup_queue(&s, QUEUE_DEPTH, 0);
+}
+
+static void cleanup(void)
+{
+ io_uring_cleanup_queue(&s, QUEUE_DEPTH);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .needs_tmpdir = 1,
+ .bufs = (struct tst_buffers []) {
+ {&write_iovs, .iov_sizes = (int[]){VEC_SIZE, VEC_SIZE,
+ VEC_SIZE, VEC_SIZE, -1}},
+ {&read_iovs, .iov_sizes = (int[]){VEC_SIZE, VEC_SIZE,
+ VEC_SIZE, VEC_SIZE, -1}},
+ {}
+ },
+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/kernel/io_uring_disabled", "0",
+ TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+ {}
+ }
+};
--
2.39.1
More information about the ltp
mailing list