diff mbox series

[blktests,v1,02/18] nvme/rc: silence fcloop cleanup failures

Message ID 20240321094727.6503-3-dwagner@suse.de (mailing list archive)
State New, archived
Headers show
Series refactoring and various cleanups/fixes | expand

Commit Message

Daniel Wagner March 21, 2024, 9:47 a.m. UTC
When the ctl file is missing we are logging

  tests/nvme/rc: line 265: /sys/class/fcloop/ctl/del_target_port: No such file or directory
  tests/nvme/rc: line 257: /sys/class/fcloop/ctl/del_local_port: No such file or directory
  tests/nvme/rc: line 249: /sys/class/fcloop/ctl/del_remote_port: No such file or directory

because the first redirect operator fails. Thus first check if the ctl
file exists.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 tests/nvme/rc | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Daniel Wagner March 21, 2024, 9:57 a.m. UTC | #1
On Thu, Mar 21, 2024 at 10:47:11AM +0100, Daniel Wagner wrote:
> When the ctl file is missing we are logging
> 
>   tests/nvme/rc: line 265: /sys/class/fcloop/ctl/del_target_port: No such file or directory
>   tests/nvme/rc: line 257: /sys/class/fcloop/ctl/del_local_port: No such file or directory
>   tests/nvme/rc: line 249: /sys/class/fcloop/ctl/del_remote_port: No such file or directory
> 
> because the first redirect operator fails. Thus first check if the ctl
> file exists.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  tests/nvme/rc | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 78d84af72e73..53fa54e64cb2 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -234,7 +234,10 @@ _nvme_fcloop_del_rport() {
>  	local remote_wwpn="$4"
>  	local loopctl=/sys/class/fcloop/ctl
>  
> -	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > ${loopctl}/del_remote_port 2> /dev/null
> +	if [[ ! -f "${loopctrl}" ]]; then

This should be ${loopctl}, obviously. Same for the other changes.
Shin'ichiro Kawasaki March 22, 2024, 9:14 a.m. UTC | #2
On Mar 21, 2024 / 10:57, Daniel Wagner wrote:
> On Thu, Mar 21, 2024 at 10:47:11AM +0100, Daniel Wagner wrote:
> > When the ctl file is missing we are logging
> > 
> >   tests/nvme/rc: line 265: /sys/class/fcloop/ctl/del_target_port: No such file or directory
> >   tests/nvme/rc: line 257: /sys/class/fcloop/ctl/del_local_port: No such file or directory
> >   tests/nvme/rc: line 249: /sys/class/fcloop/ctl/del_remote_port: No such file or directory
> > 
> > because the first redirect operator fails. Thus first check if the ctl
> > file exists.
> > 
> > Signed-off-by: Daniel Wagner <dwagner@suse.de>
> > ---
> >  tests/nvme/rc | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tests/nvme/rc b/tests/nvme/rc
> > index 78d84af72e73..53fa54e64cb2 100644
> > --- a/tests/nvme/rc
> > +++ b/tests/nvme/rc
> > @@ -234,7 +234,10 @@ _nvme_fcloop_del_rport() {
> >  	local remote_wwpn="$4"
> >  	local loopctl=/sys/class/fcloop/ctl
> >  
> > -	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > ${loopctl}/del_remote_port 2> /dev/null
> > +	if [[ ! -f "${loopctrl}" ]]; then
> 
> This should be ${loopctl}, obviously. Same for the other changes.

I see. BTW, I think the "-f" above should be "-d", since I think ${loopctl} is
a directory.
diff mbox series

Patch

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 78d84af72e73..53fa54e64cb2 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -234,7 +234,10 @@  _nvme_fcloop_del_rport() {
 	local remote_wwpn="$4"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > ${loopctl}/del_remote_port 2> /dev/null
+	if [[ ! -f "${loopctrl}" ]]; then
+		return
+	fi
+	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > ${loopctl}/del_remote_port > /dev/null 2>&1
 }
 
 _nvme_fcloop_del_lport() {
@@ -242,7 +245,10 @@  _nvme_fcloop_del_lport() {
 	local wwpn="$2"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_local_port 2> /dev/null
+	if [[ ! -f "${loopctrl}" ]]; then
+		return
+	fi
+	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_local_port > /dev/null > /dev/null 2>&1
 }
 
 _nvme_fcloop_del_tport() {
@@ -250,7 +256,10 @@  _nvme_fcloop_del_tport() {
 	local wwpn="$2"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_target_port 2> /dev/null
+	if [[ ! -f "${loopctrl}" ]]; then
+		return
+	fi
+	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_target_port > /dev/null 2&>1
 }
 
 _cleanup_fcloop() {