block tests: nvme metadata passthrough
Subsystems (2)
PATCH 1/1 block tests: nvme metadata passthrough
From: Keith Busch <[email protected]>
Get more coverage on nvme metadata passthrough. Specifically in this test, read-only metadata is targeted as this had been a gap in previous test coveraged.
--- src/Makefile | 1 + src/nvme-passthrough-meta.c | 219 ++++++++++++++++++++++++++++++++++++ tests/nvme/064 | 22 ++++ tests/nvme/064.out | 2 + 4 files changed, 244 insertions(+) create mode 100644 src/nvme-passthrough-meta.c create mode 100755 tests/nvme/064 create mode 100644 tests/nvme/064.out
src/Makefile +1 -0
@@ -13,6 +13,7 @@ C_TARGETS := \ loop_change_fd \ loop_get_status_null \ mount_clear_sock \ + nvme-passthrough-meta \ nbdsetsize \ openclose \ sg/dxfer-from-dev \
src/nvme-passthrough-meta.c new file +219 -0
219 lines not on this page · raw message
tests/nvme/064 new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2025 Keith Busch <[email protected]> +# +# Test out metadata through the passthrough interfaces + +. tests/nvme/rc + +requires() { + _nvme_requires +} + +DESCRIPTION="exercise the nvme metadata usage with passthrough commands" +QUICK=1 + +test() { + echo "Running ${TEST_NAME}" + + src/nvme-passthrough-meta ${TEST_DEV} + + echo "Test complete" +}
tests/nvme/064.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/064 +Test complete
Signature · 1 line
2.47.1
src/nvme-passthrough-meta.c line 153
Quoted 5 lines
src/nvme-passthrough-meta.c new file +5
-0+/* this should directly use the user space buffer */ + meta = mptr; + cmd = (struct nvme_passthru_cmd ) { + .opcode =1 , + .nsid =1 ,
Minor nit: should use .nsid = nsid instead of hardcoded 1
Quoted 1 line
+ /* This should not be mappable for write commands */
Maybe reword this to:
/* This buffer is read-only, so using it for write passthrough should fail */ -- makes the intent clearer.
--
Anuj Gupta
Quoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
Get more coverage on nvme metadata passthrough. Specifically in this test, read-only metadata is targeted as this had been a gap in previous test coveraged.
Thanks for the patch. I ran the test case on the kernel v6.15, and it passed. Is this pass result expected? I guess this test case intends to extend test coverage, and does not intend to recreate the failure reported in the Link. So, I'm guessing the test case should pass with v6.15 kernel.
Also, please find a few comments in line.
...
Quoted 12 lines
tests/nvme/064 new file +6
-0@@ -0,0 +1,22 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2025 Keith Busch <[email protected]> +# +# Test out metadata through the passthrough interfaces +
tests/nvme/064 line 16
Quoted 10 lines
tests/nvme/064 new file +10
-0+. tests/nvme/rc + +requires() { + _nvme_requires +} + +DESCRIPTION="exercise the nvme metadata usage with passthrough commands" +QUICK=1 + +test() {
This function name should be test_device() instead of test() to indicate that it uses TEST_DEV. For test(), blktests provides empty TEST_DEV. So, actually the src/nvme-passthrough-meta is not doing the test as expected.
tests/nvme/064 line 19
Quoted 3 lines
tests/nvme/064 new file +3
-0+ echo "Running ${TEST_NAME}" + + src/nvme-passthrough-meta ${TEST_DEV}
I suggest to check status code of the command above, like:
if ! src/nvme-passthrough-meta ${TEST_DEV}; then
echo "src/nvme-passthrough-meta failed"
fiThis will catch the failure with empty TEST_DEV for test(). By renaming test() to test_device(), src/nvme-passthrough-meta returns zero status.
Also, ${TEST_DEV} requires double quotations like "${TEST_DEV}", to suprress the shellcheck WARN below:
$ make check
shellcheck -x -e SC2119 -f gcc check common/* \
tests/*/rc tests/*/[0-9]*[0-9] src/*.sh
tests/nvme/064:19:28: note: Double quote to prevent globbing and word splitting. [SC2086]
make: *** [Makefile:21: check] Error 1Quoted 4 lines · Shinichiro Kawasaki
Quoted 2 lines · Keith Busch
From: Keith Busch <[email protected]>
Quoted 8 lines
Quoted 3 lines
Get more coverage on nvme metadata passthrough. Specifically in this test, read-only metadata is targeted as this had been a gap in previous test coveraged.
Thanks for the patch. I ran the test case on the kernel v6.15, and it passed. Is this pass result expected? I guess this test case intends to extend test coverage, and does not intend to recreate the failure reported in the Link. So, I'm guessing the test case should pass with v6.15 kernel.
As Keith mentioned in that thread [1], this test can catch the issue only in the more unusual or corner-case configurations.
Additionally, if your NVMe device is not formatted with protection information, the test will exit early and report success, as the integrity path won't be exercised in that case.
[1] https://lore.kernel.org/linux-block/aD-J9mzq_bJe26rD@kbusch-mbp/
Quoted 15 lines · Anuj gupta
Quoted 4 lines · Shinichiro Kawasaki
Quoted 2 lines · Keith Busch
From: Keith Busch <[email protected]>
Quoted 8 lines
Quoted 3 lines
Get more coverage on nvme metadata passthrough. Specifically in this test, read-only metadata is targeted as this had been a gap in previous test coveraged.
Thanks for the patch. I ran the test case on the kernel v6.15, and it passed. Is this pass result expected? I guess this test case intends to extend test coverage, and does not intend to recreate the failure reported in the Link. So, I'm guessing the test case should pass with v6.15 kernel.
Quoted 8 lines
As Keith mentioned in that thread [1], this test can catch the issue only in the more unusual or corner-case configurations.
Additionally, if your NVMe device is not formatted with protection information, the test will exit early and report success, as the integrity path won't be exercised in that case.
[1] https://lore.kernel.org/linux-block/aD-J9mzq_bJe26rD@kbusch-mbp/
I see, thanks for the explanation. Then I wish the expected device conditions to be described in the test case comment. Even if blktests can not prepare devices with the condition automatically, I think it's worth documenting.
In daily blktests run, I use a normal QEMU nvme device, but running the test case with this device does not extend the test coverage much, probably. Can we prepare the best device for the new test case using QEMU? I hope that some QEMU boot options and/or nvme format commands can prepare it.
Keith Busch
maintainerQuoted 11 lines · Shinichiro Kawasaki
Quoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
Get more coverage on nvme metadata passthrough. Specifically in this test, read-only metadata is targeted as this had been a gap in previous test coveraged.
Thanks for the patch. I ran the test case on the kernel v6.15, and it passed. Is this pass result expected? I guess this test case intends to extend test coverage, and does not intend to recreate the failure reported in the Link. So, I'm guessing the test case should pass with v6.15 kernel.
Oh, I thought it would fail in 6.15, or at least part of this test would have. I changed a lot at the last second before posting, so maybe I messed something up. I'll do another version after making sense of what's going on.
Keith Busch
maintainerQuoted 7 lines · Anuj gupta
Minor nit: should use
.nsid = nsidinstead of hardcoded1Quoted 1 line
+ /* This should not be mappable for write commands */
Maybe reword this to:
/* This buffer is read-only, so using it for write passthrough should fail */ -- makes the intent clearer.
Err, I actually got this backwards. PROT_READ means we can write to the disk from that memory, but we can't read from the disk into it.