[PATCH blktests v4 2/2] nvme: test the nvme reservation feature
Daniel Wagner
dwagner at suse.de
Mon Oct 14 04:44:21 PDT 2024
On Mon, Oct 14, 2024 at 05:01:16PM GMT, Guixin Liu wrote:
> +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"
okay, let's see how this goes.
> +test_resv() {
> + local nvmedev=$1
> + local report_arg="--cdw11=1"
> + test_dev="/dev/${nvmedev}n1"
Please use the namespace lookup helper and don't hardcode the namespace
id.
> +
> + 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 nvmedev
> + local skipped=false
> + local subsys_path=""
> + local ns_path=""
> +
> + _nvmet_target_setup --blkdev file --resv_enable
> + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}"
> + ns_path="${subsys_path}/namespaces/1"
Again here, it's better not to hardcode the nsid.
More information about the Linux-nvme
mailing list