]> www.infradead.org Git - users/sagi/blktests.git/log
users/sagi/blktests.git
17 months agoscsi/008: Test SCSI disk data lifetime support
Bart Van Assche [Tue, 3 Oct 2023 21:46:37 +0000 (14:46 -0700)]
scsi/008: Test SCSI disk data lifetime support

SCSI disk data lifetime support is available since kernel v6.9-rc1.
See also https://lore.kernel.org/linux-scsi/3b789eacddd6265921be9da6e15257908f29b186.camel@HansenPartnership.com/.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
17 months agocommon/fio: Fix the _run_fio() return code
Bart Van Assche [Mon, 25 Mar 2024 20:05:04 +0000 (13:05 -0700)]
common/fio: Fix the _run_fio() return code

Make _run_fio() return the fio exit code such that tests can use that
exit code to verify whether or not a fio run completed successfully.

Fixes: 3891768d9d6b ("blktests: add fio data verification routine")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
17 months agonvme/rc: fix shellcheck warning SC2086
Yi Zhang [Sun, 7 Apr 2024 03:17:52 +0000 (11:17 +0800)]
nvme/rc: fix shellcheck warning SC2086

tests/nvme/rc:1056:7: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/rc:1057:7: note: Double quote to prevent globbing and word splitting. [SC2086]

The warnings are observed with ShellCheck version 0.8.0. They are not
observed with ShellCheck version 0.9.0 and 0.10.0.

Fixes: 369d310 ("nvme: Add passthru error logging tests to nvme/039")
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
[Shin'ichiro: noted ShellCheck version dependency]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/{013,014}: fix device filename
Shin'ichiro Kawasaki [Mon, 8 Apr 2024 01:34:38 +0000 (10:34 +0900)]
nvme/{013,014}: fix device filename

Fixes: e55c4e09e457 ("nvme: don't assume namespace id")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/011: fix filename path
Yi Zhang [Sun, 7 Apr 2024 03:17:08 +0000 (11:17 +0800)]
nvme/011: fix filename path

Fixes: e55c4e0 ("nvme: don't assume namespace id")
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/028: drop unused nvmedev
Daniel Wagner [Tue, 26 Mar 2024 13:14:02 +0000 (14:14 +0100)]
nvme/028: drop unused nvmedev

Nothing uses nvmedev, so just remove it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: don't assume namespace id
Daniel Wagner [Tue, 26 Mar 2024 13:14:01 +0000 (14:14 +0100)]
nvme: don't assume namespace id

The tests assume that the namespace id is always 1. This might not be
correct in future (e.g. running real targets), thus harden the test by
using the uuid to lookup the correct namespace id.

The passthru test already do this, so it makes also sense to update the
other tests as well.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/{041,042,043,044,045,048}: do not pass default host{nqn|id} to _nvme_connect_subsys
Daniel Wagner [Tue, 26 Mar 2024 13:14:00 +0000 (14:14 +0100)]
nvme/{041,042,043,044,045,048}: do not pass default host{nqn|id} to _nvme_connect_subsys

There is no point in passing the default values to
_nvme_connect_subsys, thus drop these arguments.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: drop default subsysnqn argument from _nvmet_passthru_target_connect
Daniel Wagner [Tue, 26 Mar 2024 13:13:59 +0000 (14:13 +0100)]
nvme: drop default subsysnqn argument from _nvmet_passthru_target_connect

Remove the last positional argument for _nvmet_passthru_target_connect
which most test pass in the default subsysnqn anyway. There is little
point in cluttering all the test textual noise.

While at it, also use subsysnqn as variable name everywhere, instead of
subsys_name.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: drop default subsysnqn argument from _nvme_passthru_target_{setup|cleanup}
Daniel Wagner [Tue, 26 Mar 2024 13:13:58 +0000 (14:13 +0100)]
nvme: drop default subsysnqn argument from _nvme_passthru_target_{setup|cleanup}

Remove the last positional argument for
_nvme_passthrue_target_{setup|cleanup} which most test pass in the
default subsysnqn anyway. There is little point in cluttering all the
test textual noise.

While at it, also use subsysnqn as variable name everywhere, instead of
subsys_name.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: dropped the change for _nvme_disconnect_subsys in nvme/037]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: drop default subsysnqn argument from _nvme_{connect|disconnect}_subsys
Daniel Wagner [Tue, 26 Mar 2024 13:13:57 +0000 (14:13 +0100)]
nvme: drop default subsysnqn argument from _nvme_{connect|disconnect}_subsys

Remove the last positional argument for
_nvme_{connect|disconnect}_subsys which most test pass in the default
subsysnqn anyway. There is little point in cluttering all the test
textual noise.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: drop default trtype argument for _nvmet_passthru_target_connect
Daniel Wagner [Tue, 26 Mar 2024 13:13:56 +0000 (14:13 +0100)]
nvme: drop default trtype argument for _nvmet_passthru_target_connect

Every invocation of _nvmet_passthru_target_connect passes in the default
nvme_trtype argument. The argument is not evaluated anymore, thus just
remove it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme: drop default trtype argument for _nvmet_connect_subsys
Daniel Wagner [Tue, 26 Mar 2024 13:13:55 +0000 (14:13 +0100)]
nvme: drop default trtype argument for _nvmet_connect_subsys

Every invocation of _nvmet_connect_subsys passes in the default
nvme_trtype argument. nvme/rc also assumes the test is always using
nvme_trtype for trtype (e.g. cleanup code paths), thus just drop
this argument.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/031: do not open code target setup/cleanup
Daniel Wagner [Tue, 26 Mar 2024 13:13:54 +0000 (14:13 +0100)]
nvme/031: do not open code target setup/cleanup

No need to open code the target setup and cleanup step. Just use the
common helper to setup and cleanup the target.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: do not cleanup external managed loop device
Daniel Wagner [Tue, 26 Mar 2024 13:13:53 +0000 (14:13 +0100)]
nvme/rc: do not cleanup external managed loop device

If the test setups a loop device itself (not created by
_nvmet_target_setup), _nvmet_target_cleanup should not cleanup the block
device automatically.

Because _nvmet_target_cleanup has no way to figure this out by itself if
it is managed or not, the caller needs to pass in the block device type.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: remove unused connect options
Daniel Wagner [Tue, 26 Mar 2024 13:13:52 +0000 (14:13 +0100)]
nvme/rc: remove unused connect options

These options are not used, thus remove them.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: add nqn/uuid args to target setup/cleanup helper
Daniel Wagner [Tue, 26 Mar 2024 13:13:51 +0000 (14:13 +0100)]
nvme/rc: add nqn/uuid args to target setup/cleanup helper

Make these helper a bit more flexible, so that the caller
can setup not just the default subsysnqn.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: connect subsys only support long options
Daniel Wagner [Tue, 26 Mar 2024 13:13:50 +0000 (14:13 +0100)]
nvme/rc: connect subsys only support long options

There is no user for the short command line options, thus
remove the short options to reduce the parsing overhead.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/{014,015,018,019,020,023,024,026,045,046}: use long command line option for...
Daniel Wagner [Tue, 26 Mar 2024 13:13:49 +0000 (14:13 +0100)]
nvme/{014,015,018,019,020,023,024,026,045,046}: use long command line option for nvme

The long format of the command line option are more descriptive and more
likely to stay stable.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: use long command line option for nvme
Daniel Wagner [Tue, 26 Mar 2024 13:13:48 +0000 (14:13 +0100)]
nvme/rc: use long command line option for nvme

The long format of the command line option are more descriptive and more
likely to stay stable.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/{012,013,035}: check return value of _xfs_run_fio_verify_io
Daniel Wagner [Tue, 26 Mar 2024 13:13:47 +0000 (14:13 +0100)]
nvme/{012,013,035}: check return value of _xfs_run_fio_verify_io

When _xfs_run_fio_verify_io fails we should log the error. Currently, no
failure is detected when this function fails.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agocommon/xfs: propagate errors from _xfs_run_fio_verify_io
Daniel Wagner [Tue, 26 Mar 2024 13:13:46 +0000 (14:13 +0100)]
common/xfs: propagate errors from _xfs_run_fio_verify_io

If _xfs_mkfs_and_mount fails _xfs_run_fio_verify_io will continue to
execute and fio will run against the local file system instead against
the block device.

Propagate all errors back to the caller.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: log error if stale configuration is found
Daniel Wagner [Tue, 26 Mar 2024 13:13:45 +0000 (14:13 +0100)]
nvme/rc: log error if stale configuration is found

It's possible that a previous run of blktest left some stale
configuration left. E.g. when the module unload doesn't work (the bug
might in the kernel we are testing). In this case error out and avoid
confusion.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: silence fcloop cleanup failures
Daniel Wagner [Tue, 26 Mar 2024 13:13:44 +0000 (14:13 +0100)]
nvme/rc: silence fcloop cleanup failures

When the ctl file is missing we are logging

  tests/nvme/rc: line 265: /sys/class/fcloop/ctl/del_target_port: No such file or directory
  tests/nvme/rc: line 257: /sys/class/fcloop/ctl/del_local_port: No such file or directory
  tests/nvme/rc: line 249: /sys/class/fcloop/ctl/del_remote_port: No such file or directory

because the first redirect operator fails. Also it's not possible to
redirect the 'echo' error to /dev/null, because it's a builtin command
which escapes the stderr redirect operator (why?).

Anyway, the simplest way to catch this error is to first check if the
control file exists before attempting to write to it.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
17 months agonvme/rc: silence error on module unload for fc
Daniel Wagner [Tue, 26 Mar 2024 13:13:43 +0000 (14:13 +0100)]
nvme/rc: silence error on module unload for fc

The other transports silence the error output when trying to unload the
module. Do the same for FC.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
18 months agonvme/048: make queue count check retry-able
Daniel Wagner [Mon, 4 Mar 2024 13:48:26 +0000 (14:48 +0100)]
nvme/048: make queue count check retry-able

We are racing with the reset path of the controller. That means, when we
set a new queue count, we might not observe the resetting state in time.
Thus, first check if we see the correct queue count and then the
controller state.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: removed unnecessary if block in nvmf_check_queue_count()]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
18 months agonvme/048: remove unused argument for set_qid_max
Daniel Wagner [Mon, 4 Mar 2024 13:48:25 +0000 (14:48 +0100)]
nvme/048: remove unused argument for set_qid_max

The port is argument is unsed, thus remove it.

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>
18 months agonbd/001: wait for the device node to show up before running parted
Christoph Hellwig [Thu, 29 Feb 2024 14:34:27 +0000 (06:34 -0800)]
nbd/001: wait for the device node to show up before running parted

The parted call can happen before the device is settled and thus fail.
Currently this happens very rarely for me (about 1 in 500 runs), but
a pending change to freeze the queues for updating the limits will make
it much more likely to hit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
18 months agoMerge pull request #133 from yizhanglinux/dev-240219-nbd-001-fix
Shin'ichiro Kawasaki [Thu, 22 Feb 2024 08:31:13 +0000 (17:31 +0900)]
Merge pull request #133 from yizhanglinux/dev-240219-nbd-001-fix

nbd/001: change to use lsblk raw output format

18 months agonvme: Add passthru error logging tests to nvme/039
Alan Adamson [Wed, 21 Feb 2024 18:36:40 +0000 (10:36 -0800)]
nvme: Add passthru error logging tests to nvme/039

Tests the ability to enable and disable error logging for passthru admin
commands issued to the controller and passthru IO commands issued to a
namespace.

These tests will only be run on kernels that export the
passthru_err_log_enabled attribute.

Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
18 months agonvme/029: reserve hugepages for lager allocations
Daniel Wagner [Wed, 21 Feb 2024 07:43:53 +0000 (08:43 +0100)]
nvme/029: reserve hugepages for lager allocations

The test is issuing larger IO workload. This depends on being able to
allocate larger chunks of linear memory. nvme-cli used to use libhugetlb
to automatically allocate the HugeTLB pool. Though nvme-cli dropped the
dependency on the library, thus the test should try to provision the
system accordingly.

Link: https://github.com/linux-nvme/nvme-cli/issues/2218
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
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>
18 months agonbd/001: change to use lsblk raw output format
Yi Zhang [Tue, 20 Feb 2024 14:55:52 +0000 (22:55 +0800)]
nbd/001: change to use lsblk raw output format

lsblk -n ouput format changed due to the substantial changes
in libsmartcols, which lsblk relies on for generating output,
fix it by using the raw format

Fixes: #132
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
19 months agonvme/rc: revert nvme-cli context tracking
Daniel Wagner [Mon, 12 Feb 2024 10:40:46 +0000 (11:40 +0100)]
nvme/rc: revert nvme-cli context tracking

This feature is not needed anymore, after fixing nvmet-fc. The nvmet
target code is able to handle parallel operations and doesn't crash
anymore. Furthermore, it can't prevent from discovery controller created
by the udev rules, so let's rip it out.

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>
19 months agonvme/rc: do not issue errors when disconnecting when using fc transport
Daniel Wagner [Mon, 12 Feb 2024 10:40:45 +0000 (11:40 +0100)]
nvme/rc: do not issue errors when disconnecting when using fc transport

When running the tests with FC as transport and the udev auto connect
enabled, discovery controllers are created and destroyed while the tests
are running.

The cleanup code expects that all devices are under blktests control,
but this isn't the case. Thus filter out disconnect failures as well.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agonvme/rc: do not issue warnings on cleanup when using fc transport
Daniel Wagner [Mon, 12 Feb 2024 10:40:44 +0000 (11:40 +0100)]
nvme/rc: do not issue warnings on cleanup when using fc transport

When running the tests with FC as transport and the udev auto connect
enabled, discovery controllers are created and destroyed while the tests
are running.

The cleanup code expects that all devices are under blktests control,
but this isn't the case. So just disable the warning as it is reporting
a lot of false positives.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agonvme/rc: filter out errors from cat when reading files
Daniel Wagner [Mon, 12 Feb 2024 10:40:43 +0000 (11:40 +0100)]
nvme/rc: filter out errors from cat when reading files

When running the tests with FC as transport and the udev auto connect
enabled, discovery controllers are created and destroyed while the tests
are running. This races with the cleanup code and also the
_find_nvme_dev() which iterates over all device entries and tries to
read the connect of transport and subsysnqn sysfs attributes. Since
these steps are not locked in anyway, the resources can go away in
between.

Thus filter out 'cat' reporting non existing subsysnqn or transport
attributes. The tests will still fail if they can't find the device etc.
But without filtering these errors out the tests fail randomly.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agonvme/029: fix local variable declarations
Daniel Wagner [Mon, 12 Feb 2024 10:40:42 +0000 (11:40 +0100)]
nvme/029: fix local variable declarations

The syntax for local variables declarations uses whitespace as separator
and not commas:

tests/nvme/029: line 24: local: `bs,': not a valid identifier
tests/nvme/029: line 24: local: `size,': not a valid identifier
tests/nvme/029: line 24: local: `img,': not a valid identifier

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>
19 months agonvme/046: change nvme io-passthru command option from -o to --opcode
Shin'ichiro Kawasaki [Fri, 26 Jan 2024 06:10:37 +0000 (15:10 +0900)]
nvme/046: change nvme io-passthru command option from -o to --opcode

A recent commit in nvme-cli v2.6 changed the single letter of the
--opcode option from -o to -O. This caused the failure of nvme/046. To
make the test case work regardless of the nvme-cli version, replace -o
with --opcode.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agonvme: add nvme pci timeout testcase
Chaitanya Kulkarni [Wed, 31 Jan 2024 04:38:11 +0000 (20:38 -0800)]
nvme: add nvme pci timeout testcase

Trigger and test nvme-pci timeout with concurrent fio jobs.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agoblock/031: allow to run with built-in null_blk driver
Shin'ichiro Kawasaki [Thu, 11 Jan 2024 09:00:38 +0000 (18:00 +0900)]
block/031: allow to run with built-in null_blk driver

The test case block/031 sets the null_blk parameter shared_tag_bitmap=1
for testing. The parameter has been set as a module parameter, so the
null_blk driver must be loadable. However, null_blk allows you to set
shared_tag_bitmap as a configfs parameter since the kernel commit
7012eef520cb ("null_blk: add configfs variables for 2 options"). The
test case can now be run with the built-in null_blk driver by specifying
shared_tag_bitmap through configfs.

Modify the test case for that purpose. Refer to the null_blk feature
list and check if shared_tag_bitmap can be specified through configfs.
If so, specify the parameter as an option of _configure_null_blk and set
it through configfs. If not, check in requires() that shared_tag_bitmap
can be specified as a module parameter. Then call _init_null_blk() in
test() and specify shared_tag_bitmap=1 at null_blk module load.

Also, change the null_blk device name from nullb0 to nullb1 since the
default null_blk device name nullb0 is not usable with the built-in
null_blk driver.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agocommon/null_blk: introduce _have_null_blk_feature
Shin'ichiro Kawasaki [Thu, 11 Jan 2024 09:00:37 +0000 (18:00 +0900)]
common/null_blk: introduce _have_null_blk_feature

Introduce a helper function _have_null_blk_feature which checks
/sys/kernel/config/features. It allows test cases to adapt to null_blk
feature support status.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
19 months agoMerge pull request #131 from yizhanglinux/dev-blktests-fix-blktests-failure-with...
Shin'ichiro Kawasaki [Mon, 22 Jan 2024 05:38:32 +0000 (14:38 +0900)]
Merge pull request #131 from yizhanglinux/dev-blktests-fix-blktests-failure-with-latest-nvme-cli

nvme/rc: don't print the nvme connect msg

20 months agonvme/rc: don't print the nvme connect msg
Yi Zhang [Wed, 10 Jan 2024 06:17:21 +0000 (14:17 +0800)]
nvme/rc: don't print the nvme connect msg

With commit [1], the nvme connect command will show the connect msg
which breaks blktests nvme/ related cases[2], fix it from blktests
side.

[1]
https://github.com/linux-nvme/nvme-cli/commit/0b8d1e03049c5092d705bcd3ce369f02a9472f95
[2]
$ ./check nvme/003
nvme/003 (test if we're sending keep-alives to a discovery controller) [failed]
    runtime  11.344s  ...  11.346s
    --- tests/nvme/003.out 2024-01-10 04:03:21.975035862 +0100
    +++ /root/blktests/results/nodev/nvme/003.out.bad 2024-01-10 07:19:46.978193215 +0100
    @@ -1,3 +1,4 @@
     Running nvme/003
    +connecting to device: nvme0
     disconnected 1 controller(s)
     Test complete

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
20 months agoblock/007: skip hybrid polling tests when kernel does not support it
Shin'ichiro Kawasaki [Wed, 13 Dec 2023 08:46:19 +0000 (17:46 +0900)]
block/007: skip hybrid polling tests when kernel does not support it

Since the kernel commit 54bdd67d0f88 ("blk-mq: remove hybrid polling"),
kernel does not support hybrid polling. The test case block/007
specifies auto-hybrid and fixed-hybrid polling for testing. But it is
confusing and meaningless when kernel does not support it. Check if
kernel supports hybrid polling. If not, skip the hybrid polling tests.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agoblock/011: set default timeout to 20 minutes
Shin'ichiro Kawasaki [Tue, 31 Oct 2023 00:19:13 +0000 (09:19 +0900)]
block/011: set default timeout to 20 minutes

The test case runs fio while disabling and enabling PCI device of the
test target block device. Depending on the device type, it takes very
long time to re-enable the device. At worst case, it takes 4 hours to
complete the test case.

To avoid the meaningless long test runtime, set default timeout limit. I
ran the test case on various devices: real NVME SSD, QEMU NVME
emulation, HDDs with AHCI, HDDs with SAS-HBA. Many of them takes less
than 20 minutes to complete and pass the test case. Hence, choose 20
minutes as the timeout duration.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agoblock/011: recover test target devices to online or live status
Shin'ichiro Kawasaki [Mon, 30 Oct 2023 00:44:10 +0000 (09:44 +0900)]
block/011: recover test target devices to online or live status

The test case runs fio while disabling and enabling PCI device of the
test target block device. This often leaves the devices in offline or
dead status. For example, when the block device is a HDD connected to
HBA, kernel makes the device into offline mode with this message:

    sd x:x:x:x Device offlined - not ready after error recovery

This causes following test cases to fail. To avoid the failure, remove
and rescan the devices to get them back to online or live status. This
improvement is similar as the commit f8f33218eca7 ("block/011: recover
test target NVME device capacity"). While at this change, improve code
comments for the commit f8f33218eca7, and add missing local variable
declarations.

Of note is that the added rescan operation triggers a lockdep WARN if
the system has devices which depend on P2SB [1].

[1] https://lore.kernel.org/linux-pci/6xb24fjmptxxn5js2fjrrddjae6twex5bjaftwqsuawuqqqydx@7cl3uik5ef6j/

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agoloop/009: require --option of udevadm control command
Shin'ichiro Kawasaki [Wed, 29 Nov 2023 11:36:15 +0000 (20:36 +0900)]
loop/009: require --option of udevadm control command

The test case loop/009 calls udevadm control command with --ping option.
When systemd version is prior to 241, udevadm control command does not
support the option, and the test case fails. Check availability of the
option to avoid the failure.

Link: https://github.com/osandov/blktests/issues/129
Reported-by: Disha Goel <disgoel@linux.ibm.com>
Tested-by: Disha Goel <disgoel@linux.ibm.com>
Reviewed-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agonvme/{041,042,043,044,045}: check dhchap_ctrl_secret support by nvme-fabrics
Shin'ichiro Kawasaki [Mon, 20 Nov 2023 02:49:31 +0000 (11:49 +0900)]
nvme/{041,042,043,044,045}: check dhchap_ctrl_secret support by nvme-fabrics

The kernel commit d68006348288 ("nvme: rework NVME_AUTH Kconfig
selection") in v6.7-rc1 introduced a new kernel config option
NVME_HOST_AUTH. When the option is disabled, nvme test cases from 041 to
045 fail because nvme-fabrics module does not support the feature
dhchap_ctrl_secret.

To check the requirement, add _require_kernel_nvme_fabrics_feature()
which refers /dev/nvme-fabrics and checks if the specified feature
string is found or not. Call it to check dhchap_ctrl_secret support in
require() of the test cases.

This change relies on the kernel commit 1697d7d4c5ef ("nvme: blank out
authentication fabrics options if not configured").

Suggested-by: Daniel Wagner <dwagner@suse.de>
Suggested-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agonvme: do not print subsystem NQN to stdout
Hannes Reinecke [Fri, 17 Nov 2023 12:05:50 +0000 (21:05 +0900)]
nvme: do not print subsystem NQN to stdout

The subsystem NQN might be changed from the default value, but
that shouldn't cause the tests to fail. So don't register the
subsystem NQN in the 'out' files to avoid a false positive.

Signed-off-by: Hannes Reinecke <hare@suse.de>
[Shin'ichiro: remove only subsystem NQN from nvme disconnect message]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
21 months agonvme: do not print UUID to log files
Hannes Reinecke [Fri, 17 Nov 2023 12:05:49 +0000 (21:05 +0900)]
nvme: do not print UUID to log files

The UUID/wwid of a namespace might be assigned externally, so
we shouldn't register it in the 'out' files.
The current checks for UUID/wwid are just there to ensure that
if a UUID is present is should match the wwid setting.
So rather add a function _check_uuid() which does exactly that
and don't register the actual UUID in the 'out' files.

[Shin'ichiro: added check against def_subsys_uuid in _check_uuid()]

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
22 months agocommon/ublk: allow to run ublk test without building miniublk
Ming Lei [Mon, 13 Nov 2023 13:35:03 +0000 (21:35 +0800)]
common/ublk: allow to run ublk test without building miniublk

Now `rublk` is enough for supporting ublk test, not necessary to build
miniublk any more.

Convert ublk common helpers into ${UBLK_PROG}.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
[Shin'ichiro: fixed a shellcheck warning]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
22 months agoublk/rc: prefer to rublk over miniublk
Ming Lei [Sat, 11 Nov 2023 11:42:53 +0000 (19:42 +0800)]
ublk/rc: prefer to rublk over miniublk

Add one wrapper script for using rublk to run ublk tests, and prefer
to rublk because it is well implemented and more reliable.

This way has been run for months in rublk's github CI test.

https://github.com/ming1/rublk

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
22 months agoMerge pull request #128 from yizhanglinux/codespell-fix
Shin'ichiro Kawasaki [Mon, 13 Nov 2023 02:50:57 +0000 (11:50 +0900)]
Merge pull request #128 from yizhanglinux/codespell-fix

Codespell fix and remove unused srp/015.out

22 months agoFix common misspellings from codespell project
Yi Zhang [Fri, 10 Nov 2023 06:33:58 +0000 (14:33 +0800)]
Fix common misspellings from codespell project

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
22 months agotests/srp: remove the unused file 015.out
Yi Zhang [Fri, 10 Nov 2023 06:31:52 +0000 (14:31 +0800)]
tests/srp: remove the unused file 015.out

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
22 months agosrc/miniublk: fix logical block size setting
Akinobu Mita [Sat, 4 Nov 2023 12:17:42 +0000 (21:17 +0900)]
src/miniublk: fix logical block size setting

The miniublk always sets the logical block size to 512 bytes when setting
a regular file-backed loop target.
A test fails if the regular file is on a filesystem built on a block
device with a logical block size of 4KB.

$ cd blktests
$ modprobe -r scsi_debug
$ modprobe scsi_debug sector_size=4096 dev_size_mb=2048
$ mkfs.ext4 /dev/sdX
$ mount /dev/sdX results/
$ ./check ublk/003

The logical block size of the ublk block device is set to 512 bytes,
so a request that is not 4KB aligned may occur, and the miniublk will
attempt to process it with direct IO and fail.

The original ublk program already fixed this problem by determining
the logical block size to set based on the block device to which the
target regular file belongs.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agoblock/002: fix TMPDIR path
Shin'ichiro Kawasaki [Thu, 12 Oct 2023 02:11:52 +0000 (11:11 +0900)]
block/002: fix TMPDIR path

There has been a typo of TMPDIR variable. This resulted in blktrace
files created at unexpected place. Fix the typo.

Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agonvme/{rc,017,031}: replace def_file_path with _nvme_def_file_path()
Shin'ichiro Kawasaki [Thu, 12 Oct 2023 02:11:51 +0000 (11:11 +0900)]
nvme/{rc,017,031}: replace def_file_path with _nvme_def_file_path()

The commit b6356f6 ("nvme/rc: Add common file_path name define") defined
a global variable 'def_file_path' in nvme/rc, which refers TMPDIR.
However, when nvme/rc is sourced and def_file_path is defined for the
nvme test group, TMPDIR is not yet defined since TMPDIR is defined for
each test case. Then an unexpected path is set to def_file_path and
temporary files are created at the unexpected path.

Fix this by replacing the global variable def_file_path with a helper
function _nvme_def_file_path(). This helper function allows to refer
TMPDIR not at nvme/rc source timing but in test() or test_device()
context of each test case.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Fixes: b6356f6 ("nvme/rc: Add common file_path name define")
Reviewed-by: Daniel Wagner <dwagern@suse.de>
Reviewed-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agonvme/rc: fix rdma driver check
Shin'ichiro Kawasaki [Thu, 5 Oct 2023 08:02:42 +0000 (17:02 +0900)]
nvme/rc: fix rdma driver check

Since the commit 4824ac3f5c4a ("Skip tests based on SKIP_REASON, not
return value"), blktests no longer checks return values of _have_foo
helpers. Instead, it checks if _have_foo helpers set SKIP_REASON, which
was renamed to SKIP_REASONS later, to judge test case skip. If two
_have_foo helpers are chained with ||, the skip check does not work as
expected since one of the helper may set SKIP_REASONS even when the
other does not set. Such chain with || is done in _nvme_requires() to
check rdma drivers.

To fix the check, do not chain the helper functions with || operator.
Instead, refer $use_rxe to call only the required function.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agonbd/004: avoid left connection
Shin'ichiro Kawasaki [Fri, 29 Sep 2023 01:16:40 +0000 (10:16 +0900)]
nbd/004: avoid left connection

The test case nbd/004 disconnects /dev/nbd0 in most cases, but sometimes
leaves it in connected status. The test case stops the nbd server then
/dev/nbd0 does not work even when it is in connected status. This makes
"udevadm settle" command to wait for nbd udev events infinitely and
causes failures of following test cases.

There are two causes of the left connection. The first cause is left
nbd-client process. The test case waits for completion of its child
process connect_and_disconnect. However, it does not wait for completion
of nbd-client process that connect_and_disconnect spawns. After the test
case end, the left nbd-client process establishes the connection of
/dev/nbd0. The second cause is missing disconnect operation. The
connect_and_disconnect process repeats _netlink_connect and
_netlink_disconnect. When this process is killed after _netlink_connect
and before _netlink_disconnect, the connected status is left.

To avoid the left connection, wait for nbd-client process completion
and call _netlink_disconnect at the test case end.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agoChange the default RDMA driver from rdma_rxe to siw
Bart Van Assche [Tue, 22 Aug 2023 16:57:07 +0000 (09:57 -0700)]
Change the default RDMA driver from rdma_rxe to siw

Since the siw driver is more stable than the rdma_rxe driver, change the
default into siw. See e.g.
https://lore.kernel.org/all/c3d1a966-b9b0-d015-38ec-86270b5045fc@acm.org/.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agosrp/015: Remove this test
Bart Van Assche [Wed, 13 Sep 2023 14:53:59 +0000 (07:53 -0700)]
srp/015: Remove this test

Remove this test because except for the RDMA driver choice, it is a duplicate
of test srp/002.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agotests/srp/rc: Reduce the number of channels
Bart Van Assche [Wed, 23 Aug 2023 17:57:50 +0000 (10:57 -0700)]
tests/srp/rc: Reduce the number of channels

Login failures have been observed with the default number of channels
(ch_count) and dynamic debug enabled on a system with a large number of
CPU cores (72). Hence reduce the number of channels.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
23 months agotests/srp/rc: Rework use_blk_mq()
Bart Van Assche [Wed, 13 Sep 2023 15:11:51 +0000 (08:11 -0700)]
tests/srp/rc: Rework use_blk_mq()

Prepare for adding an additional kernel module parameter. This patch does
not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agotests/nvme/031: fix connecting faiure
Yi Zhang [Thu, 7 Sep 2023 03:44:23 +0000 (11:44 +0800)]
tests/nvme/031: fix connecting faiure

allow_any_host was disabled during _create_nvmet_subsystem, call
_create_nvmet_host before connecting to allow the host to connect.

[76096.420586] nvmet: adding nsid 1 to subsystem blktests-subsystem-0
[76096.440595] nvmet_tcp: enabling port 0 (127.0.0.1:4420)
[76096.491344] nvmet: connect by host nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349 for subsystem blktests-subsystem-0 not allowed
[76096.505049] nvme nvme2: Connect for subsystem blktests-subsystem-0 is not allowed, hostnqn: nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349
[76096.519609] nvme nvme2: failed to connect queue: 0 ret=16772

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
Fixes: c32b233b7dd6 ("nvme/rc: Add helper for adding/removing to allow list")
Link: https://lore.kernel.org/linux-block/20230907034423.3928010-1-yi.zhang@redhat.com/
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agoblock/002,scsi/007,zbd/003: remove options for shellcheck SC2119
Shin'ichiro Kawasaki [Thu, 31 Aug 2023 06:25:45 +0000 (15:25 +0900)]
block/002,scsi/007,zbd/003: remove options for shellcheck SC2119

The commits 852996fea4f1 and 45b203cce8ba added options of a few
function calls to avoid the shellcheck warning SC2119. After that,
SC2119 was disabled with the commit 3d1c0fe2677d. Then the added options
are no longer needed. Remove them to clean up.

Link: https://lore.kernel.org/linux-nvme/o5xnqvujzakhrudv7p64owiuzgozmean6blxow4vdxhdqozg5v@qznf2tzmey7k/
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2 years agonvme: introduce nvmet_target_{setup/cleanup} common code
Daniel Wagner [Wed, 30 Aug 2023 09:20:19 +0000 (11:20 +0200)]
nvme: introduce nvmet_target_{setup/cleanup} common code

Almost all fabric tests have the identically code for
setting up and cleaning up the target side. Introduce
two new helpers.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: added missing "--blkdev file" option in nvme/018]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
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>