]> www.infradead.org Git - users/sagi/blktests.git/log
users/sagi/blktests.git
2 years agonvme/{033,034,035,036,37}: drop port handle between passthru target setup and cleanup
Daniel Wagner [Wed, 30 Aug 2023 09:20:18 +0000 (11:20 +0200)]
nvme/{033,034,035,036,37}: drop port handle between passthru target setup and cleanup

The passthru nvmet setup and cleanup helpers are using the port as
handle to track resources.

Instead returning the port from the setup call, we figure out in the
cleanup code which resources have been allocated. This avoids passing
around awkward handles.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{033,034,035,036}: use default subsysnqn variable directly
Daniel Wagner [Wed, 30 Aug 2023 09:20:17 +0000 (11:20 +0200)]
nvme/{033,034,035,036}: use default subsysnqn variable directly

There is no need to introduce an extra local variable when it
uses the default subsysnqn anyway.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoRevert "Do not suppress any shellcheck warnings"
Shin'ichiro Kawasaki [Wed, 30 Aug 2023 10:41:34 +0000 (19:41 +0900)]
Revert "Do not suppress any shellcheck warnings"

This reverts commit 26664dff17b626550fae99181112f9ceff9bb971.

The commit enabled the shellcheck warning SC2119 based on the
understanding that bash would pass arguments list "$@" from caller to
callee when functions are called without arguments. However, it was not
correct then merit of SC2119 is not so important. On the other hand,
SC2119 reports false positive warning when bash functions take optional
arguments and they are called without arguments.

Per discussion on the list [1], we concluded that the merit of optional
arguments is larger than that of SC2119. Hence, disable SC2119 again.

[1] https://lore.kernel.org/linux-nvme/o5xnqvujzakhrudv7p64owiuzgozmean6blxow4vdxhdqozg5v@qznf2tzmey7k/

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: remove "udevadm settle" after _nvme_connect_subsys
Shin'ichiro Kawasaki [Thu, 17 Aug 2023 05:21:30 +0000 (14:21 +0900)]
nvme: remove "udevadm settle" after _nvme_connect_subsys

The previous commit introduced "udevadm settle" command at the end of
_nvme_connect_subsys. Then the command is no longer required after
calling _nvme_connect_subsys in test cases.

Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: fix nvme device readiness check after _nvme_connect_subsys
Shin'ichiro Kawasaki [Thu, 10 Aug 2023 11:17:51 +0000 (20:17 +0900)]
nvme/rc: fix nvme device readiness check after _nvme_connect_subsys

The helper function _nvme_connect_subsys() creates a nvme device. It may
take some time after the function call until the device gets ready for
I/O. So it is expected that the test cases call _find_nvme_dev() after
_nvme_connect_subsys() before I/O. _find_nvme_dev() returns the path of
the created device, and it also waits for uuid and wwid sysfs attributes
of the created device get ready. This wait works as the wait for the
device I/O readiness.

However, this wait by _find_nvme_dev() has two problems. The first
problem is missing call of _find_nvme_dev(). The test case nvme/047
calls _nvme_connect_subsys() twice, but _find_nvme_dev() is called only
for the first _nvme_connect_subsys() call. This causes too early I/O to
the device with tcp transport [1]. Fix this by moving the wait for the
device readiness from _find_nvme_dev() to _nvme_connect_subsys(). Also
add --no-wait option to _nvme_connect_subsys(). It allows to skip the
wait in _nvmet_passthru_target_connect() which has its own wait for
device readiness.

The second problem is wrong paths for the sysfs attributes. The paths
do not include namespace index, so the check for the attributes always
fail. Still _find_nvme_dev() does 1 second wait and allows the device
get ready for I/O in most cases, but this is not intended behavior.
Fix this by checking sysfs paths with the namespace index. Get list of
namespace indices for the sub-system and do the check for all indices.

On top of the checks for sysfs attributes, add 'udevadm settle' and a
check for the created device file. These ensures that the create device
is ready for I/O.

[1] https://lore.kernel.org/linux-block/CAHj4cs9GNohGUjohNw93jrr8JGNcRYC-ienAZz+sa7az1RK77w@mail.gmail.com/

Fixes: c766fccf3aff ("Make the NVMe tests more reliable")
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Add explicitly host to allow_host list
Daniel Wagner [Fri, 11 Aug 2023 09:36:13 +0000 (11:36 +0200)]
nvme: Add explicitly host to allow_host list

Only allow to connect to our setup target with the correct hostnqn.

Thus we have to explicitly add the test hostnqn to the test subsysnqn
allow_host list.

In nvme/030 the genctr is updated as side effect by writing the
attr_allow_any_host variable. Though writting to attr_allow_any_host is
not allowed after switching to the allow_host list. We can achieve the
same effect by adding and removing the host to the allow_host list.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add helper for adding/removing to allow list
Daniel Wagner [Fri, 11 Aug 2023 09:36:12 +0000 (11:36 +0200)]
nvme/rc: Add helper for adding/removing to allow list

Add two helpers to add or remove the host from the allow list of the
subsystem.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Use def_subsys_uuid variable
Daniel Wagner [Fri, 11 Aug 2023 09:36:11 +0000 (11:36 +0200)]
nvme: Use def_subsys_uuid variable

As all tests are using the same subsys uuid name anyway, use
the def_subsys_uuid variable.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add common def_subsys_uuid define
Daniel Wagner [Fri, 11 Aug 2023 09:36:10 +0000 (11:36 +0200)]
nvme/rc: Add common def_subsys_uuid define

Add common subsys uuid as global definition so that we can reuse it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
[Shin'ichiro: added export to def_subsys_uuid]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Use def_file_path variable instead local variable
Daniel Wagner [Fri, 11 Aug 2023 09:36:09 +0000 (11:36 +0200)]
nvme: Use def_file_path variable instead local variable

As all tests are using the same file path name anyway, use
the def_file_path variable.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add common file_path name define
Daniel Wagner [Fri, 11 Aug 2023 09:36:08 +0000 (11:36 +0200)]
nvme/rc: Add common file_path name define

Add common file_path name as global definition so that we can reuse it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
[Shin'ichiro: added export to def_file_path]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{041,042,043,044,045,048}: Remove local variable hostnqn and hostid
Daniel Wagner [Fri, 11 Aug 2023 09:36:07 +0000 (11:36 +0200)]
nvme/{041,042,043,044,045,048}: Remove local variable hostnqn and hostid

Commit acc408477e85 ("nvme/{041,042,043,044,045,048}: Use default
hostnqn and hostid") switched the test over to use the default
hostnqn. It missed the change to remove the local variable and
use the def_hostnqn/def_hostid directly.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Use def_subsysnqn variable instead local variable
Daniel Wagner [Fri, 11 Aug 2023 09:36:06 +0000 (11:36 +0200)]
nvme: Use def_subsysnqn variable instead local variable

As all tests are using the same subsystem nqn anyway, use
the def_subsysnqn variable and drop the local subsys_name
variable.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add common subsystem nqn define
Daniel Wagner [Fri, 11 Aug 2023 09:36:05 +0000 (11:36 +0200)]
nvme/rc: Add common subsystem nqn define

Add common subsystem nqn as global definition so that we can reuse it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
[Shin'ichiro: added export to def_subsysnqn]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/043: Use hostnqn to generate DHCAP key
Daniel Wagner [Fri, 11 Aug 2023 09:36:04 +0000 (11:36 +0200)]
nvme/043: Use hostnqn to generate DHCAP key

The key is supposed to be derived from the hostnqn not fom the subsys
name.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Reorganize test preamble code section
Daniel Wagner [Fri, 11 Aug 2023 09:36:03 +0000 (11:36 +0200)]
nvme: Reorganize test preamble code section

This unifies all the tests preamble code section.

Reorganize all tests to start with printing the test name, then
the setting nvmet and finally followed by the variable declarations.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{003,004,005,013,046,049}: Group all variables declarations
Daniel Wagner [Fri, 11 Aug 2023 09:36:02 +0000 (11:36 +0200)]
nvme/{003,004,005,013,046,049}: Group all variables declarations

Group all variable declarations together at the beginning of the
function. Many of the nvme tests do this but not all. Thus make these
tests use the same style. This allows to spot the odd balls in the
refactoring of the tests.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/004: reset zones of TEST_DEV before fio operation
Shin'ichiro Kawasaki [Fri, 4 Aug 2023 12:20:07 +0000 (21:20 +0900)]
block/004: reset zones of TEST_DEV before fio operation

When test target is a zoned block device with max_active_zones limit
larger than max_open_zones, fio write operation may fail depending on
zone conditions. To avoid the failure, reset zones of the device before
the fio run.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoREADME: clarify motivations to add new test cases
Shin'ichiro Kawasaki [Fri, 28 Jul 2023 11:07:20 +0000 (20:07 +0900)]
README: clarify motivations to add new test cases

It is often questioned when new test cases should be added to blktests.
Clarify it in "Adding Tests" section.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoCONTRIBUTING, README: recommend patch post for contributions
Shin'ichiro Kawasaki [Fri, 28 Jul 2023 11:07:19 +0000 (20:07 +0900)]
CONTRIBUTING, README: recommend patch post for contributions

There are voices that blktests changes through GitHub pull requests are
not visible to relevant block sub-system kernel developers who
communicate through linux-block mailing list. Some GitHub pull requests
in the past needed additional discussion in the linux-block mailing list
again to confirm that the changes were good for the kernel developers.

To reduce the repeated discussion in the mailing list and GitHub,
clarify that contribution by patch post to linux-block is preferred to
GitHub pull request. Still GitHub pull requests are open mainly for
quick, minor fixes.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoREADME: describe what './new' script documents
Shin'ichiro Kawasaki [Fri, 28 Jul 2023 11:07:18 +0000 (20:07 +0900)]
README: describe what './new' script documents

The knowledge required to implement blktests test cases are documented
in './new' script which generates test case script template. This is
handy when we implement new test cases. However, it is difficult to
refer the documentation when we do not implement new test cases.

To help to refer the documentation, add a pointer to it and describe
what it documents.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonew: don't mandate double square brackets
Shin'ichiro Kawasaki [Fri, 28 Jul 2023 11:07:17 +0000 (20:07 +0900)]
new: don't mandate double square brackets

It was guided for test statements in blktests scripts to use double
square brackets [[ ]] form instead of single square brackets [ ] form.
However, a number of patch contributors use [ ]. It is not productive to
replace them with [[ ]] and discouraging contributions. To avoid those
drawbacks, allow both forms and still keep [[ ]] as the preferred form.
While at it, fix a typo.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agosrc/Makefile: fix static linking of miniublk
Theodore Ts'o [Thu, 3 Aug 2023 21:20:52 +0000 (17:20 -0400)]
src/Makefile: fix static linking of miniublk

When using static linking, the libraries need to be placed after the
.o or .c files so they are searched.  Otherwise, the build will fail:

cc -O2 -Wall -Wshadow  -DHAVE_LINUX_BLKZONED_H  -D_GNU_SOURCE -lpthread -luring -o miniublk miniublk.c
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_ctrl_init':
miniublk.c:(.text+0xaeb): undefined reference to `io_uring_queue_init_params'
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_queue_deinit':
miniublk.c:(.text+0xb73): undefined reference to `io_uring_unregister_ring_fd'
/bin/ld: miniublk.c:(.text+0xb85): undefined reference to `io_uring_unregister_files'
/bin/ld: /tmp/ccfjiUvb.o: in function `ublk_io_handler_fn':
miniublk.c:(.text+0xd62): undefined reference to `io_uring_queue_init_params'
/bin/ld: miniublk.c:(.text+0xd77): undefined reference to `io_uring_register_ring_fd'
/bin/ld: miniublk.c:(.text+0xd8c): undefined reference to `io_uring_register_files'
/bin/ld: miniublk.c:(.text+0xe94): undefined reference to `io_uring_submit_and_wait_timeout'
/bin/ld: /tmp/ccfjiUvb.o: in function `__ublk_ctrl_cmd':
miniublk.c:(.text+0x14a6): undefined reference to `io_uring_submit'
/bin/ld: miniublk.c:(.text+0x1533): undefined reference to `__io_uring_get_cqe'
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: miniublk] Error 1

Fixes: d42fe976 ("src: add mini ublk source code")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoMerge pull request #124 from bvanassche/master
Shin'ichiro Kawasaki [Wed, 2 Aug 2023 04:50:37 +0000 (13:50 +0900)]
Merge pull request #124 from bvanassche/master

common/scsi_debug: Use _unload_module() instead of modprobe -r
_unload_module(): Report the failure reason once

2 years agocommon/scsi_debug: Use _unload_module() instead of modprobe -r
Bart Van Assche [Mon, 12 Jun 2023 19:52:28 +0000 (19:52 +0000)]
common/scsi_debug: Use _unload_module() instead of modprobe -r

It may happen that unloading the scsi_debug kernel module fails a few
times before it finally succeeds. Fix this by using _unload_module
instead of modprobe -r.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2 years ago_unload_module(): Report the failure reason once
Bart Van Assche [Mon, 12 Jun 2023 19:35:15 +0000 (12:35 -0700)]
_unload_module(): Report the failure reason once

Instead of reporting that unloading a module fails during every
iteration of the loop inside _unload_module(), report the unload failure
reason once.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2 years agoblock/005: require queue/scheduler sysfs attribute
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 05:53:52 +0000 (14:53 +0900)]
block/005: require queue/scheduler sysfs attribute

The test case block/005 does "switch schedulers while doing IO" then it requires
the queue/scheduler sysfs attribute. Check that requirement.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/004, zbd/{005,006}: call _test_dev_set_scheduler
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 06:22:46 +0000 (15:22 +0900)]
block/004, zbd/{005,006}: call _test_dev_set_scheduler

The test cases block/004, zbd/005 and zbd/006 do write to zoned block
devices which require mq-deadline scheduler. When TEST_DEV is a bio
based device-mapper, mq-deadline scheduler shall be set to destination
devices. For this purpose, call _test_dev_set_scheduler instead of
_test_dev_queue_set.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/rc: introduce _require_test_dev_sysfs
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 05:47:17 +0000 (14:47 +0900)]
common/rc: introduce _require_test_dev_sysfs

The test case block/005 requires TEST_DEV to have the queue/scheduler
sysfs attribute. However, kernel no longer provides the attribute since
version 6.5. Add the helper function _require_test_dev_sysfs to check
the requirement.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/{rc,dm}: introduce functions to set scheduler of dm destinations
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 06:07:51 +0000 (15:07 +0900)]
common/{rc,dm}: introduce functions to set scheduler of dm destinations

Since version v6.5, kernel no longer provides scheduler sysfs attribute
of bio based device-mapper. If TEST_DEV is a bio based device-mapper and
the test case requires specific scheduler, it is required to modify
sysfs attributes of destination devices instead of TEST_DEV.

To set scheduler to the sysfs attribute of destination devices, add the
helper function _dm_destination_dev_set_scheduler. It saves the original
scheduler value in the associative array SYSFS_QUEUE_SAVED so that it is
restored at each test case end. Also add _test_dev_set_scheduler which
sets scheduler regardless whether TEST_DEV is a bio based device-mapper
or not.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/dm: add script file for device-mapper functions
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 06:01:41 +0000 (15:01 +0900)]
common/dm: add script file for device-mapper functions

Create a new script file common/dm and move two helper functions for
device-mapper from tests/zbd/rc.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocheck, common/rc: save sysfs attribute path
Shin'ichiro Kawasaki [Tue, 18 Jul 2023 07:19:03 +0000 (16:19 +0900)]
check, common/rc: save sysfs attribute path

Current implementation saves sysfs attributes under queue/ directory
in the associative array TEST_DEV_QUEUE_SAVED using attribute file names
as keys. The saved attributes are restored after each test case run.
When TEST_DEV is a device-mapper, this attribute restore does not cover
attributes of device-mapper destination devices. As a preparation to
cover the destination devices, use path of the attributes as keys
instead of file names. Also rename the associative array
TEST_DEV_QUEUE_SAVED to SYSFS_QUEUE_SAVED.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/ublk: avoid modprobe failure for built-in ublk_drv
Shin'ichiro Kawasaki [Wed, 5 Jul 2023 10:35:22 +0000 (19:35 +0900)]
common/ublk: avoid modprobe failure for built-in ublk_drv

When ublk_drv driver is not a loadable module but a built-in module,
modprobe for the driver fails in _init_ublk. This results in unexpected
test case skips with the message "requires ublk_drv".

To not skip the test cases with built-in ublk_drv, call modprobe only
when the driver is loadable and its module file exists. Also, do not set
SKIP_REASONS to handle modprobe failure as test case failure.

Fixes: 840ccf1fc33e ("block/033: add test to cover gendisk leak")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{041,042,043,044,045,048}: Use default hostnqn and hostid
Daniel Wagner [Mon, 3 Jul 2023 09:16:47 +0000 (11:16 +0200)]
nvme/{041,042,043,044,045,048}: Use default hostnqn and hostid

The host might have enabled the udev/systemd auto connect feature.
This disturbs the blktests for the fc transport. nvme-cli is able
to distinguish between the different invocations via the --context
option.

Instead creating random generated IDs or reuse the hostnqn, it's safer
to always use the same hostnqn to reduce the risk that the matching
logic doesn't work. For this purpose, drop references to
/etc/nvme/hostid and /etc/nvme/hostnqn.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: resolved conflict and noted /etc/nvme/* in commit message]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Avoid triggering host nvme-cli autoconnect
Daniel Wagner [Mon, 3 Jul 2023 09:16:46 +0000 (11:16 +0200)]
nvme/rc: Avoid triggering host nvme-cli autoconnect

When the host has enabled the udev/systemd autoconnect services for the
fc transport it interacts with blktests and make tests break.

nvme-cli learned to ignore connects attemps when using the --context
command line option paired with a volatile configuration. Thus we can
mark all the resources created by blktests and avoid any interaction
with the systemd autoconnect scripts.

Only enabled this for the fc transport.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/048: Check for queue count check directly
Daniel Wagner [Mon, 3 Jul 2023 09:16:45 +0000 (11:16 +0200)]
nvme/048: Check for queue count check directly

The test monitored the state changes live -> resetting -> connecting ->
live, to figure out the queue count change was successful.

The fc transport is reconnecting very fast and the state transitions
are not observed by the current approach.

So instead trying to monitor the state changes, let's just wait for the
live state and the correct queue number.

As queue count is depending on the number of online CPUs we explicitly
use 1 and 2 for the max_queue count. This means the queue_count value
needs to reach either 2 or 3 (admin queue included).

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/043: use a valid hostkey
Alan Adamson [Mon, 3 Jul 2023 18:25:49 +0000 (11:25 -0700)]
nvme/043: use a valid hostkey

The test does not generate a hostkey and uses a NULL when setting
up and connecting to a target. The test passes, but a valid hotkey
should be used. This patch generates a valid hostkey and uses it
when setting up the target.

Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/linux-nvme/eedfab08-e50c-0a51-5dd3-2861dcc02b4d@oracle.com/
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agozbd/009: skip have_good_mkfs_btrfs when mkfs.btrfs not avaiable
Yi Zhang [Fri, 30 Jun 2023 12:00:28 +0000 (20:00 +0800)]
zbd/009: skip have_good_mkfs_btrfs when mkfs.btrfs not avaiable

When mkfs.btrfs is not available, have_good_mkfs_btrfs in the test case
zbd/009 reports a bash script error. Skip have_good_mkfs_btrfs to avoid
the error.

tests/zbd/009: line 24: mkfs.btrfs: command not found
zbd/009 (test gap zone support with BTRFS)                   [not run]
    driver btrfs is not available
    mkfs.btrfs is not available

Fixes: 21f94b20a9af ("zbd/009: check mkfs.btrfs version")
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
[Shin'ichiro: improved commit message]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: specify hostnqn and hostid to nvme discover and connect
Shin'ichiro Kawasaki [Wed, 28 Jun 2023 12:43:43 +0000 (21:43 +0900)]
nvme/rc: specify hostnqn and hostid to nvme discover and connect

After the kernel commit ae8bd606e09b ("nvme-fabrics: prevent overriding
of existing host"), 'nvme discover' and 'nvme connect' commands will
fail in case hostid and hostnqn don't maintain 1:1 mapping in the
system. This caused failure of many test cases in the nvme group with
kernel messages "nvme_fabrics: found same hostid XXX but different
hostnqn YYY".

To avoid the failures, specify valid hostnqn and hostid to the nvme
commands always. Prepare def_hostnqn and def_hostid even when
/etc/nvme/hostnqn or /etc/nvme/hostid is not available. Using these
values, add --hostnqn and --hostid options to the nvme commands in
_nvme_discover() and _nvme_connect_subsys().

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Link: https://lore.kernel.org/linux-nvme/CAHj4cs_qUWzetD0203EKbBLNv3KF=qgTLsWLeHN3PY7UE6mzmw@mail.gmail.com/
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Tested-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/034: Test memory is released by null-blk driver with memory_backed=1
Nitesh Shetty [Wed, 14 Jun 2023 17:06:42 +0000 (22:36 +0530)]
block/034: Test memory is released by null-blk driver with memory_backed=1

This tests memory leak, by loading/unloading nullblk driver.
Steps:
1. Load nullblk driver with memory_backed=1
2. "dd" of 50M
3. Unload null-blk driver
We do it for 5 iterations to avoid any noise.

Commit 8cfb98196cceec35416041c6b91212d2b99392e4 fixes issue in kernel

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/040: Free loop back resources
Daniel Wagner [Mon, 12 Jun 2023 14:29:45 +0000 (16:29 +0200)]
nvme/040: Free loop back resources

The tests does not cleanup all resources after it has finished. This
leads to rm not being able to remove the TMPDIR cleanly:

  + rm -rf blktests/results/tmpdir.nvme.040.m2J
  rm: cannot remove 'blktests/results/tmpdir.nvme.040.m2J': Directory not empty

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/011: recover test target NVME device capacity
Shin'ichiro Kawasaki [Fri, 26 May 2023 04:58:43 +0000 (13:58 +0900)]
block/011: recover test target NVME device capacity

The test case runs fio while disabling and enabling PCI device of the
test target block device. When the block device is a NVME PCI device,
the test triggers NVME controller reset. When an error happens during
the reset, NVME PCI driver marks zero capacity for the device. This
zero capacity device causes failures of the following test cases.

To avoid the failures by zero device capacity, check the capacity at the
test end. If it is zero, remove the device and rescan PCI bus to detect
the device again, and regain the correct capacity.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/011: skip when mounted block devices are affected
Shin'ichiro Kawasaki [Fri, 26 May 2023 04:58:42 +0000 (13:58 +0900)]
block/011: skip when mounted block devices are affected

The test case disables PCI device of the test target block device. When
the PCI device has other block devices mounted, those block devices are
disabled also. If the mounted device is the system disk, the test screws
up the system. To avoid such dangerous operation, check if the target
PCI device has mounted block devices. In that case, skip the test.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/rc: introduce _get_pci_from_dev_sysfs
Shin'ichiro Kawasaki [Fri, 26 May 2023 04:58:41 +0000 (13:58 +0900)]
common/rc: introduce _get_pci_from_dev_sysfs

To prepare for block/011 test case improvement, add the helper function
which gets PCI device from the given sysfs path of a block device.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvmeof-mp: Remove nvmeof-mp tests
Daniel Wagner [Tue, 6 Jun 2023 07:54:43 +0000 (09:54 +0200)]
nvmeof-mp: Remove nvmeof-mp tests

The nvmeof-mp are designed to test a NVMe multipathing setup using
dm_multipath, which was a configuration RHEL shipped. In the meantime,
RHEL switched also to NVMe native multipathing which is tested with the
nvme tests.

The nvme tests cover all the use cases which are testes by nvmeof-mp
including the transport failure, see nvme/040.

During LSFMM 2023 conference it was decided it is better to drop these
tests and reduce the maintenance burden on blktests.

Cc: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: remove _filter_discovery
Shin'ichiro Kawasaki [Wed, 7 Jun 2023 05:58:55 +0000 (14:58 +0900)]
nvme/rc: remove _filter_discovery

The previous commit removed calls to _filter_discovery(). Remove the
helper function.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{016,017}: use _check_genctr instead of _filter_discovery
Yang Xu [Wed, 31 May 2023 01:07:01 +0000 (09:07 +0800)]
nvme/{016,017}: use _check_genctr instead of _filter_discovery

Since commit 328943e3 ("Update tests for discovery log page changes"),
blktests also include the discovery subsystem itself. But it
will lead these cases fails on older nvme-cli system.

To avoid this, like nvme/002, use _check_genctr to check instead of
comparing many discovery Log Entry output.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Cleanup fc resource before module unloading
Daniel Wagner [Wed, 3 May 2023 08:38:16 +0000 (10:38 +0200)]
nvme/rc: Cleanup fc resource before module unloading

Cleanup all fc resources before unloading the module, so it the
operations are in reverse order how we setup them.

Also unload the nvme-fcloop after usage.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Cleanup fc ports in reverse order
Daniel Wagner [Wed, 3 May 2023 08:38:15 +0000 (10:38 +0200)]
nvme/rc: Cleanup fc ports in reverse order

We need to free the resources in the opposite order as we allocate them.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agotests: Add ublk tests
Ziyang Zhang [Wed, 24 May 2023 08:55:41 +0000 (16:55 +0800)]
tests: Add ublk tests

It is very important to test ublk crash handling since the userspace
part is not reliable. Especially we should test removing device, killing
ublk daemons and user recovery feature.

Add five new tests for ublk to cover these cases.

Signed-off-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agosrc/miniublk: add user recovery
Ziyang Zhang [Wed, 24 May 2023 08:55:40 +0000 (16:55 +0800)]
src/miniublk: add user recovery

We are going to test ublk's user recovery feature so add support in
miniublk.

Signed-off-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agosrp/rc: Replace _have_module() with _have_driver()
Xiao Yang [Wed, 24 May 2023 03:06:43 +0000 (11:06 +0800)]
srp/rc: Replace _have_module() with _have_driver()

srp test group can be executed with built-in scsi_dh_alua,
scsi_dh_emc and scsi_dh_rdac drivers.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{016,017}: Make the number iterations configurable
Daniel Wagner [Thu, 11 May 2023 14:09:53 +0000 (16:09 +0200)]
nvme/{016,017}: Make the number iterations configurable

Some tests hard code high values of iterations. This makes them run
relatively long compared to the other tests. Introduce a new environment
variable nvme_num_iter to allow tune the runtime.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{002,030}: Move discovery generation counter code to rc
Daniel Wagner [Thu, 11 May 2023 14:09:52 +0000 (16:09 +0200)]
nvme/{002,030}: Move discovery generation counter code to rc

Move the discovery generation counter code to rc so that we can reuse
it in 002.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{045,047}: Calculate IO size for random fio jobs
Daniel Wagner [Thu, 11 May 2023 14:09:51 +0000 (16:09 +0200)]
nvme/{045,047}: Calculate IO size for random fio jobs

_nvme_calc_run_io_size() returns the jobs size for _run_fio_rand_io()
function. The jobs size is the size per job, thus we have to divide
through the number of CPUs.

_xfs_run_fio_verify_io() is replaced with _run_fio_rand_io() because the
former has a minimum nvme_img_size of 350M. Both tests nvme/{045,047}
just want some IO to verify that the path is working. Thus reduce the
min nmve_img_size requirement switch to _run_fio_rand_io()

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Add minimal test image size requirement
Daniel Wagner [Thu, 11 May 2023 14:09:50 +0000 (16:09 +0200)]
nvme: Add minimal test image size requirement

Some tests need a minimal test image size to work correctly. Thus add a
helper to check the size and update these tests accordingly.

The image minimum is 4M because some of the test have hard coded values.
All tests which use the xfs fio verification job have a minimum
requirement of 350M impossed by the xfs filesystem.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: Make test image size configurable
Daniel Wagner [Thu, 11 May 2023 14:09:49 +0000 (16:09 +0200)]
nvme: Make test image size configurable

The reduce the overall runtime of the testsuite by making the default
size of the test image small. For verification jobs, the default can be
overwriten via the newly introduced nvme_img_size environment variable.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoDocumentation: Add info on nvme_trtype
Daniel Wagner [Thu, 11 May 2023 14:09:48 +0000 (16:09 +0200)]
Documentation: Add info on nvme_trtype

Mention that the nvme tests can be parametrized.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{032,040}: Use runtime fio background jobs
Daniel Wagner [Thu, 11 May 2023 14:09:47 +0000 (16:09 +0200)]
nvme/{032,040}: Use runtime fio background jobs

The fio jobs are supposed to run long in background during the test.
Instead relying on a job size use explicit runtime for this.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/xfs: Limit fio size job to fit into xfs fs
Daniel Wagner [Thu, 11 May 2023 14:09:46 +0000 (16:09 +0200)]
common/xfs: Limit fio size job to fit into xfs fs

The usable capacity of the filesystem is less than the raw
partition/device size due to the additional meta/log data.

Ensure that the job size for fio is not exceeding the limits.

Because we have hard coded the path where we mount the filesystem
and don't want to expose this, we just update max size inside
_xfs_run_fio_verify_io(). No need to leak this into the caller.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/xfs: Make size argument optional for _xfs_run_fio_verify_io
Daniel Wagner [Thu, 11 May 2023 14:09:45 +0000 (16:09 +0200)]
common/xfs: Make size argument optional for _xfs_run_fio_verify_io

Make the size argument optional by reading the filesystem info. The
caller doesn't have to guess (or calculate) how big the max IO size.
The log data structure of XFS is reducing the capacity.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/{014/015}: Do not hard code device size for dd test
Daniel Wagner [Thu, 11 May 2023 14:09:44 +0000 (16:09 +0200)]
nvme/{014/015}: Do not hard code device size for dd test

Read the block device sizes instead hard coding them,
so that the device size can be configurable in future.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Auto convert test device size info
Daniel Wagner [Thu, 11 May 2023 14:09:43 +0000 (16:09 +0200)]
nvme/rc: Auto convert test device size info

Introduce a convert_to_mb() helper which converts the size argument
to MBytes and use in test device require function. This makes it
possible to use user input strings in future.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/{001,002,027}: allow to run with built-in scsi_debug and sd_mod
Shin'ichiro Kawasaki [Wed, 26 Apr 2023 10:06:11 +0000 (19:06 +0900)]
block/{001,002,027}: allow to run with built-in scsi_debug and sd_mod

To allow the test cases run with build-in scsi_debug, replace
'_have_module scsi_debug' with _have_scsi_debug, and replace
_init_scsi_debug with _configure_scsi_debug.

Also to allow block/001 run with built-in sd_mod, replace
'_have_module sd_mod' with '_have_kernel_option BLK_DEV_SD'. When sd_mod
driver is built-in, /sys/module/sd_mod directory is not created. Then
_have_driver() can not detect availability of the driver. Instead, refer
the kernel config to check availability of the driver.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoscsi/{004,005}: allow to run with built-in scsi_debug
Shin'ichiro Kawasaki [Tue, 25 Apr 2023 11:47:44 +0000 (20:47 +0900)]
scsi/{004,005}: allow to run with built-in scsi_debug

To allow the test case run with build-in scsi_debug, replace
'_have_module scsi_debug' with _have_scsi_debug, and replace
_init_scsi_debug with _configure_scsi_debug.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/scsi_debug: introduce _configure_scsi_debug
Shin'ichiro Kawasaki [Tue, 25 Apr 2023 11:47:43 +0000 (20:47 +0900)]
common/scsi_debug: introduce _configure_scsi_debug

To set up scsi_debug devices with built-in scsi_debug module, introduce
a new helper function _configure_scsi_debug. It works in similar manner
as _init_scsi_debug which sets up scsi_debug devices with loadable
scsi_debug module.

_configure_scsi_debug takes parameters of scsi_debug devices in format
of 'key=value' as its arguments. It calls another new helper function
_scsi_debug_key_path to find sysfs files corresponding to the keys in
/sys/module/scsi_debug/parameters or /sys/bus/pseudo/drivers/scsi_debug.
When the file is found, write the value to the file.

Before setting the parameters through sysfs files, save current values
of scsi_debug parameters in ORIG_SCSI_DEBUG_PARAMS. Use the saved values
to restore parameters in _exit_scsi_debug. Do this value restore not
only for the parameters modified in _configure_scsi_debug but also for
the parameters modified by test cases.

Among the parameters, 'add_host' has special meaning to add new hosts.
Then handle it separately so that it is set at last in
_configure_scsi_debug, and restored at first in _exit_scsi_debug.

Also record the hosts which exist before _configure_scsi_debug in the
array ORIG_SCSI_DEBUG_HOSTS. Those hosts should not be used for testing,
then do not add them to SCSI_DEBUG_HOSTS.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/scsi_debug: factor out _setup_scsi_debug_vars
Shin'ichiro Kawasaki [Tue, 25 Apr 2023 11:47:42 +0000 (20:47 +0900)]
common/scsi_debug: factor out _setup_scsi_debug_vars

As a preparation to introduce a new helper function to configure
scsi_debug device with built-in scsi_debug module, factor out a part
of _init_scsi_debug to a new function _setup_scsi_debug_vars.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/scsi_debug, tests/*: re-define _have_scsi_debug
Shin'ichiro Kawasaki [Tue, 25 Apr 2023 11:47:41 +0000 (20:47 +0900)]
common/scsi_debug, tests/*: re-define _have_scsi_debug

As a preparation to adapt test cases to built-in scsi_debug module, re-
define the _have_scsi_debug function. It checks that the scsi_debug
module is built as a loadable module. Modify it to check that the
scsi_debug module is available as built-in module or loadable module.

Also replace all _have_scsi_debug calls in test cases with
"_have_module scsi_debug" so that the change of _have_scsi_debug do not
affect the test cases. Following commits will modify them to call
_have_scsi_debug, only for test cases ready to run with built-in
scsi_debug.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/rc: skip module file check if modules path does not exist
Shin'ichiro Kawasaki [Tue, 25 Apr 2023 11:47:40 +0000 (20:47 +0900)]
common/rc: skip module file check if modules path does not exist

When all of the kernel modules are built-in, /lib/modules/*/kernel path
may not exist. In this case, check for the path results in failure. Skip
the check when the path does not exist.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoloop/009: add test for loop partition uvents
Alyssa Ross [Thu, 30 Mar 2023 16:02:47 +0000 (16:02 +0000)]
loop/009: add test for loop partition uvents

Link: https://lore.kernel.org/r/20230320125430.55367-1-hch@lst.de/
Suggested-by: Chaitanya Kulkarni <chaitanyak@nvidia.com>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
[Shin'ichiro: added mkdir for /run/udev/rules.d]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoMerge pull request #119 from yizhanglinux/add-have-fio-check-for-nvme-045
Shin'ichiro Kawasaki [Fri, 19 May 2023 06:23:41 +0000 (15:23 +0900)]
Merge pull request #119 from yizhanglinux/add-have-fio-check-for-nvme-045

test/nvme: add missing _have_fio check for nvme/045

2 years agoMerge pull request #118 from Ablu/ldflag-cross-compile
Shin'ichiro Kawasaki [Fri, 19 May 2023 06:23:11 +0000 (15:23 +0900)]
Merge pull request #118 from Ablu/ldflag-cross-compile

src/Makefile: forward LDFLAGS to $(CC)

2 years agotest/nvme: add missing _have_fio check for nvme/045
Yi Zhang [Fri, 5 May 2023 23:29:18 +0000 (07:29 +0800)]
test/nvme: add missing _have_fio check for nvme/045

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
2 years agotests/dm: add dm test group and a test for self-map
Yu Kuai [Thu, 27 Apr 2023 02:41:26 +0000 (10:41 +0800)]
tests/dm: add dm test group and a test for self-map

Verify that reload a dm with maps to itself will fail.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
[Shin'ichiro: improved code for shellcheck, commit title and file mode]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon/rc: fix kernel version parse failure
Shin'ichiro Kawasaki [Sat, 29 Apr 2023 10:55:36 +0000 (19:55 +0900)]
common/rc: fix kernel version parse failure

When kernel version numbers have postfix letters, _have_fio_ver fail to
parse the version. For example, uname -r returns "6.3.0+", it handles
"0+" as a number and fails to parse. Fix it by dropping all letters
other than numbers or period.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/linux-block/20230501041415.49939-1-shinichiro.kawasaki@wdc.com/
2 years agoblock/{014,015,030}: don't require modular null_blk for fault-injection
Akinobu Mita [Sun, 16 Apr 2023 04:37:44 +0000 (13:37 +0900)]
block/{014,015,030}: don't require modular null_blk for fault-injection

This blktests change changes null_blk fault-injection settings to be
configured via configfs instead of module parameters.
This allows null_blk fault-injection tests to run even if the null_blk is
built-in the kernel and not built as a module.

If the null_blk does not yet support configuring fault-injection via
configfs, fall back to set up with module parameter.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
[Shin'ichiro: improved commit title]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agosrc/Makefile: forward LDFLAGS to $(CC)
Erik Schilling [Tue, 18 Apr 2023 13:27:41 +0000 (15:27 +0200)]
src/Makefile: forward LDFLAGS to $(CC)

Something external may set some special LDFLAGS. Currently those would
get ignored. Lets honor them and pass them to the compiler.

This simplifies packaging and cross-compilation.

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2 years agonvme/039: avoid failure by error message rate limit
Shin'ichiro Kawasaki [Wed, 12 Apr 2023 08:59:23 +0000 (17:59 +0900)]
nvme/039: avoid failure by error message rate limit

The test case nvme/039 tests that expected error messages are printed
for errors injected to the nvme driver. However, the test case fails by
chance when previous test cases generate many error messages. In this
case, the kernel function pr_err_ratelimited() may suppress the error
messages that the test case expects. Also, it may print messages that
the test case does not expect, such as "blk_print_req_error: xxxx
callbacks suppressed".

To avoid the failure, make two improvements for the test case. Firstly,
wait DEFAULT_RATE_LIMIT seconds at the beginning of the test to ensure
the expected error messages are not suppressed. Secondly, exclude the
unexpected message for the error message check. Introduce a helper
function last_dmesg() for the second improvement.

Fixes: 9accb5f86670 ("tests/nvme: add tests for error logging")
Link: https://lore.kernel.org/linux-block/5vnpdeocos6k4nmh6ewh7ltqz7b6wuemzcmqflfkybejssewkh@edtqm3t4w3zv/
Reviewed-by: Alan Adamson <alan.adamson@oracle.com>
Tested-by: Alan Adamson <alan.adamson@oracle.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/049: add test for uring-passthrough
Kanchan Joshi [Thu, 13 Apr 2023 08:50:24 +0000 (14:20 +0530)]
nvme/049: add test for uring-passthrough

User can communicate to NVMe char device (/dev/ngXnY) using the
uring-passthrough interface. This test exercises some of these
communication pathways, using the 'io_uring_cmd' ioengine of fio.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocommon,fio: helper for version check
Kanchan Joshi [Thu, 13 Apr 2023 08:50:23 +0000 (14:20 +0530)]
common,fio: helper for version check

Add new helper _have_fio_ver which checks whether installed fio version
is greater than or equal to input.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/048: test queue count changes on reconnect
Daniel Wagner [Thu, 6 Apr 2023 08:30:50 +0000 (10:30 +0200)]
nvme/048: test queue count changes on reconnect

The target is allowed to change the number of I/O queues. Test if the
host is able to reconnect in this scenario.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: added _setup_nvmet and replaced spaces with tabs]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add timeout argument parsing to _nvme_connect_subsys()
Daniel Wagner [Thu, 6 Apr 2023 08:30:49 +0000 (10:30 +0200)]
nvme/rc: Add timeout argument parsing to _nvme_connect_subsys()

Add the possiblity for tests to specify the timeout values. This makes
it possible to reduce the test runtime.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/047: Test different queue types for fabrics transports
Daniel Wagner [Wed, 29 Mar 2023 09:02:02 +0000 (11:02 +0200)]
nvme/047: Test different queue types for fabrics transports

Test if the fabrics transports are handling different queues types
correctly.

Currently, only TCP and RDMA from the fabric transport family support
this feature, so limit the test to these two.

We also issue some I/O to make sure that not just the plain connect
works. For this we have to use a file system which supports direct I/O
and hence we use a device backend.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add parametric transport required check
Daniel Wagner [Wed, 29 Mar 2023 09:02:01 +0000 (11:02 +0200)]
nvme/rc: Add parametric transport required check

Not all transport support the same features thus we need to be able to
express this. Add a transport require check which can be runtime
parameterized.

While at it also update the existing helpers to test for trtype to with
an explicit list of transport types.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Add nr queue parser arguments to _nvme_connect_subsys()
Daniel Wagner [Wed, 29 Mar 2023 09:02:00 +0000 (11:02 +0200)]
nvme/rc: Add nr queue parser arguments to _nvme_connect_subsys()

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/rc: Parse optional arguments in _nvme_connect_subsys()
Daniel Wagner [Wed, 29 Mar 2023 09:01:59 +0000 (11:01 +0200)]
nvme/rc: Parse optional arguments in _nvme_connect_subsys()

Extend the nvme_connect_subsys() function to parse optional arguments.
This avoids that all test have to pass in always all arguments.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoMerge pull request #116 from yizhanglinux/add-missing-executable-mode
Shin'ichiro Kawasaki [Mon, 10 Apr 2023 11:54:55 +0000 (20:54 +0900)]
Merge pull request #116 from yizhanglinux/add-missing-executable-mode

Add missing executable mode

2 years agotests/block/013.out: remove the unused 013.out file
Yi Zhang [Fri, 31 Mar 2023 09:35:59 +0000 (05:35 -0400)]
tests/block/013.out: remove the unused 013.out file

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
2 years agotests: add the missing +x mode
Yi Zhang [Fri, 31 Mar 2023 09:34:58 +0000 (05:34 -0400)]
tests: add the missing +x mode

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
2 years agosrc/Makefile: fix number sign handling in macro
Shin'ichiro Kawasaki [Wed, 1 Mar 2023 08:03:01 +0000 (17:03 +0900)]
src/Makefile: fix number sign handling in macro

GNU make version 4.3 introduced a backward-incompatible change. The
number sign '#' now should not have preceding backslash in a macro [1].
To make macros with number signs work regardless of make versions,
assign the number sign to a variable.

[1] https://lwn.net/Articles/810071/

Reported-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Link: https://lore.kernel.org/linux-block/cfccc895-5a9b-f45b-5851-74c94219d743@linux.alibaba.com/
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/033: add test to cover gendisk leak
Ming Lei [Fri, 24 Feb 2023 12:45:02 +0000 (20:45 +0800)]
block/033: add test to cover gendisk leak

So far only sync ublk removal is supported, and the device's
last reference is dropped in gendisk's ->free_disk(), so it
can be used to test gendisk leak issue.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agosrc: add mini ublk source code
Ming Lei [Fri, 24 Feb 2023 12:45:01 +0000 (20:45 +0800)]
src: add mini ublk source code

Prepare for adding ublk related test:

1) ublk delete is sync removal, this way is convenient to
   blkg/queue/disk instance leak issue

2) mini ublk has two builtin target(null, loop), and loop IO is
handled by io_uring, so we can use ublk to cover part of io_uring
workloads

3) not like loop/nbd, ublk won't pre-allocate/add disk, and always
add/delete disk dynamically, this way may cover disk plug & unplug
tests

4) ublk specific test given people starts to use it, so better to
let blktest cover ublk related tests

Add mini ublk source for test purpose only, which is easy to use:

./miniublk add -t {null|loop} [-q nr_queues] [-d depth] [-n dev_id]
 default: nr_queues=2(max 4), depth=128(max 128), dev_id=-1(auto allocation)
 -t loop -f backing_file
 -t null
./miniublk del [-n dev_id] -a
 -a delete all devices, -n delete specified device
./miniublk list [-n dev_id] -a
 -a list all devices, -n list specified device, default -a

miniublk depends on liburing 2.2, adds HAVE_LIBURING for checking if
liburing 2.2 exists; also add HAVE_UBLK_HEADER for checking ublk kernel
UAPI header exits. If either of two dependencies can't be met, simply
ignore miniublk target.

Also v6.0 is the 1st linux kernel release with ublk.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme/046: add test for unprivileged passthrough
Kanchan Joshi [Thu, 9 Feb 2023 09:45:41 +0000 (15:15 +0530)]
nvme/046: add test for unprivileged passthrough

Alters permissions for char-device node (/dev/ngX) and runs few
passthrough commands as a normal user to exercise nvme_cmd_allowed().

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
[Shin'ichiro: adjusted to normal user helper functions]
Tested-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agocheck, common/rc: support normal user privilege
Shin'ichiro Kawasaki [Mon, 13 Feb 2023 02:00:08 +0000 (11:00 +0900)]
check, common/rc: support normal user privilege

To run commands with normal user privilege, add a new config variable
NORMAL_USER and two helper functions _run_user and _require_normal_user.
The user name specified to NORMAL_USER is used to run the commands
specified to _run_user. The test cases which require NORMAL_USER shall
call _require_normal_user to ensure the NORMAL_USER is valid.

Tested-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/032: add test to cover umount one deleted disk
Ming Lei [Wed, 8 Feb 2023 01:02:35 +0000 (09:02 +0800)]
block/032: add test to cover umount one deleted disk

disk can be disappear any time because of error handling, when
it is usually being mounted. Make sure umount can be done successfully
after disk deleting is done from error handling.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/linux-block/20230208063552.GA15030@lst.de/T/#u
[Shin'ichiro: fixed commit title and added Link tag]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoMerge pull request #111 from hreinecke/disc-log-changes
Shin'ichiro Kawasaki [Tue, 7 Feb 2023 03:56:44 +0000 (12:56 +0900)]
Merge pull request #111 from hreinecke/disc-log-changes

Update tests for discovery log page changes

2 years agoUpdate tests for discovery log page changes
Hannes Reinecke [Mon, 6 Feb 2023 14:51:42 +0000 (15:51 +0100)]
Update tests for discovery log page changes

With TP8013 the discovery log includes now a record for the
discovery subsystem itself, so we need to update the blktests
to be aware of the new discovery log page layout.

Signed-off-by: Hannes Reinecke <hare@suse.de>
2 years agoMerge pull request #110 from bvanassche/build-fix
Shin'ichiro Kawasaki [Fri, 3 Feb 2023 07:53:18 +0000 (16:53 +0900)]
Merge pull request #110 from bvanassche/build-fix

src/discontiguous-io.cpp: Fix the build

2 years agoMerge pull request #109 from bvanassche/polling
Shin'ichiro Kawasaki [Fri, 3 Feb 2023 07:49:55 +0000 (16:49 +0900)]
Merge pull request #109 from bvanassche/polling

tests/block/007: Rework I/O polling

2 years agosrc/discontiguous-io.cpp: Fix the build
Bart Van Assche [Thu, 2 Feb 2023 18:20:39 +0000 (10:20 -0800)]
src/discontiguous-io.cpp: Fix the build

Fix the following build error:

g++  -O2 -std=c++11 -Wall -Wextra -Wshadow -Wno-sign-compare -Werror -DHAVE_LINUX_BLKZONED_H -o discontiguous-io discontiguous-io.cpp
discontiguous-io.cpp: In function ‘void dumphex(std::ostream&, const void*, size_t)’:
discontiguous-io.cpp:92:24: error: ‘uintptr_t’ was not declared in this scope

Signed-off-by: Bart Van Assche <bvanassche@acm.org>