Thread (5 messages) 5 messages, 2 authors, 2025-09-19

Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP

From: Shinichiro Kawasaki <hidden>
Date: 2025-08-08 11:40:15

Possibly related (same subject, not in this thread)

On Aug 05, 2025 / 11:46, Anuj Gupta wrote:
This test verifies end-to-end support for integrity metadata via the
io-uring interface. It uses the FS_IOC_GETLBMD_CAP ioctl to query the
logical block metadata capabilities of the device. These values are then
passed to fio using the md_per_io_size option.

io_uring PI interface: https://lore.kernel.org/all/20241128112240.8867-1-anuj20.g@samsung.com/ (local)
fio support for interface: https://lore.kernel.org/all/20250725175808.2632-2-vincent.fu@samsung.com/ (local)
ioctl: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.integrity
Signed-off-by: Anuj Gupta <redacted>
Signed-off-by: Vincent Fu <redacted>
Anuj, thank you for the patch.

I wonder which test group this test case should go into, block or nvme. IIUC,
this test case runs only for nvme devices. Said that, block group looks good for
me since the test target ioctl interface belongs to the block layer.

I tried to run the test case using QEMU NVME emulation devices with some
ms=X,pi=Y options, but the test runs failed. The kernel reported a number of
"protection error"s. Can we run the test case with QEMU NVME emulation device?
If so, could you share the recommended set up of the device?

Also, please find my comments on this patch inline.
---
 src/.gitignore         |  1 +
 src/Makefile           |  1 +
 src/ioctl-lbmd-query.c | 60 +++++++++++++++++++++++++++++++++++++
 tests/block/041        | 68 ++++++++++++++++++++++++++++++++++++++++++
 tests/block/041.out    |  2 ++
 5 files changed, 132 insertions(+)
 create mode 100644 src/ioctl-lbmd-query.c
 create mode 100644 tests/block/041
Nit: I suggest file mode 755 in same manner as other test script files.
 create mode 100644 tests/block/041.out
[...]
quoted hunk ↗ jump to hunk
diff --git a/tests/block/041 b/tests/block/041
new file mode 100644
index 0000000..ddb8117
--- /dev/null
+++ b/tests/block/041
@@ -0,0 +1,68 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Anuj Gupta, Samsung Electronics
+
+# Test: io_uring read with metadata buffer using FIO's io_uring PI interface
+
+. tests/nvme/rc
Cross references across test groups are not recommended. I think you introduced
this dependency for _test_dev_has_metadata and _test_dev_disables_extended_lba.
So I suggest to add antoher preperation patch to move them from tests/nvme/rc to
common/nvme (_test_dev_has_no_metadata can be moved together).
+
+DESCRIPTION="io_uring read with PI metadata buffer on block device"
+
+device_requires() {
+	_test_dev_has_metadata
+	_test_dev_disables_extended_lba
I think this test case works only for nvme devices since nvme-cli is used in
_test_dev_disables_extended_lba. Also, I think fio io_uring engine works only
for nvme. Then I suggest to call _require_test_dev_is_nvme here to clarify the
test device requirement. If this suggestion is valid, _require_test_dev_is_nvme
also needs to move from tests/nvme/rc to common/nvme in the preparation patch.
+}
+
+requires() {
+	_have_fio
+	_have_kernel_option IO_URING
+	_have_kernel_option BLK_DEV_INTEGRITY
+	_have_fio_ver 3 40
+}
+
+test_device() {
+	echo "Running ${TEST_NAME}"
+
I suggest to add the shellcheck control comment below:

  # shellcheck disable=SC2034
+	local lbmd_flags lbmd_size lbmd_interval
because when I run "make check", I observed the shellcheck warning below:

  tests/block/041:26:8: warning: lbmd_flags appears unused. Verify use (or export if used externally). [SC2034]
+	local cap_out bs md_per_io_size
+
+	# Query integrity capabilities via ioctl helper
+	cap_out=$(src/ioctl-lbmd-query "$TEST_DEV")
+	ret=$?
+	if [[ $ret != 0 ]]; then
+		SKIP_REASONS+=("FS_IOC_GETLBMD_CAP ioctl not supported")
+		return
+	fi
+	if [[ $cap_out == "unsupported" ]]; then
+		SKIP_REASONS+=("Integrity not supported on $TEST_DEV")
+		return
+	fi
+
+	# Parse fields
+	eval "$cap_out"  # sets lbmd_flags, lbmd_size, lbmd_interval
+
+	# Calculate md_per_io_size = (bs / interval) * size
+	bs=$(_min_io "$TEST_DEV")
+	md_per_io_size=$((bs / lbmd_interval * lbmd_size))
Also, shellcheck warns about the live above:

  tests/block/041:46:23: note: Increase precision by replacing a/b*c with a*c/b. [SC2017]
quoted hunk ↗ jump to hunk
+
+	local fio_args=(
+		--name=pi_read_test
+		--filename="$TEST_DEV"
+		--size=1M
+		--bs="$bs"
+		--rw=randread
+		--ioengine=io_uring
+		--iodepth=8
+		--numjobs=1
+		--direct=1
+		--time_based
+		--runtime=3
+		--md_per_io_size="$md_per_io_size"
+		--pi_act=0            # Host supplies metadata
+		--pi_chk=APPTAG       # Only check app tag
+		--apptag=0x1234
+	)
+
+	_run_fio "${fio_args[@]}"
+	echo "Test complete"
+}
diff --git a/tests/block/041.out b/tests/block/041.out
new file mode 100644
index 0000000..6706a76
--- /dev/null
+++ b/tests/block/041.out
@@ -0,0 +1,2 @@
+Running block/041
+Test complete
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help