diff mbox series

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

Message ID 20240206131655.32050-3-dwagner@suse.de (mailing list archive)
State New, archived
Headers show
Series fc transport cleanups | expand

Commit Message

Daniel Wagner Feb. 6, 2024, 1:16 p.m. UTC
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@suse.de>
---
 tests/nvme/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Chaitanya Kulkarni Feb. 6, 2024, 11:07 p.m. UTC | #1
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@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
Daniel Wagner Feb. 7, 2024, 8:19 a.m. UTC | #2
On Tue, Feb 06, 2024 at 11:07:06PM +0000, Chaitanya Kulkarni wrote:
> >   	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 ?

In this case transport will be '' and not match with '${nvme_trtype}'.
So we already handle this properly.

> >   		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)"
Shinichiro Kawasaki Feb. 7, 2024, 9:57 a.m. UTC | #3
On Feb 06, 2024 / 14:16, 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

Nit: maybe you meant "destroyed" or "destroy" instead of "destroys".

> 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.

Nit: s/fine/find/

> But without filtering these errors out the tests fail randomly.
> 
> Signed-off-by: Daniel Wagner <dwagner@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)"
>  		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)"
>  		if [[ "$subsysnqn" == "$subsys" ]]; then
>  			echo "$dev"
>  		fi
> -- 
> 2.43.0
>
diff mbox series

Patch

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)"
 		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)"
 		if [[ "$subsysnqn" == "$subsys" ]]; then
 			echo "$dev"
 		fi