Re: [PATCH v3 blktests 1/2] tests/nvme: add helper routines to use error injector

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

 



On May 13, 2022 / 08:52, Alan Adamson wrote:
> nvme tests can use these helper routines to setup and use
> the nvme error injector.
> 
> Signed-off-by: Alan Adamson <alan.adamson@xxxxxxxxxx>
> ---
>  tests/nvme/rc | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 3c38408a0bfe..c49a3c5d78da 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -375,3 +375,47 @@ _discovery_genctr() {
>  	_nvme_discover "${nvme_trtype}" |
>  		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
>  }
> +
> +declare -A NS_DEV_FAULT_INJECT_SAVE
> +declare -A CTRL_DEV_FAULT_INJECT_SAVE
> +
> +_nvme_err_inject_setup()
> +{
> +        local a
> +
> +        for a in /sys/kernel/debug/"$1"/fault_inject/*; do
> +                NS_DEV_FAULT_INJECT_SAVE[${a}]=$(<"${a}")
> +        done
> +
> +        for a in /sys/kernel/debug/"$2"/fault_inject/*; do
> +                CTRL_DEV_FAULT_INJECT_SAVE[${a}]=$(<"${a}")
> +        done
> +}
> +
> +_nvme_err_inject_cleanup()
> +{
> +        local a
> +
> +        for a in /sys/kernel/debug/"${ns_dev}"/fault_inject/*; do
> +                echo "${NS_DEV_FAULT_INJECT_SAVE[${a}]}" > "${a}"
> +		echo ${a} $(<"${a}") >> /tmp/iii
> +        done
> +        for a in /sys/kernel/debug/"${ctrl_dev}"/fault_inject/*; do
> +                echo "${CTRL_DEV_FAULT_INJECT_SAVE[${a}]}" > "${a}"
> +        done
> +}

Thanks for separating out the helper functions.

${ns_dev} and ${ctrl_dev} should be ${1} and ${2}, and a debug code is left.
'make check' finds out them. Also, I wish to have an empty line between two for
blocks in same manner as _nvme_err_inject_setup().

> +
> +_nvme_enable_err_inject()
> +{
> +        echo "$2" > /sys/kernel/debug/"$1"/fault_inject/verbose
> +        echo "$3" > /sys/kernel/debug/"$1"/fault_inject/probability
> +        echo "$4" > /sys/kernel/debug/"$1"/fault_inject/dont_retry
> +        echo "$5" > /sys/kernel/debug/"$1"/fault_inject/status
> +        echo "$6" > /sys/kernel/debug/"$1"/fault_inject/times
> +}
> +
> +_nvme_clear_err_inject()

To be paired with _nvme_enable_err_inject(), _nvme_disable_err_inject() would be
the better name?

> +{
> +        echo 0 > /sys/kernel/debug/"$1"/fault_inject/probability
> +        echo 0 > /sys/kernel/debug/"$1"/fault_inject/times
> +}
> -- 
> 2.27.0
> 

-- 
Best Regards,
Shin'ichiro Kawasaki



[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