Re: [PATCH blktests v3 2/2] nvme: test the nvme reservation feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/12/24 04:11, Guixin Liu wrote:
> Test the NVMe reservation feature, including register, acquire,
> release and report.
>
> Signed-off-by: Guixin Liu <kanie@xxxxxxxxxxxxxxxxx>
> ---
>   tests/nvme/054     |  99 +++++++++++++++++++++++++++++++++++++++++
>   tests/nvme/054.out | 108 +++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 207 insertions(+)
>   create mode 100644 tests/nvme/054
>   create mode 100644 tests/nvme/054.out
>
> diff --git a/tests/nvme/054 b/tests/nvme/054
> new file mode 100644
> index 0000000..f352c73
> --- /dev/null
> +++ b/tests/nvme/054
> @@ -0,0 +1,99 @@
> +#!/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 nvmedev=$1
> +	local report_arg=$2
> +
> +	nvme resv-report "/dev/${nvmedev}n1" "${report_arg}" | grep -v "hostid"
> +}
> +
> +test_resv() {
> +	local nvmedev=$1
> +	local report_arg="--cdw11=1"
> +
> +	if nvme resv-report --help 2>&1 | grep -- '--eds' > /dev/null; then
> +		report_arg="--eds"
> +	fi
> +
> +	echo "Register"
> +	resv_report "${nvmedev}" "${report_arg}"
> +	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Replace"
> +	nvme resv-register "/dev/${nvmedev}n1" --crkey=4 --nrkey=5 --rrega=2
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Unregister"
> +	nvme resv-register "/dev/${nvmedev}n1" --crkey=5 --rrega=1
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Acquire"
> +	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
> +	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Preempt"
> +	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --racqa=1
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Release"
> +	nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --rrela=0
> +	resv_report "${nvmedev}" "${report_arg}"
> +
> +	echo "Clear"
> +	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
> +	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0
> +	resv_report "${nvmedev}" "${report_arg}"
> +	nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rrela=1
> +}
> +
> +

make it easier to debug totally untested :-

test_resv() {
         local nvmedev=$1
         local report_arg="--cdw11=1"
         test_dev="/dev/${nvmedev}n1"

         if nvme resv-report --help 2>&1 | grep -- '--eds' > /dev/null; then
                 report_arg="--eds"
         fi

         echo "Register"
         resv_report "${nvmedev}" "${report_arg}"
         nvme resv-register "${test_dev}" --nrkey=4 --rrega=0
         resv_report "${nvmedev}" "${report_arg}"

         echo "Replace"
         nvme resv-register "${test_dev}" --crkey=4 --nrkey=5 --rrega=2
         resv_report "${nvmedev}" "${report_arg}"

         echo "Unregister"
         nvme resv-register "${test_dev}" --crkey=5 --rrega=1
         resv_report "${nvmedev}" "${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 "${nvmedev}" "${report_arg}"

         echo "Preempt"
         nvme resv-acquire "${test_dev}" --crkey=4 --rtype=2 --racqa=1
         resv_report "${nvmedev}" "${report_arg}"

         echo "Release"
         nvme resv-release "${test_dev}" --crkey=4 --rtype=2 --rrela=0
         resv_report "${nvmedev}" "${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 "${nvmedev}" "${report_arg}"
         nvme resv-release "${test_dev}" --crkey=4 --rrela=1
}


irrespective of that looks good :-

Reviewed-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>

-ck






[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux