-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nvme: test the nvme reservation feature
Test the NVMe reservation feature, including register, acquire, release and report. Signed-off-by: Guixin Liu <kanie@linux.alibaba.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> [Shin'ichiro: set executable flag to nvme/054, added 'local' to test_dev] Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
- Loading branch information
1 parent
e3fe06e
commit 5a1fb7a
Showing
2 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0+ | ||
# Copyright (C) 2024 Guixin Liu | ||
# Copyright (C) 2024 Alibaba Group. | ||
# | ||
# Test the NVMe reservation feature | ||
# | ||
. tests/nvme/rc | ||
|
||
DESCRIPTION="Test the NVMe reservation feature" | ||
QUICK=1 | ||
nvme_trtype="loop" | ||
|
||
requires() { | ||
_nvme_requires | ||
} | ||
|
||
resv_report() { | ||
local test_dev=$1 | ||
local report_arg=$2 | ||
|
||
nvme resv-report "${test_dev}" "${report_arg}" | grep -v "hostid" | \ | ||
grep -E "gen|rtype|regctl|regctlext|cntlid|rcsts|rkey" | ||
} | ||
|
||
test_resv() { | ||
local ns=$1 | ||
local report_arg="--cdw11=1" | ||
local test_dev="/dev/${ns}" | ||
|
||
if nvme resv-report --help 2>&1 | grep -- '--eds' > /dev/null; then | ||
report_arg="--eds" | ||
fi | ||
|
||
echo "Register" | ||
resv_report "${test_dev}" "${report_arg}" | ||
nvme resv-register "${test_dev}" --nrkey=4 --rrega=0 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Replace" | ||
nvme resv-register "${test_dev}" --crkey=4 --nrkey=5 --rrega=2 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Unregister" | ||
nvme resv-register "${test_dev}" --crkey=5 --rrega=1 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Acquire" | ||
nvme resv-register "${test_dev}" --nrkey=4 --rrega=0 | ||
nvme resv-acquire "${test_dev}" --crkey=4 --rtype=1 --racqa=0 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Preempt" | ||
nvme resv-acquire "${test_dev}" --crkey=4 --rtype=2 --racqa=1 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Release" | ||
nvme resv-release "${test_dev}" --crkey=4 --rtype=2 --rrela=0 | ||
resv_report "${test_dev}" "${report_arg}" | ||
|
||
echo "Clear" | ||
nvme resv-register "${test_dev}" --nrkey=4 --rrega=0 | ||
nvme resv-acquire "${test_dev}" --crkey=4 --rtype=1 --racqa=0 | ||
resv_report "${test_dev}" "${report_arg}" | ||
nvme resv-release "${test_dev}" --crkey=4 --rrela=1 | ||
} | ||
|
||
test() { | ||
echo "Running ${TEST_NAME}" | ||
|
||
_setup_nvmet | ||
|
||
local ns | ||
local skipped=false | ||
local subsys_path="" | ||
local ns_path="" | ||
|
||
_nvmet_target_setup --blkdev file --resv_enable | ||
subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" | ||
_nvme_connect_subsys | ||
|
||
ns=$(_find_nvme_ns "${def_subsys_uuid}") | ||
ns_id=$(echo "${ns}" | grep -oE '[0-9]+' | sed -n '2p') | ||
ns_path="${subsys_path}/namespaces/${ns_id}" | ||
|
||
if [[ -f "${ns_path}/resv_enable" ]] ; then | ||
test_resv "${ns}" | ||
else | ||
SKIP_REASONS+=("missing reservation feature") | ||
skipped=true | ||
fi | ||
|
||
_nvme_disconnect_subsys | ||
_nvmet_target_cleanup | ||
|
||
if [[ "${skipped}" = true ]] ; then | ||
return 1 | ||
fi | ||
|
||
echo "Test complete" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Running nvme/054 | ||
Register | ||
gen : 0 | ||
rtype : 0 | ||
regctl : 0 | ||
NVME Reservation success | ||
gen : 1 | ||
rtype : 0 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 0 | ||
rkey : 4 | ||
Replace | ||
NVME Reservation success | ||
gen : 2 | ||
rtype : 0 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 0 | ||
rkey : 5 | ||
Unregister | ||
NVME Reservation success | ||
gen : 3 | ||
rtype : 0 | ||
regctl : 0 | ||
Acquire | ||
NVME Reservation success | ||
NVME Reservation Acquire success | ||
gen : 4 | ||
rtype : 1 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 1 | ||
rkey : 4 | ||
Preempt | ||
NVME Reservation Acquire success | ||
gen : 5 | ||
rtype : 2 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 1 | ||
rkey : 4 | ||
Release | ||
NVME Reservation Release success | ||
gen : 5 | ||
rtype : 0 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 0 | ||
rkey : 4 | ||
Clear | ||
NVME Reservation success | ||
NVME Reservation Acquire success | ||
gen : 6 | ||
rtype : 1 | ||
regctl : 1 | ||
regctlext[0] : | ||
cntlid : ffff | ||
rcsts : 1 | ||
rkey : 4 | ||
NVME Reservation Release success | ||
disconnected 1 controller(s) | ||
Test complete |