* [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP [not found] <CGME20250805061730epcas5p4ae7a8eda6d1d11cc90317a80738eb2ea@epcas5p4.samsung.com> @ 2025-08-05 6:16 ` Anuj Gupta 2025-08-06 2:51 ` Martin K. Petersen 2025-08-08 11:40 ` Shinichiro Kawasaki 0 siblings, 2 replies; 6+ messages in thread From: Anuj Gupta @ 2025-08-05 6:16 UTC (permalink / raw) To: vincent.fu, anuj1072538, axboe, hch, martin.petersen, shinichiro.kawasaki Cc: linux-block, joshi.k, gost.dev, Anuj Gupta 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/ fio support for interface: https://lore.kernel.org/all/20250725175808.2632-2-vincent.fu@samsung.com/ ioctl: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.integrity Signed-off-by: Anuj Gupta <anuj20.g@samsung.com> Signed-off-by: Vincent Fu <vincent.fu@samsung.com> --- 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 create mode 100644 tests/block/041.out diff --git a/src/.gitignore b/src/.gitignore index 399a046..2ece754 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -10,3 +10,4 @@ /zbdioctl /miniublk /nvme-passthrough-meta +/ioctl-lbmd-query diff --git a/src/Makefile b/src/Makefile index f91ac62..ba0d9b7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,6 +14,7 @@ C_TARGETS := \ loop_get_status_null \ mount_clear_sock \ nvme-passthrough-meta \ + ioctl-lbmd-query \ nbdsetsize \ openclose \ sg/dxfer-from-dev \ diff --git a/src/ioctl-lbmd-query.c b/src/ioctl-lbmd-query.c new file mode 100644 index 0000000..0b60320 --- /dev/null +++ b/src/ioctl-lbmd-query.c @@ -0,0 +1,60 @@ +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> +#include <sys/ioctl.h> +#include <linux/fs.h> +#include <errno.h> + +#ifndef FS_IOC_GETLBMD_CAP +#define FS_IOC_GETLBMD_CAP _IOWR(0x15, 2, struct logical_block_metadata_cap) + +#define LBMD_PI_CAP_INTEGRITY (1 << 0) + +struct logical_block_metadata_cap { + __u32 lbmd_flags; + __u16 lbmd_interval; + __u8 lbmd_size; + __u8 lbmd_opaque_size; + __u8 lbmd_opaque_offset; + __u8 lbmd_pi_size; + __u8 lbmd_pi_offset; + __u8 lbmd_guard_tag_type; + __u8 lbmd_app_tag_size; + __u8 lbmd_ref_tag_size; + __u8 lbmd_storage_tag_size; + __u8 pad; +}; +#endif + +int main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr, "Usage: %s <block-device>\n", argv[0]); + return 1; + } + + const char *dev = argv[1]; + int fd = open(dev, O_RDONLY); + if (fd < 0) { + perror("open"); + return 1; + } + + struct logical_block_metadata_cap cap = {}; + if (ioctl(fd, FS_IOC_GETLBMD_CAP, &cap) < 0) { + perror("FS_IOC_GETLBMD_CAP"); + close(fd); + return 1; + } + close(fd); + + if (!(cap.lbmd_flags & LBMD_PI_CAP_INTEGRITY)) { + printf("unsupported\n"); + return 0; + } + + printf("lbmd_flags=%u lbmd_interval=%u lbmd_size=%u\n", + cap.lbmd_flags, cap.lbmd_interval, cap.lbmd_size); + return 0; +} 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 + +DESCRIPTION="io_uring read with PI metadata buffer on block device" + +device_requires() { + _test_dev_has_metadata + _test_dev_disables_extended_lba +} + +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}" + + local lbmd_flags lbmd_size lbmd_interval + 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)) + + 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP 2025-08-05 6:16 ` [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP Anuj Gupta @ 2025-08-06 2:51 ` Martin K. Petersen 2025-08-08 11:40 ` Shinichiro Kawasaki 1 sibling, 0 replies; 6+ messages in thread From: Martin K. Petersen @ 2025-08-06 2:51 UTC (permalink / raw) To: Anuj Gupta Cc: vincent.fu, anuj1072538, axboe, hch, martin.petersen, shinichiro.kawasaki, linux-block, joshi.k, gost.dev Anuj, > 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. Looks OK to me. Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> -- Martin K. Petersen ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP 2025-08-05 6:16 ` [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP Anuj Gupta 2025-08-06 2:51 ` Martin K. Petersen @ 2025-08-08 11:40 ` Shinichiro Kawasaki 2025-08-11 11:03 ` Anuj Gupta/Anuj Gupta 1 sibling, 1 reply; 6+ messages in thread From: Shinichiro Kawasaki @ 2025-08-08 11:40 UTC (permalink / raw) To: Anuj Gupta Cc: vincent.fu@samsung.com, anuj1072538@gmail.com, axboe@kernel.dk, hch@infradead.org, martin.petersen@oracle.com, linux-block@vger.kernel.org, joshi.k@samsung.com, gost.dev@samsung.com 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/ > fio support for interface: https://lore.kernel.org/all/20250725175808.2632-2-vincent.fu@samsung.com/ > ioctl: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.integrity > Signed-off-by: Anuj Gupta <anuj20.g@samsung.com> > Signed-off-by: Vincent Fu <vincent.fu@samsung.com> 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 [...] > 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] > + > + 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 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP 2025-08-08 11:40 ` Shinichiro Kawasaki @ 2025-08-11 11:03 ` Anuj Gupta/Anuj Gupta 2025-08-13 11:24 ` Shinichiro Kawasaki 0 siblings, 1 reply; 6+ messages in thread From: Anuj Gupta/Anuj Gupta @ 2025-08-11 11:03 UTC (permalink / raw) To: Shinichiro Kawasaki Cc: vincent.fu@samsung.com, anuj1072538@gmail.com, axboe@kernel.dk, hch@infradead.org, martin.petersen@oracle.com, linux-block@vger.kernel.org, joshi.k@samsung.com, gost.dev@samsung.com On 8/8/2025 5:10 PM, Shinichiro Kawasaki wrote: > 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/ >> fio support for interface: https://lore.kernel.org/all/20250725175808.2632-2-vincent.fu@samsung.com/ >> ioctl: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.integrity >> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com> >> Signed-off-by: Vincent Fu <vincent.fu@samsung.com> > > 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? Could you please share/paste the errors that you encountered? The issue occurs because setting ms and pi in the QEMU command line is not enough, the namespace still needs to be formatted. Could you please run the test again after running the nvme format command on device with the desired LBA format (PI enabled). Thanks, Anuj ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP 2025-08-11 11:03 ` Anuj Gupta/Anuj Gupta @ 2025-08-13 11:24 ` Shinichiro Kawasaki 2025-09-19 10:12 ` Anuj Gupta/Anuj Gupta 0 siblings, 1 reply; 6+ messages in thread From: Shinichiro Kawasaki @ 2025-08-13 11:24 UTC (permalink / raw) To: Anuj Gupta/Anuj Gupta Cc: vincent.fu@samsung.com, anuj1072538@gmail.com, axboe@kernel.dk, hch@infradead.org, martin.petersen@oracle.com, linux-block@vger.kernel.org, joshi.k@samsung.com, gost.dev@samsung.com On Aug 11, 2025 / 16:33, Anuj Gupta/Anuj Gupta wrote: > On 8/8/2025 5:10 PM, Shinichiro Kawasaki wrote: > > 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/ > >> fio support for interface: https://lore.kernel.org/all/20250725175808.2632-2-vincent.fu@samsung.com/ > >> ioctl: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.integrity > >> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com> > >> Signed-off-by: Vincent Fu <vincent.fu@samsung.com> > > > > 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? > > Could you please share/paste the errors that you encountered? The errors were as follows: block/041 => nvme1n1 (io_uring read with PI metadata buffer on block device) [failed] runtime ... 0.354s --- tests/block/041.out 2025-08-13 19:56:15.487074413 +0900 +++ /home/shin/Blktests/blktests/results/nvme1n1/block/041.out.bad 2025-08-13 20:06:23.199291948 +0900 @@ -1,2 +1,12 @@ Running block/041 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=12288, buflen=4096 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=688128, buflen=4096 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=630784, buflen=4096 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=905216, buflen=4096 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=233472, buflen=4096 +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=540672, buflen=4096 ... (Run 'diff -u tests/block/041.out /home/shin/Blktests/blktests/results/nvme1n1/block/041.out.bad' to see the entire diff) > > The issue occurs because setting ms and pi in the QEMU command line is > not enough, the namespace still needs to be formatted. Could you please > run the test again after running the nvme format command on device with > the desired LBA format (PI enabled). Ah, thanks. I ran "nvme format -i 1 /dev/nvme0n1" for the QEMU NVME device prepared with QEMU NVME option "ms=8,pi=1", then the test case passes. The test case looks working as expected :) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP 2025-08-13 11:24 ` Shinichiro Kawasaki @ 2025-09-19 10:12 ` Anuj Gupta/Anuj Gupta 0 siblings, 0 replies; 6+ messages in thread From: Anuj Gupta/Anuj Gupta @ 2025-09-19 10:12 UTC (permalink / raw) To: Shinichiro Kawasaki Cc: vincent.fu@samsung.com, anuj1072538@gmail.com, axboe@kernel.dk, hch@infradead.org, martin.petersen@oracle.com, linux-block@vger.kernel.org, joshi.k@samsung.com, gost.dev@samsung.com > The errors were as follows: > > block/041 => nvme1n1 (io_uring read with PI metadata buffer on block device) [failed] > runtime ... 0.354s > --- tests/block/041.out 2025-08-13 19:56:15.487074413 +0900 > +++ /home/shin/Blktests/blktests/results/nvme1n1/block/041.out.bad 2025-08-13 20:06:23.199291948 +0900 > @@ -1,2 +1,12 @@ > Running block/041 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=12288, buflen=4096 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=688128, buflen=4096 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=630784, buflen=4096 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=905216, buflen=4096 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=233472, buflen=4096 > +fio: io_u error on file /dev/nvme1n1: Invalid or incomplete multibyte or wide character: read offset=540672, buflen=4096 > ... > (Run 'diff -u tests/block/041.out /home/shin/Blktests/blktests/results/nvme1n1/block/041.out.bad' to see the entire diff) > >> >> The issue occurs because setting ms and pi in the QEMU command line is >> not enough, the namespace still needs to be formatted. Could you please >> run the test again after running the nvme format command on device with >> the desired LBA format (PI enabled). > > Ah, thanks. I ran "nvme format -i 1 /dev/nvme0n1" for the QEMU NVME device > prepared with QEMU NVME option "ms=8,pi=1", then the test case passes. The > test case looks working as expected :) Hi Shinichiro, Thanks a lot for your detailed review comments. Sorry for the delay in re-spinning - I had a few conflicting deadlines. I have addressed your feedback and sent out a v2 here: https://lore.kernel.org/linux-block/20250919101028.14245-1-anuj20.g@samsung.com/ Thanks, Anuj Gupta ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-19 10:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20250805061730epcas5p4ae7a8eda6d1d11cc90317a80738eb2ea@epcas5p4.samsung.com>
2025-08-05 6:16 ` [blktests v1] block: add test for io_uring Protection Information (PI) interface using FS_IOC_GETLBMD_CAP Anuj Gupta
2025-08-06 2:51 ` Martin K. Petersen
2025-08-08 11:40 ` Shinichiro Kawasaki
2025-08-11 11:03 ` Anuj Gupta/Anuj Gupta
2025-08-13 11:24 ` Shinichiro Kawasaki
2025-09-19 10:12 ` Anuj Gupta/Anuj Gupta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox