blktests: add userspace IO test
PATCH 1/1 blktests: add userspace IO test
Add one test to cover changes on block passthrough IO interface, such as blk_rq_map_user(), blk_rq_map_user_iov(), blk_rq_unmap_user() and blk_rq_map_kern().
--- tests/block/029 | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 5 +++ 2 files changed, 116 insertions(+) create mode 100755 tests/block/029 create mode 100644 tests/block/029.out
tests/block/029 new file +111 -0
@@ -0,0 +1,111 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Ming Lei <[email protected]> +# +# Test userspace IO on NVMe loop device + +. tests/nvme/rc + +DESCRIPTION="test userspace IO via nvme-cli read/write interface" +QUICK=1 + +requires() { + _have_program nvme && _have_modules loop nvme-loop nvmet && \ + _have_configfs +} + +__test_user_io() +{ + DISK=$1 + START=$2 + CNT=$3 + + BS=`blockdev --getss $DISK` + SIZE=$(($CNT * $BS)) + + IMG=`mktemp /tmp/blk_img_XXXXXX` + IMG1=`mktemp /tmp/blk_img_XXXXXX` + + dd if=/dev/urandom of=$IMG bs=$BS count=$CNT status=none + + let CNT-- + + nvme write --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG $DISK + [ $? -ne 0 ] && return -1 + nvme read --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG1 $DISK + [ $? -ne 0 ] && return -1 + + diff -q -u $IMG $IMG1 + RES=$? + + rm -f $IMG $IMG1 + return $RES +} + +test_user_io() +{ + DEV=$1 + + __test_user_io $DEV 1 512 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 511 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 513 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1024 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1023 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1025 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" +} + +test() { + echo "Running ${TEST_NAME}" + + modprobe nvmet + modprobe nvme-loop + + local port + local nvmedev + local loop_dev + local file_path="$TMPDIR/img" + local subsys_name="blktests-subsystem-1" + + truncate -s 1G "${file_path}" + + loop_dev="$(losetup -f --show "${file_path}")" + + _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ + "91fdba0d-f87b-4c25-b80f-db7be1418b9e" + port="$(_create_nvmet_port "loop")" + _add_nvmet_subsys_to_port "${port}" "${subsys_name}" + + nvme connect -t loop -n "${subsys_name}" + + nvmedev="$(_find_nvme_loop_dev)" + cat "/sys/block/${nvmedev}n1/uuid" + cat "/sys/block/${nvmedev}n1/wwid" + + test_user_io "/dev/${nvmedev}n1" + + nvme disconnect -n "${subsys_name}" + + _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" + _remove_nvmet_subsystem "${subsys_name}" + _remove_nvmet_port "${port}" + + losetup -d "${loop_dev}" + + rm "${file_path}" + + modprobe -r nvme-loop + modprobe -r nvmet + + echo "Test complete" +}
tests/block/029.out new file +5 -0
@@ -0,0 +1,5 @@ +Running block/029 +91fdba0d-f87b-4c25-b80f-db7be1418b9e +uuid.91fdba0d-f87b-4c25-b80f-db7be1418b9e +NQN:blktests-subsystem-1 disconnected 1 controller(s) +Test complete
Signature · 1 line
2.9.5
Quoted 18 lines · Ming Lei
Add one test to cover changes on block passthrough IO interface, such as
blk_rq_map_user(),blk_rq_map_user_iov(),blk_rq_unmap_user()andblk_rq_map_kern().Signed-off-by Ming Lei <[email protected]>--- tests/block/029 | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 5 +++ 2 files changed, 116 insertions(+) create mode 100755 tests/block/029 create mode 100644 tests/block/029.outtests/block/029 new file +0
-0
tests/block/029 line 5
Quoted 5 lines
tests/block/029 new file +5
-0@@ -0,0 +1,111 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Ming Lei <[email protected]> +# +# Test userspace IO on NVMe loop device
Is this a regression test for one of your recent patches?
Quoted 7 lines
tests/block/029 new file +7
-0+. tests/nvme/rc + +DESCRIPTION="test userspace IO via nvme-cli read/write interface" +QUICK=1 + +requires() { + _have_program nvme && _have_modules loop nvme-loop nvmet && \
tests/block/029 line 23
Quoted 10 lines
tests/block/029 new file +10
-0+ _have_configfs +} + +__test_user_io() +{ + DISK=$1 + START=$2 + CNT=$3 + + BS=`blockdev --getss $DISK`
$() instead of `` here and everywhere else, please. Also, $DISK needs to quoted, as do several other variables. Please run make check.
tests/block/029 line 27
Quoted 4 lines
tests/block/029 new file +4
-0+ SIZE=$(($CNT * $BS)) + + IMG=`mktemp /tmp/blk_img_XXXXXX` + IMG1=`mktemp /tmp/blk_img_XXXXXX`
Please make all of these variables local and lowercase.
tests/block/029 line 31
Quoted 3 lines
tests/block/029 new file +3
-0+ dd if=/dev/urandom of=$IMG bs=$BS count=$CNT status=none + + let CNT--
$((CNT--))
Quoted 55 lines
tests/block/029 new file +55
-0+ nvme write --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG $DISK + [ $? -ne 0 ] && return -1 + nvme read --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG1 $DISK + [ $? -ne 0 ] && return -1 + + diff -q -u $IMG $IMG1 + RES=$? + + rm -f $IMG $IMG1 + return $RES +} + +test_user_io() +{ + DEV=$1 + + __test_user_io $DEV 1 512 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 511 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 513 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1024 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1023 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1025 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" +} + +test() { + echo "Running ${TEST_NAME}" + + modprobe nvmet + modprobe nvme-loop + + local port + local nvmedev + local loop_dev + local file_path="$TMPDIR/img" + local subsys_name="blktests-subsystem-1" + + truncate -s 1G "${file_path}" + + loop_dev="$(losetup -f --show "${file_path}")" + + _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ + "91fdba0d-f87b-4c25-b80f-db7be1418b9e" + port="$(_create_nvmet_port "loop")" + _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
tests/block/029 line 97
Quoted 10 lines
tests/block/029 new file +10
-0+ + nvme connect -t loop -n "${subsys_name}" + + nvmedev="$(_find_nvme_loop_dev)" + cat "/sys/block/${nvmedev}n1/uuid" + cat "/sys/block/${nvmedev}n1/wwid" + + test_user_io "/dev/${nvmedev}n1" + + nvme disconnect -n "${subsys_name}"
We just changed the other nvme tests to redirect the output of disconnect like so:
nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1Let's do that for this one, too.
Thanks for the test!
Quoted 13 lines · Omar Sandoval
Quoted 12 lines · Ming Lei
Add one test to cover changes on block passthrough IO interface, such as
blk_rq_map_user(),blk_rq_map_user_iov(),blk_rq_unmap_user()andblk_rq_map_kern().Signed-off-by Ming Lei <[email protected]>--- tests/block/029 | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/block/029.out | 5 +++ 2 files changed, 116 insertions(+) create mode 100755 tests/block/029 create mode 100644 tests/block/029.out
Quoted 13 lines
tests/block/029 line 5
Quoted 11 lines
tests/block/029 new file +5
-0@@ -0,0 +1,111 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Ming Lei <[email protected]> +# +# Test userspace IO on NVMe loop deviceIs this a regression test for one of your recent patches?
Yeah, it is for the following patch:
https://marc.info/?l=linux-block&m=155161907811128&w=2
Also it will serve regression test for the following(not posted yet) patch of 'enabling multi-bvec for passthrough IO'.
Quoted 104 lines
Quoted 8 lines
tests/block/029 new file +7
-0+. tests/nvme/rc + +DESCRIPTION="test userspace IO via nvme-cli read/write interface" +QUICK=1 + +requires() { + _have_program nvme && _have_modules loop nvme-loop nvmet && \tests/block/029 line 23
Quoted 10 lines
tests/block/029 new file +10
-0+ _have_configfs +} + +__test_user_io() +{ + DISK=$1 + START=$2 + CNT=$3 + + BS=`blockdev --getss $DISK`$() instead of `` here and everywhere else, please. Also, $DISK needs to quoted, as do several other variables. Please run
make check.tests/block/029 line 27
Quoted 4 lines
tests/block/029 new file +4
-0+ SIZE=$(($CNT * $BS)) + + IMG=`mktemp /tmp/blk_img_XXXXXX` + IMG1=`mktemp /tmp/blk_img_XXXXXX`Please make all of these variables local and lowercase.
tests/block/029 line 31
Quoted 3 lines
tests/block/029 new file +3
-0+ dd if=/dev/urandom of=$IMG bs=$BS count=$CNT status=none + + let CNT--$((CNT--))
Quoted 55 lines
tests/block/029 new file +55
-0+ nvme write --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG $DISK + [ $? -ne 0 ] && return -1 + nvme read --start-block=$START --block-count=$CNT --data-size=$SIZE --data=$IMG1 $DISK + [ $? -ne 0 ] && return -1 + + diff -q -u $IMG $IMG1 + RES=$? + + rm -f $IMG $IMG1 + return $RES +} + +test_user_io() +{ + DEV=$1 + + __test_user_io $DEV 1 512 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 511 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 1 513 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1024 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1023 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" + + __test_user_io $DEV 511 1025 > /dev/null 2>&1 + [ -$? -ne 0 ] && echo "FAIL" +} + +test() { + echo "Running ${TEST_NAME}" + + modprobe nvmet + modprobe nvme-loop + + local port + local nvmedev + local loop_dev + local file_path="$TMPDIR/img" + local subsys_name="blktests-subsystem-1" + + truncate -s 1G "${file_path}" + + loop_dev="$(losetup -f --show "${file_path}")" + + _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ + "91fdba0d-f87b-4c25-b80f-db7be1418b9e" + port="$(_create_nvmet_port "loop")" + _add_nvmet_subsys_to_port "${port}" "${subsys_name}"tests/block/029 line 97
Quoted 10 lines
tests/block/029 new file +10
-0+ + nvme connect -t loop -n "${subsys_name}" + + nvmedev="$(_find_nvme_loop_dev)" + cat "/sys/block/${nvmedev}n1/uuid" + cat "/sys/block/${nvmedev}n1/wwid" + + test_user_io "/dev/${nvmedev}n1" + + nvme disconnect -n "${subsys_name}"We just changed the other nvme tests to redirect the output of disconnect like so:
Quoted 5 lines
nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1Let's do that for this one, too.
Thanks for the test!
All have been addressed in V2.
Thanks,
Ming