nvme/067: test io_uring pass through for NVMe admin queue
PATCH v2 1/1 nvme/067: test io_uring pass through for NVMe admin queue
From: Swarna Prabhu <[email protected]>
Simple test to exercise the nvme admin commands usage with io uring passthrough interfaces. The motivation for the test is to extend the kernel code coverage for NVMe admin commands via io_uring passthrough.
---
Changes since v1:
- Fixed typo in the git commit description and included motivation.
- Revert the file mode of src/Makefile to 644 from 755.
- Change src program name from "nvme-passthrough-admin.c" to "nvme-passthru-admin-uring.c".
- Change the file mode of src/nvme-passthru-admin-uring.c from 755 to 644.
- Added missing SPDX-License-Identifier and copyright in src/nvme-passthru-admin-uring.c
- Add space after commment markers in src/nvme-passthru-admin-uring.c.
- Added tab for indentation to 'struct nvme_id_ctrl' declaration in src/nvme-passthru-admin-uring.c.
- Added missing "\n" to the end of fprintf statement in src/nvme-passthru-admin-uring.c.
- Replaced direct return statements with goto to do resource clean up in src/nvme-passthru-admin-uring.c
- Added missing copyright and SPDX-License-Identifier in tests/nvme/067 script.
- Added '_io_uring_enable' and '_io_uring_restore' functions to script tests/nvme/067 to enable and restore io_uring setting for the test run.
Link to v1: https://lore.kernel.org/all/[email protected]/
src/Makefile | 3 +- src/nvme-passthru-admin-uring.c | 100 ++++++++++++++++++++++++++++++++ tests/nvme/067 | 34 +++++++++++ tests/nvme/067.out | 2 + 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/nvme-passthru-admin-uring.c create mode 100755 tests/nvme/067 create mode 100644 tests/nvme/067.out
src/Makefile +2 -1
@@ -23,7 +23,8 @@ C_TARGETS := \ zbdioctl C_URING_TARGETS := miniublk \ - metadata + metadata \ + nvme-passthru-admin-uring HAVE_LIBURING := $(call HAVE_C_MACRO,liburing.h,IORING_OP_URING_CMD) HAVE_UBLK_HEADER := $(call HAVE_C_HEADER,linux/ublk_cmd.h,1)
src/nvme-passthru-admin-uring.c new file +100 -0
101 lines not on this page · raw message
tests/nvme/067 new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2026 Swarna Prabhu, Samsung Electronics +# Test out admin commands through the io uring passthrough interfaces. + +. tests/nvme/rc + +requires() { + _nvme_requires + _have_kernel_option IO_URING +} + +DESCRIPTION="exercise the nvme admin commands usage with io uring passthrough interfaces" +QUICK=1 + +test_device() { + echo "Running ${TEST_NAME}" + + # extract the ctrl dev from the test dev + devname=${TEST_DEV#/dev/} + ctrl_dev="/dev/${devname%n*}" + + # enable io_uring when it is disabled + _io_uring_enable + + if ! sudo src/nvme-passthrough-admin "${ctrl_dev}"; then + echo "src/nvme-passthrough-admin failed" + fi + + # reset io_uring setting before test exits + _io_uring_restore + + echo "Test Complete" +}
tests/nvme/067.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/067 +Test Complete
Signature · 1 line
2.39.5
Quoted 8 lines · On Feb 02, 2026 / 11:26, [email protected] wrote:
From: Swarna Prabhu <[email protected]>
Simple test to exercise the nvme admin commands usage with io uring passthrough interfaces. The motivation for the test is to extend the kernel code coverage for NVMe admin commands via
io_uringpassthrough.Signed-off-by Swarna Prabhu <[email protected]>
Thanks for this v2 patch. I applied it. FYI, I took a liberty to fold-in some edits below:
...
Quoted 4 lines
src/Makefile +0
-0
[...]
src/Makefile
Quoted 7 lines
src/Makefile +7
-0+ if (cqe) + io_uring_cqe_seen(&nvring, cqe); + io_uring_queue_exit(&nvring); +free_nctrl: + free(nctrl); +free_fd: + close(fd);
I replaced space indent above with a tab.
Quoted 9 lines
src/Makefile +3
-0+ + return ret; +}tests/nvme/067 new file +0
-0
[...]
tests/nvme/067 line 17
Quoted 2 lines
tests/nvme/067 new file +2
-0+test_device() { + echo "Running ${TEST_NAME}"
I added local variable declarations for devname and ctrl_dev here.
tests/nvme/067 line 27
Quoted 10 lines
tests/nvme/067 new file +10
-0+ + # extract the ctrl dev from the test dev + devname=${TEST_DEV#/dev/} + ctrl_dev="/dev/${devname%n*}" + + # enable io_uring when it is disabled + _io_uring_enable + + if ! sudo src/nvme-passthrough-admin "${ctrl_dev}"; then + echo "src/nvme-passthrough-admin failed"
I replaced the program names "src/nvme-passthrough-admin" above with "src/nvme-passthru-admin-uring".
Thanks again for the contribution!