[PATCH blktests v1 2/5] nvme/rc: filter out errors from cat when reading files

Chaitanya Kulkarni chaitanyak at nvidia.com
Tue Feb 6 15:07:06 PST 2024


On 2/6/2024 5:16 AM, Daniel Wagner wrote:
> When running the tests with FC as transport and the udev auto connect
> enabled, discovery controllers are created and destroys 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 fine the device etc.
> But without filtering these errors out the tests fail randomly.
> 
> Signed-off-by: Daniel Wagner <dwagner at suse.de>
> ---
>   tests/nvme/rc | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index e0461f1cd53a..9cc83afe0668 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -350,7 +350,7 @@ _cleanup_nvmet() {
>   
>   	for dev in /sys/class/nvme/nvme*; do
>   		dev="$(basename "$dev")"
> -		transport="$(cat "/sys/class/nvme/${dev}/transport")"
> +		transport="$(cat "/sys/class/nvme/${dev}/transport" 2>/dev/null)"

do we have to do anything if there is in error ?

>   		if [[ "$transport" == "${nvme_trtype}" ]]; then
>   			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
>   			_nvme_disconnect_ctrl "${dev}"
> @@ -840,7 +840,7 @@ _find_nvme_dev() {
>   	for dev in /sys/class/nvme/nvme*; do
>   		[ -e "$dev" ] || continue
>   		dev="$(basename "$dev")"
> -		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn")"
> +		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn" 2>/dev/null)"

same here ..

>   		if [[ "$subsysnqn" == "$subsys" ]]; then
>   			echo "$dev"
>   		fi

-ck




More information about the Linux-nvme mailing list