Skip to contentSkip to conversation

commands/mkswap01.sh: Revert the original retry loops

PATCH New Xiao Yang 3 participants 6 messages Jun 21, 2018 – Jun 28, 2018

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 commands/mkswap01.sh: Revert the original retry loops

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files and gets TBROK. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enable loop devices for swapping sucessfully.

---
 testcases/commands/mkswap/mkswap01.sh | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
testcases/commands/mkswap/mkswap01.sh +15 -4
index 5ead4cd..1c01c86 100755
@@ -37,14 +37,25 @@ setup()
 	DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))
 }
 
-check_for_file()
+wait_for_file()
 {
 	local path="$1"
+	local retries=10
 
-	if [ -z "$path" -o -e "$path" ]; then
+	if [ -z "$path" ]; then
 		return
 	fi
-	return 1
+
+	while [ $retries -gt 0 ]; do
+		if [ -e "$path" ]; then
+			return
+		fi
+		tst_res TINFO "Waiting for $path to appear"
+		retries=$((retries - 1))
+		tst_sleep 10ms
+	done
+
+	tst_res TINFO "The file $path haven't appeared"
 }
 
 mkswap_verify()
@@ -64,7 +75,7 @@ mkswap_verify()
 		local pagesize=$PAGE_SIZE
 	fi
 
-	TST_RETRY_FUNC "check_for_file $dev_file" 0
+	wait_for_file "$dev_file"
 
 	swapon $swapfile 2>/dev/null
 
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 commands/mkswap01.sh: Revert the original retry loops

Hi Xiao,

Quoted 5 lines · Xiao Yang

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files and gets TBROK. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enable loop devices for swapping sucessfully.

Thanks for reporting this.

Quoted 40 lines
---
 testcases/commands/mkswap/mkswap01.sh | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
testcases/commands/mkswap/mkswap01.sh +14 -3
index 5ead4cd..1c01c86 100755
@@ -37,14 +37,25 @@ setup()
        DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))
 }
 
-check_for_file()
+wait_for_file()
 {
        local path="$1"
+       local retries=10
 
-       if [ -z "$path" -o -e "$path" ]; then
+       if [ -z "$path" ]; then
                return
        fi
-       return 1
+
+       while [ $retries -gt 0 ]; do
+               if [ -e "$path" ]; then
+                       return
+               fi
+               tst_res TINFO "Waiting for $path to appear"
+               retries=$((retries - 1))
+               tst_sleep 10ms
+       done
+
+       tst_res TINFO "The file $path haven't appeared"
 }
 
 mkswap_verify()

testcases/commands/mkswap/mkswap01.sh mkswap_verify() · line 80

Quoted 7 lines
testcases/commands/mkswap/mkswap01.sh +1 -1
@@ -64,7 +75,7 @@ mkswap_verify()
                local pagesize=$PAGE_SIZE
        fi
 
-       TST_RETRY_FUNC "check_for_file $dev_file" 0
+       wait_for_file "$dev_file"
 
        swapon $swapfile 2>/dev/null

To revert this patch is also not wise for old kernels (without commit c3473c63542), because the kernel has to finish this looping to wait for a disk label that will never appear.

So, what about just wait 100ms for old kernels directly?

testcases/commands/mkswap/mkswap01.sh +5 -1
@@ -64,7 +64,11 @@ mkswap_verify()
                local pagesize=$PAGE_SIZE
        fi
 
-       TST_RETRY_FUNC "check_for_file $dev_file" 0
+       if tst_kvcmp -lt '2.6.35'; then
+               tst_resm TINFO "Waiting for $dev_file to appear"
+               tst_sleep 100ms
+       else
+               TST_RETRY_FUNC "check_for_file $dev_file" 0
 
        swapon $swapfile 2>/dev/null
 
Signature · 2 lines
Regards,
Li Wang
author
#2 lore raw

PATCH 1/1 commands/mkswap01.sh: Revert the original retry loops

Quoted 55 lines · Li Wang

Hi Xiao,

Quoted 5 lines · Xiao Yang

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files and gets TBROK. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enable loop devices for swapping sucessfully.

Thanks for reporting this.

Quoted 45 lines
---
  testcases/commands/mkswap/mkswap01.sh | 19 +++++++++++++++----
  1 file changed, 15 insertions(+), 4 deletions(-)
testcases/commands/mkswap/mkswap01.sh +15 -4
index 5ead4cd..1c01c86 100755
@@ -37,14 +37,25 @@ setup()
         DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))
  }
 
-check_for_file()
+wait_for_file()
  {
         local path="$1"
+       local retries=10
 
-       if [ -z "$path" -o -e "$path" ]; then
+       if [ -z "$path" ]; then
                 return
         fi
-       return 1
+
+       while [ $retries -gt 0 ]; do
+               if [ -e "$path" ]; then
+                       return
+               fi
+               tst_res TINFO "Waiting for $path to appear"
+               retries=$((retries - 1))
+               tst_sleep 10ms
+       done
+
+       tst_res TINFO "The file $path haven't appeared"
  }
 
  mkswap_verify()
@@ -64,7 +75,7 @@ mkswap_verify()
                 local pagesize=$PAGE_SIZE
         fi
 
-       TST_RETRY_FUNC "check_for_file $dev_file" 0
+       wait_for_file "$dev_file"
 
Quoted 6 lines

testcases/commands/mkswap/mkswap01.sh mkswap_verify() · line 73

Quoted 1 line
testcases/commands/mkswap/mkswap01.sh +0 -0
         swapon $swapfile 2>/dev/null

To revert this patch is also not wise for old kernels (without commit c3473c63542), because the kernel has to finish this looping to wait for a disk label that will never appear.

So, what about just wait 100ms for old kernels directly?

Hi Li,

OK, it is reasonabel to me, and i will send v2 patch.

Thanks,
Xiao Yang

Quoted 16 lines
testcases/commands/mkswap/mkswap01.sh +5 -1
@@ -64,7 +64,11 @@ mkswap_verify()
                 local pagesize=$PAGE_SIZE
         fi
 
-       TST_RETRY_FUNC "check_for_file $dev_file" 0
+       if tst_kvcmp -lt '2.6.35'; then
+               tst_resm TINFO "Waiting for $dev_file to appear"
+               tst_sleep 100ms
+       else
+               TST_RETRY_FUNC "check_for_file $dev_file" 0
 
         swapon $swapfile 2>/dev/null
 
author
#3 lore raw

PATCH v2 1/1 commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*" files on old kernels

In reply to Li Wang

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enables loop devices for swapping sucessfully.

---
 testcases/commands/mkswap/mkswap01.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/commands/mkswap/mkswap01.sh +6 -1
index 5ead4cd..4185702 100755
@@ -64,7 +64,12 @@ mkswap_verify()
 		local pagesize=$PAGE_SIZE
 	fi
 
-	TST_RETRY_FUNC "check_for_file $dev_file" 0
+	if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
+		tst_res TINFO "Waiting for $dev_file to appear"
+		tst_sleep 100ms
+	else
+		TST_RETRY_FUNC "check_for_file $dev_file" 0
+	fi
 
 	swapon $swapfile 2>/dev/null
 
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 1/1 commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*" files on old kernels

Quoted 8 lines · Xiao Yang

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enables loop devices for swapping sucessfully.

Quoted 27 lines
---
 testcases/commands/mkswap/mkswap01.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/commands/mkswap/mkswap01.sh +6 -2
index 5ead4cd..4185702 100755
@@ -64,7 +64,12 @@ mkswap_verify()
                local pagesize=$PAGE_SIZE
        fi
 
-       TST_RETRY_FUNC "check_for_file $dev_file" 0
+       if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
+               tst_res TINFO "Waiting for $dev_file to appear"
+               tst_sleep 100ms
+       else
+               TST_RETRY_FUNC "check_for_file $dev_file" 0
+       fi
 
        swapon $swapfile 2>/dev/null
 
--

1.8.3.1

Signature · 2 lines
Regards,
Li Wang
#5 lore raw

PATCH v2 1/1 commands/mkswap01.sh: Fix unexisted "/dev/disk/by-*" files on old kernels

In reply to Xiao Yang

Hi Li, Xiao,

Quoted 19 lines

Before kernel commit c3473c6(e.g. RHEL6), mkswap -L or mkswap -U for loop devices can not generate corresponding "/dev/disk/by-*" files. It is just a way to check the success of mkswap rather than a bug, so the test should not get TBROK when "/dev/disk/by-*" files are not generated but swapon enables loop devices for swapping sucessfully.

---
 testcases/commands/mkswap/mkswap01.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/commands/mkswap/mkswap01.sh +0 -0
index 5ead4cd..4185702 100755
@@ -64,7 +64,12 @@ mkswap_verify()
 		local pagesize=$PAGE_SIZE
 	fi

testcases/commands/mkswap/mkswap01.sh mkswap_verify() · line 74

Quoted 10 lines
testcases/commands/mkswap/mkswap01.sh +6 -1
 
-	TST_RETRY_FUNC "check_for_file $dev_file" 0
+	if tst_kvcmp -lt "2.6.35" && [ -n "$dev_file" ]; then
+		tst_res TINFO "Waiting for $dev_file to appear"
+		tst_sleep 100ms
+	else
+		TST_RETRY_FUNC "check_for_file $dev_file" 0
+	fi
 
 	swapon $swapfile 2>/dev/null

pushed, thanks!

Kind regards,
Petr