All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4]
@ 2024-03-27 17:11 fdmanana
  2024-03-27 17:11 ` [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance fdmanana
                   ` (9 more replies)
  0 siblings, 10 replies; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing any of the tests cases btrfs/06[0-9] and btrfs/07[0-4] often leaves
some background processes running around that prevent unmounting the
scratch filesystems or running fstests again. When that happens it requires
manually finding which processes are still using the scratch filesystem
and then kill them. These patches address that issue. Details in the change
logs.

Filipe Manana (10):
  btrfs: add helper to kill background process running _btrfs_stress_balance
  btrfs/028: use the helper _btrfs_kill_stress_balance_pid
  btrfs/028: removed redundant sync and scratch filesystem unmount
  btrfs: add helper to kill background process running _btrfs_stress_scrub
  btrfs: add helper to kill background process running _btrfs_stress_defrag
  btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  btrfs: add helper to kill background process running _btrfs_stress_replace
  btrfs: add helper to stop background process running _btrfs_stress_subvolume
  btrfs: remove stop file early at _btrfs_stress_subvolume
  btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted

 common/btrfs    | 84 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/028 | 16 +++-------
 tests/btrfs/060 | 33 +++++++++++++------
 tests/btrfs/061 | 30 ++++++++++++------
 tests/btrfs/062 | 30 ++++++++++++------
 tests/btrfs/063 | 30 ++++++++++++------
 tests/btrfs/064 | 30 ++++++++++++------
 tests/btrfs/065 | 33 +++++++++++++------
 tests/btrfs/066 | 33 +++++++++++++------
 tests/btrfs/067 | 33 +++++++++++++------
 tests/btrfs/068 | 33 +++++++++++++------
 tests/btrfs/069 | 31 ++++++++++++------
 tests/btrfs/070 | 31 ++++++++++++------
 tests/btrfs/071 | 31 ++++++++++++------
 tests/btrfs/072 | 31 ++++++++++++------
 tests/btrfs/073 | 30 ++++++++++++------
 tests/btrfs/074 | 30 ++++++++++++------
 tests/btrfs/255 |  8 ++---
 18 files changed, 417 insertions(+), 160 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  8:16   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid fdmanana
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing a background process running _btrfs_stress_balance() is not as
simple as sending a signal to the process and waiting for it to die.
Therefore we have the following logic to terminate such process:

   kill $pid
   wait $pid
   # Wait for the balance operation to finish.
   while ps aux | grep "balance start" | grep -qv grep; do
       sleep 1
   done

Since this is repeated in several test cases, move this logic to a common
helper and use it in all affected test cases. This will help to avoid
repeating the same code again several times in upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 14 ++++++++++++++
 tests/btrfs/060 |  8 ++------
 tests/btrfs/061 | 10 ++++------
 tests/btrfs/062 | 10 ++++------
 tests/btrfs/063 | 10 ++++------
 tests/btrfs/064 | 10 ++++------
 tests/btrfs/255 |  8 ++------
 7 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index aa344706..e95cff7f 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -308,6 +308,20 @@ _btrfs_stress_balance()
 	done
 }
 
+# Kill a background process running _btrfs_stress_balance()
+_btrfs_kill_stress_balance_pid()
+{
+	local balance_pid=$1
+
+	# Ignore if process already died.
+	kill $balance_pid &> /dev/null
+	wait $balance_pid &> /dev/null
+	# Wait for the balance operation to finish.
+	while ps aux | grep "balance start" | grep -qv grep; do
+		sleep 1
+	done
+}
+
 # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
 _btrfs_stress_subvolume()
 {
diff --git a/tests/btrfs/060 b/tests/btrfs/060
index a0184891..58167cc6 100755
--- a/tests/btrfs/060
+++ b/tests/btrfs/060
@@ -57,12 +57,8 @@ run_test()
 	wait $fsstress_pid
 
 	touch $stop_file
-	kill $balance_pid
-	wait
-	# wait for the balance operation to finish
-	while ps aux | grep "balance start" | grep -qv grep; do
-		sleep 1
-	done
+	wait $subvol_pid
+	_btrfs_kill_stress_balance_pid $balance_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/061 b/tests/btrfs/061
index c1010413..d0b55e48 100755
--- a/tests/btrfs/061
+++ b/tests/btrfs/061
@@ -51,12 +51,10 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $balance_pid $scrub_pid
-	wait
-	# wait for the balance and scrub operations to finish
-	while ps aux | grep "balance start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_balance_pid $balance_pid
+	kill $scrub_pid
+	wait $scrub_pid
+	# wait for the crub operation to finish
 	while ps aux | grep "scrub start" | grep -qv grep; do
 		sleep 1
 	done
diff --git a/tests/btrfs/062 b/tests/btrfs/062
index 818a0156..a2639d6c 100755
--- a/tests/btrfs/062
+++ b/tests/btrfs/062
@@ -52,12 +52,10 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $balance_pid $defrag_pid
-	wait
-	# wait for the balance and defrag operations to finish
-	while ps aux | grep "balance start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_balance_pid $balance_pid
+	kill $defrag_pid
+	wait $defrag_pid
+	# wait for the defrag operation to finish
 	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
 		sleep 1
 	done
diff --git a/tests/btrfs/063 b/tests/btrfs/063
index 2f771baf..baf0c356 100755
--- a/tests/btrfs/063
+++ b/tests/btrfs/063
@@ -51,12 +51,10 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $balance_pid $remount_pid
-	wait
-	# wait for the balance and remount loop to finish
-	while ps aux | grep "balance start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_balance_pid $balance_pid
+	kill $remount_pid
+	wait $remount_pid
+	# wait for the remount loop to finish
 	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
 		sleep 1
 	done
diff --git a/tests/btrfs/064 b/tests/btrfs/064
index e9b46ce6..58b53afe 100755
--- a/tests/btrfs/064
+++ b/tests/btrfs/064
@@ -63,12 +63,10 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $balance_pid $replace_pid
-	wait
-	# wait for the balance and replace operations to finish
-	while ps aux | grep "balance start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_balance_pid $balance_pid
+	kill $replace_pid
+	wait $replace_pid
+	# wait for the replace operation to finish
 	while ps aux | grep "replace start" | grep -qv grep; do
 		sleep 1
 	done
diff --git a/tests/btrfs/255 b/tests/btrfs/255
index 7e70944a..aa250467 100755
--- a/tests/btrfs/255
+++ b/tests/btrfs/255
@@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do
 	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
 	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
 done
-kill $balance_pid &> /dev/null
-wait
-# wait for the balance operation to finish
-while ps aux | grep "balance start" | grep -qv grep; do
-	sleep 1
-done
+
+_btrfs_kill_stress_balance_pid $balance_pid
 
 echo "Silence is golden"
 status=0
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
  2024-03-27 17:11 ` [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  8:41   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 03/10] btrfs/028: removed redundant sync and scratch filesystem unmount fdmanana
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Now that there's a helper to kill a background process that is running
_btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the
existing code in btrfs/028.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/028 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/btrfs/028 b/tests/btrfs/028
index d860974e..8fbe8887 100755
--- a/tests/btrfs/028
+++ b/tests/btrfs/028
@@ -44,12 +44,9 @@ balance_pid=$!
 
 # 30s is enough to trigger bug
 sleep $((30*$TIME_FACTOR))
-kill $fsstress_pid $balance_pid &> /dev/null
-wait
-
-# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel
-# to cancel running or paused balance.
-$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
+kill $fsstress_pid &> /dev/null
+wait $fsstress_pid &> /dev/null
+_btrfs_kill_stress_balance_pid $balance_pid
 
 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 03/10] btrfs/028: removed redundant sync and scratch filesystem unmount
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
  2024-03-27 17:11 ` [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance fdmanana
  2024-03-27 17:11 ` [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-27 17:11 ` [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub fdmanana
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

There's no need to have an explicit scratch filesystem sync and unmount
at the of the test, as the fstests framework automatically unmounts the
filesystem and the unmount naturally syncs any data and metadata.

So remove them and update the comment to be more clear.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/028 | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tests/btrfs/028 b/tests/btrfs/028
index 8fbe8887..0c96b2fe 100755
--- a/tests/btrfs/028
+++ b/tests/btrfs/028
@@ -48,11 +48,8 @@ kill $fsstress_pid &> /dev/null
 wait $fsstress_pid &> /dev/null
 _btrfs_kill_stress_balance_pid $balance_pid
 
-_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
-
-_scratch_unmount
-
-# qgroup will be checked at _check_scratch_fs() by fstest.
+# The qgroups accounting will be checked by 'btrfs check' (fsck) after the
+# fstests framework unmounts the filesystem.
 echo "Silence is golden"
 status=0
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (2 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 03/10] btrfs/028: removed redundant sync and scratch filesystem unmount fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  8:41   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag fdmanana
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing a background process running _btrfs_stress_scrub() is not as
simple as sending a signal to the process and waiting for it to die.
Therefore we have the following logic to terminate such process:

   kill $pid
   wait $pid
   while ps aux | grep "scrub start" | grep -qv grep; do
       sleep 1
   done

Since this is repeated in several test cases, move this logic to a common
helper and use it in all affected test cases. This will help to avoid
repeating the same code again several times in upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 14 ++++++++++++++
 tests/btrfs/061 |  7 +------
 tests/btrfs/066 |  8 ++------
 tests/btrfs/069 | 11 +++++------
 tests/btrfs/072 | 11 +++++------
 tests/btrfs/073 | 11 +++++------
 6 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index e95cff7f..d0adeea1 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -349,6 +349,20 @@ _btrfs_stress_scrub()
 	done
 }
 
+# Kill a background process running _btrfs_stress_scrub()
+_btrfs_kill_stress_scrub_pid()
+{
+       local scrub_pid=$1
+
+       # Ignore if process already died.
+       kill $scrub_pid &> /dev/null
+       wait $scrub_pid &> /dev/null
+       # Wait for the scrub operation to finish.
+       while ps aux | grep "scrub start" | grep -qv grep; do
+               sleep 1
+       done
+}
+
 # stress btrfs by defragmenting every file/dir in a loop and compress file
 # contents while defragmenting if second argument is not "nocompress"
 _btrfs_stress_defrag()
diff --git a/tests/btrfs/061 b/tests/btrfs/061
index d0b55e48..b8b2706c 100755
--- a/tests/btrfs/061
+++ b/tests/btrfs/061
@@ -52,12 +52,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
-	kill $scrub_pid
-	wait $scrub_pid
-	# wait for the crub operation to finish
-	while ps aux | grep "scrub start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_scrub_pid $scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/066 b/tests/btrfs/066
index a29034bb..29821fdd 100755
--- a/tests/btrfs/066
+++ b/tests/btrfs/066
@@ -57,12 +57,8 @@ run_test()
 	wait $fsstress_pid
 
 	touch $stop_file
-	kill $scrub_pid
-	wait
-	# wait for the scrub operation to finish
-	while ps aux | grep "scrub start" | grep -qv grep; do
-		sleep 1
-	done
+	wait $subvol_pid
+	_btrfs_kill_stress_scrub_pid $scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/069 b/tests/btrfs/069
index 139dde48..20f44b39 100755
--- a/tests/btrfs/069
+++ b/tests/btrfs/069
@@ -59,17 +59,16 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $replace_pid $scrub_pid
-	wait
+	kill $replace_pid
+	wait $replace_pid
 
-	# wait for the scrub and replace operations to finish
-	while ps aux | grep "scrub start" | grep -qv grep; do
-		sleep 1
-	done
+	# wait for the replace operation to finish
 	while ps aux | grep "replace start" | grep -qv grep; do
 		sleep 1
 	done
 
+	_btrfs_kill_stress_scrub_pid $scrub_pid
+
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
 	if [ $? -ne 0 ]; then
diff --git a/tests/btrfs/072 b/tests/btrfs/072
index 4b6b6fb5..6c15b51f 100755
--- a/tests/btrfs/072
+++ b/tests/btrfs/072
@@ -52,16 +52,15 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $scrub_pid $defrag_pid
-	wait
-	# wait for the scrub and defrag operations to finish
-	while ps aux | grep "scrub start" | grep -qv grep; do
-		sleep 1
-	done
+	kill $defrag_pid
+	wait $defrag_pid
+	# wait for the defrag operation to finish
 	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
 		sleep 1
 	done
 
+	_btrfs_kill_stress_scrub_pid $scrub_pid
+
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
 	if [ $? -ne 0 ]; then
diff --git a/tests/btrfs/073 b/tests/btrfs/073
index b1604f94..49a4abd1 100755
--- a/tests/btrfs/073
+++ b/tests/btrfs/073
@@ -51,16 +51,15 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $scrub_pid $remount_pid
-	wait
-	# wait for the scrub and remount operations to finish
-	while ps aux | grep "scrub start" | grep -qv grep; do
-		sleep 1
-	done
+	kill $remount_pid
+	wait $remount_pid
+	# wait for the remount operation to finish
 	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
 		sleep 1
 	done
 
+	_btrfs_kill_stress_scrub_pid $scrub_pid
+
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
 	if [ $? -ne 0 ]; then
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (3 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:18   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress fdmanana
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing a background process running _btrfs_stress_defrag() is not as
simple as sending a signal to the process and waiting for it to die.
Therefore we have the following logic to terminate such process:

       kill $pid
       wait $pid
       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
           sleep 1
       done

Since this is repeated in several test cases, move this logic to a common
helper and use it in all affected test cases. This will help to avoid
repeating the same code again several times in upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 14 ++++++++++++++
 tests/btrfs/062 |  7 +------
 tests/btrfs/067 |  8 ++------
 tests/btrfs/070 | 11 +++++------
 tests/btrfs/072 |  7 +------
 tests/btrfs/074 | 11 +++++------
 6 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index d0adeea1..46056d4a 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -383,6 +383,20 @@ _btrfs_stress_defrag()
 	done
 }
 
+# Kill a background process running _btrfs_stress_defrag()
+_btrfs_kill_stress_defrag_pid()
+{
+       local defrag_pid=$1
+
+       # Ignore if process already died.
+       kill $defrag_pid &> /dev/null
+       wait $defrag_pid &> /dev/null
+       # Wait for the defrag operation to finish.
+       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
+               sleep 1
+       done
+}
+
 # stress btrfs by remounting it with different compression algorithms in a loop
 # run this with fsstress running at background could exercise the compression
 # code path and ensure no race when switching compression algorithm with constant
diff --git a/tests/btrfs/062 b/tests/btrfs/062
index a2639d6c..59d581be 100755
--- a/tests/btrfs/062
+++ b/tests/btrfs/062
@@ -53,12 +53,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
-	kill $defrag_pid
-	wait $defrag_pid
-	# wait for the defrag operation to finish
-	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_defrag_pid $defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/067 b/tests/btrfs/067
index 709db155..2bb00b87 100755
--- a/tests/btrfs/067
+++ b/tests/btrfs/067
@@ -58,12 +58,8 @@ run_test()
 	wait $fsstress_pid
 
 	touch $stop_file
-	kill $defrag_pid
-	wait
-	# wait for btrfs defrag process to exit, otherwise it will block umount
-	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
-		sleep 1
-	done
+	wait $subvol_pid
+	_btrfs_kill_stress_defrag_pid $defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/070 b/tests/btrfs/070
index 54aa275c..cefa5723 100755
--- a/tests/btrfs/070
+++ b/tests/btrfs/070
@@ -60,17 +60,16 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $replace_pid $defrag_pid
-	wait
+	kill $replace_pid
+	wait $replace_pid
 
-	# wait for the defrag and replace operations to finish
-	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
-		sleep 1
-	done
+	# wait for the replace operation to finish
 	while ps aux | grep "replace start" | grep -qv grep; do
 		sleep 1
 	done
 
+	_btrfs_kill_stress_defrag_pid $defrag_pid
+
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
 	if [ $? -ne 0 ]; then
diff --git a/tests/btrfs/072 b/tests/btrfs/072
index 6c15b51f..505d0b57 100755
--- a/tests/btrfs/072
+++ b/tests/btrfs/072
@@ -52,13 +52,8 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $defrag_pid
-	wait $defrag_pid
-	# wait for the defrag operation to finish
-	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
-		sleep 1
-	done
 
+	_btrfs_kill_stress_defrag_pid $defrag_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/074 b/tests/btrfs/074
index 9b22c620..d51922d0 100755
--- a/tests/btrfs/074
+++ b/tests/btrfs/074
@@ -52,16 +52,15 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $defrag_pid $remount_pid
-	wait
-	# wait for the defrag and remount operations to finish
-	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
-		sleep 1
-	done
+	kill $remount_pid
+	wait $remount_pid
+	# wait for the remount operation to finish
 	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
 		sleep 1
 	done
 
+	_btrfs_kill_stress_defrag_pid $defrag_pid
+
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
 	if [ $? -ne 0 ]; then
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (4 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:24   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace fdmanana
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing a background process running _btrfs_stress_remount_compress() is
not as simple as sending a signal to the process and waiting for it to
die. Therefore we have the following logic to terminate such process:

    kill $pid
    wait $pid
    while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
        sleep 1
    done

Since this is repeated in several test cases, move this logic to a common
helper and use it in all affected test cases. This will help to avoid
repeating the same code again several times in upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 15 +++++++++++++++
 tests/btrfs/063 |  7 +------
 tests/btrfs/068 |  8 ++------
 tests/btrfs/071 | 12 +++++-------
 tests/btrfs/073 |  8 +-------
 tests/btrfs/074 |  8 +-------
 6 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index 46056d4a..66a3a347 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -411,6 +411,21 @@ _btrfs_stress_remount_compress()
 	done
 }
 
+# Kill a background process running _btrfs_stress_remount_compress()
+_btrfs_kill_stress_remount_compress_pid()
+{
+	local remount_pid=$1
+	local btrfs_mnt=$2
+
+	# Ignore if process already died.
+	kill $remount_pid &> /dev/null
+	wait $remount_pid &> /dev/null
+	# Wait for the remount loop to finish.
+	while ps aux | grep "mount.*${btrfs_mnt}" | grep -qv grep; do
+		sleep 1
+	done
+}
+
 # stress btrfs by replacing devices in a loop
 # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last
 # device should be free(not used by btrfs)
diff --git a/tests/btrfs/063 b/tests/btrfs/063
index baf0c356..5ee2837f 100755
--- a/tests/btrfs/063
+++ b/tests/btrfs/063
@@ -52,12 +52,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
-	kill $remount_pid
-	wait $remount_pid
-	# wait for the remount loop to finish
-	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/068 b/tests/btrfs/068
index 15fd41db..db53254a 100755
--- a/tests/btrfs/068
+++ b/tests/btrfs/068
@@ -58,12 +58,8 @@ run_test()
 	wait $fsstress_pid
 
 	touch $stop_file
-	kill $remount_pid
-	wait
-	# wait for the remount loop process to finish
-	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
-		sleep 1
-	done
+	wait $subvol_pid
+	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/071 b/tests/btrfs/071
index 6ebbd8cc..7ba15390 100755
--- a/tests/btrfs/071
+++ b/tests/btrfs/071
@@ -58,17 +58,15 @@ run_test()
 	echo "$remount_pid" >>$seqres.full
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
-	wait $fsstress_pid
-	kill $replace_pid $remount_pid
-	wait
+	kill $replace_pid
+	wait $fsstress_pid $replace_pid
 
-	# wait for the remount and replace operations to finish
+	# wait for the replace operationss to finish
 	while ps aux | grep "replace start" | grep -qv grep; do
 		sleep 1
 	done
-	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
-		sleep 1
-	done
+
+	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/073 b/tests/btrfs/073
index 49a4abd1..50358286 100755
--- a/tests/btrfs/073
+++ b/tests/btrfs/073
@@ -51,13 +51,7 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $remount_pid
-	wait $remount_pid
-	# wait for the remount operation to finish
-	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
-		sleep 1
-	done
-
+	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 	_btrfs_kill_stress_scrub_pid $scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/074 b/tests/btrfs/074
index d51922d0..6e93b36a 100755
--- a/tests/btrfs/074
+++ b/tests/btrfs/074
@@ -52,13 +52,7 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $remount_pid
-	wait $remount_pid
-	# wait for the remount operation to finish
-	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
-		sleep 1
-	done
-
+	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 	_btrfs_kill_stress_defrag_pid $defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (5 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:35   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume fdmanana
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Killing a background process running _btrfs_stress_replace() is not as
simple as sending a signal to the process and waiting for it to die.
Therefore we have the following logic to terminate such process:

   kill $pid
   wait $pid
   while ps aux | grep "replace start" | grep -qv grep; do
      sleep 1
   done

Since this is repeated in several test cases, move this logic to a common
helper and use it in all affected test cases. This will help to avoid
repeating the same code again several times in upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 14 ++++++++++++++
 tests/btrfs/064 |  7 +------
 tests/btrfs/065 |  8 ++------
 tests/btrfs/069 |  9 +--------
 tests/btrfs/070 |  9 +--------
 tests/btrfs/071 | 10 ++--------
 6 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index 66a3a347..6d7e7a68 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -475,6 +475,20 @@ _btrfs_stress_replace()
 	done
 }
 
+# Kill a background process running _btrfs_stress_replace()
+_btrfs_kill_stress_replace_pid()
+{
+       local replace_pid=$1
+
+       # Ignore if process already died.
+       kill $replace_pid &> /dev/null
+       wait $replace_pid &> /dev/null
+       # Wait for the replace operation to finish.
+       while ps aux | grep "replace start" | grep -qv grep; do
+               sleep 1
+       done
+}
+
 # find the right option to force output in bytes, older versions of btrfs-progs
 # print that by default, newer print human readable numbers with unit suffix
 _btrfs_qgroup_units()
diff --git a/tests/btrfs/064 b/tests/btrfs/064
index 58b53afe..9e0b3b30 100755
--- a/tests/btrfs/064
+++ b/tests/btrfs/064
@@ -64,12 +64,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
-	kill $replace_pid
-	wait $replace_pid
-	# wait for the replace operation to finish
-	while ps aux | grep "replace start" | grep -qv grep; do
-		sleep 1
-	done
+	_btrfs_kill_stress_replace_pid $replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/065 b/tests/btrfs/065
index c4b6aafe..d2b04178 100755
--- a/tests/btrfs/065
+++ b/tests/btrfs/065
@@ -65,12 +65,8 @@ run_test()
 	wait $fsstress_pid
 
 	touch $stop_file
-	kill $replace_pid
-	wait
-	# wait for the replace operation to finish
-	while ps aux | grep "replace start" | grep -qv grep; do
-		sleep 1
-	done
+	wait $subvol_pid
+	_btrfs_kill_stress_replace_pid $replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/069 b/tests/btrfs/069
index 20f44b39..ad1609d4 100755
--- a/tests/btrfs/069
+++ b/tests/btrfs/069
@@ -59,15 +59,8 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $replace_pid
-	wait $replace_pid
-
-	# wait for the replace operation to finish
-	while ps aux | grep "replace start" | grep -qv grep; do
-		sleep 1
-	done
-
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	_btrfs_kill_stress_replace_pid $replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/070 b/tests/btrfs/070
index cefa5723..3054c270 100755
--- a/tests/btrfs/070
+++ b/tests/btrfs/070
@@ -60,14 +60,7 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
-	kill $replace_pid
-	wait $replace_pid
-
-	# wait for the replace operation to finish
-	while ps aux | grep "replace start" | grep -qv grep; do
-		sleep 1
-	done
-
+	_btrfs_kill_stress_replace_pid $replace_pid
 	_btrfs_kill_stress_defrag_pid $defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/071 b/tests/btrfs/071
index 7ba15390..36b39341 100755
--- a/tests/btrfs/071
+++ b/tests/btrfs/071
@@ -58,14 +58,8 @@ run_test()
 	echo "$remount_pid" >>$seqres.full
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
-	kill $replace_pid
-	wait $fsstress_pid $replace_pid
-
-	# wait for the replace operationss to finish
-	while ps aux | grep "replace start" | grep -qv grep; do
-		sleep 1
-	done
-
+	wait $fsstress_pid
+	_btrfs_kill_stress_replace_pid $replace_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 
 	echo "Scrub the filesystem" >>$seqres.full
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (6 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:36   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume fdmanana
  2024-03-27 17:11 ` [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted fdmanana
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

We have this logic to stop a process running _btrfs_stress_subvolume()
spread in several test cases:

   touch $stop_file
   wait $subvol_pid

Add a helper to encapsulate that logic and also remove the stop file after
the process terminated as there's no point having it around anymore.

This will help to avoid repeating the same code again several times in
upcoming changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 12 ++++++++++++
 tests/btrfs/060 |  3 +--
 tests/btrfs/065 |  3 +--
 tests/btrfs/066 |  3 +--
 tests/btrfs/067 |  3 +--
 tests/btrfs/068 |  3 +--
 6 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index 6d7e7a68..e19a6ad1 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -340,6 +340,18 @@ _btrfs_stress_subvolume()
 	done
 }
 
+# Kill a background process running _btrfs_stress_subvolume()
+_btrfs_kill_stress_subvolume_pid()
+{
+	local subvol_pid=$1
+	local stop_file=$2
+
+	touch $stop_file
+	# Ignore if process already died.
+	wait $subvol_pid &> /dev/null
+	rm -f $stop_file
+}
+
 # stress btrfs by running scrub in a loop
 _btrfs_stress_scrub()
 {
diff --git a/tests/btrfs/060 b/tests/btrfs/060
index 58167cc6..87823aba 100755
--- a/tests/btrfs/060
+++ b/tests/btrfs/060
@@ -56,8 +56,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 
-	touch $stop_file
-	wait $subvol_pid
+	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
 	_btrfs_kill_stress_balance_pid $balance_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/065 b/tests/btrfs/065
index d2b04178..ddc28616 100755
--- a/tests/btrfs/065
+++ b/tests/btrfs/065
@@ -64,8 +64,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 
-	touch $stop_file
-	wait $subvol_pid
+	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
 	_btrfs_kill_stress_replace_pid $replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/066 b/tests/btrfs/066
index 29821fdd..c7488602 100755
--- a/tests/btrfs/066
+++ b/tests/btrfs/066
@@ -56,8 +56,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 
-	touch $stop_file
-	wait $subvol_pid
+	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
 	_btrfs_kill_stress_scrub_pid $scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/067 b/tests/btrfs/067
index 2bb00b87..ebbec1be 100755
--- a/tests/btrfs/067
+++ b/tests/btrfs/067
@@ -57,8 +57,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 
-	touch $stop_file
-	wait $subvol_pid
+	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
 	_btrfs_kill_stress_defrag_pid $defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
diff --git a/tests/btrfs/068 b/tests/btrfs/068
index db53254a..5f41fb74 100755
--- a/tests/btrfs/068
+++ b/tests/btrfs/068
@@ -57,8 +57,7 @@ run_test()
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
 
-	touch $stop_file
-	wait $subvol_pid
+	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
 
 	echo "Scrub the filesystem" >>$seqres.full
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (7 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:38   ` Anand Jain
  2024-03-27 17:11 ` [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted fdmanana
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Instead of having every test case that uses _btrfs_stress_subvolume()
removing the stop file before calling that function, do the file
remove at _btrfs_stress_subvolume(). There's no point in doing it in
every single test case.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 common/btrfs    | 1 +
 tests/btrfs/060 | 2 --
 tests/btrfs/065 | 2 --
 tests/btrfs/066 | 2 --
 tests/btrfs/067 | 2 --
 tests/btrfs/068 | 2 --
 6 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/common/btrfs b/common/btrfs
index e19a6ad1..29061c23 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -331,6 +331,7 @@ _btrfs_stress_subvolume()
 	local subvol_mnt=$4
 	local stop_file=$5
 
+	rm -f $stop_file
 	mkdir -p $subvol_mnt
 	while [ ! -e $stop_file ]; do
 		$BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
diff --git a/tests/btrfs/060 b/tests/btrfs/060
index 87823aba..53cbd3a0 100755
--- a/tests/btrfs/060
+++ b/tests/btrfs/060
@@ -46,8 +46,6 @@ run_test()
 	balance_pid=$!
 	echo "$balance_pid" >>$seqres.full
 
-	# make sure the stop sign is not there
-	rm -f $stop_file
 	echo -n "Start subvolume worker: " >>$seqres.full
 	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
 	subvol_pid=$!
diff --git a/tests/btrfs/065 b/tests/btrfs/065
index ddc28616..f9e43cdc 100755
--- a/tests/btrfs/065
+++ b/tests/btrfs/065
@@ -49,8 +49,6 @@ run_test()
 	$FSSTRESS_PROG $args >>$seqres.full &
 	fsstress_pid=$!
 
-	# make sure the stop sign is not there
-	rm -f $stop_file
 	echo -n "Start subvolume worker: " >>$seqres.full
 	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
 	subvol_pid=$!
diff --git a/tests/btrfs/066 b/tests/btrfs/066
index c7488602..b6f904ac 100755
--- a/tests/btrfs/066
+++ b/tests/btrfs/066
@@ -41,8 +41,6 @@ run_test()
 	$FSSTRESS_PROG $args >>$seqres.full &
 	fsstress_pid=$!
 
-	# make sure the stop sign is not there
-	rm -f $stop_file
 	echo -n "Start subvolume worker: " >>$seqres.full
 	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
 	subvol_pid=$!
diff --git a/tests/btrfs/067 b/tests/btrfs/067
index ebbec1be..7be09d52 100755
--- a/tests/btrfs/067
+++ b/tests/btrfs/067
@@ -42,8 +42,6 @@ run_test()
 	$FSSTRESS_PROG $args >>$seqres.full &
 	fsstress_pid=$!
 
-	# make sure the stop sign is not there
-	rm -f $stop_file
 	echo -n "Start subvolume worker: " >>$seqres.full
 	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
 	subvol_pid=$!
diff --git a/tests/btrfs/068 b/tests/btrfs/068
index 5f41fb74..19e37010 100755
--- a/tests/btrfs/068
+++ b/tests/btrfs/068
@@ -42,8 +42,6 @@ run_test()
 	$FSSTRESS_PROG $args >>$seqres.full &
 	fsstress_pid=$!
 
-	# make sure the stop sign is not there
-	rm -f $stop_file
 	echo -n "Start subvolume worker: " >>$seqres.full
 	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
 	subvol_pid=$!
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
  2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
                   ` (8 preceding siblings ...)
  2024-03-27 17:11 ` [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume fdmanana
@ 2024-03-27 17:11 ` fdmanana
  2024-03-28  9:48   ` Anand Jain
  9 siblings, 1 reply; 27+ messages in thread
From: fdmanana @ 2024-03-27 17:11 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent
operations while fsstress is running in parallel, and all these are left
as child processes running in the background, which are correctly stopped
if the tests are not interrupted/killed. However if any of these tests is
interrupted/killed, it often leaves child processes still running in the
background, which prevent further running fstests again. For example:

  $ /check -g auto
  (...)
  btrfs/060 394s ...  264s
  btrfs/061 83s ...  69s
  btrfs/062 109s ...  105s
  btrfs/063 52s ...  67s
  btrfs/064 53s ...  51s
  btrfs/065 88s ...  271s
  btrfs/066 127s ...  241s
  btrfs/067 435s ...  248s
  btrfs/068 161s ... ^C^C
  ^C

  $ ./check btrfs/068
  FSTYP         -- btrfs
  PLATFORM      -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar  4 17:19:19 WET 2024
  MKFS_OPTIONS  -- /dev/sdb
  MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1

  our local _scratch_mkfs routine ...
  btrfs-progs v6.6.2
  See https://btrfs.readthedocs.io for more information.

  ERROR: unable to open /dev/sdb: Device or resource busy
  check: failed to mkfs $SCRATCH_DEV using specified options
  Interrupted!
  Passed all 0 tests

In this case there was still a process running _btrfs_stress_subvolume()
from common/btrfs.

This is a bit annoying because it requires manually finding out which
process is preventing unmounting the scratch device and then properly
stop/kill it.

So fix this by adding a _cleanup() function to all these tests and then
making sure it stops all the child processes it spawned and are running
in the background.

All these tests have the same structure as they were part of the same
patchset and from the same author.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/060 | 22 +++++++++++++++++++++-
 tests/btrfs/061 | 19 +++++++++++++++++++
 tests/btrfs/062 | 19 +++++++++++++++++++
 tests/btrfs/063 | 19 +++++++++++++++++++
 tests/btrfs/064 | 19 +++++++++++++++++++
 tests/btrfs/065 | 22 +++++++++++++++++++++-
 tests/btrfs/066 | 22 +++++++++++++++++++++-
 tests/btrfs/067 | 22 +++++++++++++++++++++-
 tests/btrfs/068 | 22 +++++++++++++++++++++-
 tests/btrfs/069 | 19 +++++++++++++++++++
 tests/btrfs/070 | 19 +++++++++++++++++++
 tests/btrfs/071 | 19 +++++++++++++++++++
 tests/btrfs/072 | 19 +++++++++++++++++++
 tests/btrfs/073 | 19 +++++++++++++++++++
 tests/btrfs/074 | 19 +++++++++++++++++++
 15 files changed, 295 insertions(+), 5 deletions(-)

diff --git a/tests/btrfs/060 b/tests/btrfs/060
index 53cbd3a0..f74d9593 100755
--- a/tests/btrfs/060
+++ b/tests/btrfs/060
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto balance subvol scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	fi
+	if [ ! -z "$balance_pid" ]; then
+		_btrfs_kill_stress_balance_pid $balance_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,11 +36,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
 	local mkfs_opts=$1
 	local subvol_mnt=$TEST_DIR/$seq.mnt
-	local stop_file=$TEST_DIR/$seq.stop.$$
 
 	echo "Test $mkfs_opts" >>$seqres.full
 
@@ -53,9 +70,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	unset subvol_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
+	unset balance_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/061 b/tests/btrfs/061
index b8b2706c..fec90882 100755
--- a/tests/btrfs/061
+++ b/tests/btrfs/061
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto balance scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$balance_pid" ]; then
+		_btrfs_kill_stress_balance_pid $balance_pid
+	fi
+	if [ ! -z "$scrub_pid" ]; then
+		_btrfs_kill_stress_scrub_pid $scrub_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
+	unset balance_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	unset scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/062 b/tests/btrfs/062
index 59d581be..0b57681f 100755
--- a/tests/btrfs/062
+++ b/tests/btrfs/062
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto balance defrag compress scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$balance_pid" ]; then
+		_btrfs_kill_stress_balance_pid $balance_pid
+	fi
+	if [ ! -z "$defrag_pid" ]; then
+		_btrfs_kill_stress_defrag_pid $defrag_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,8 +68,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
+	unset balance_pid
 	_btrfs_kill_stress_defrag_pid $defrag_pid
+	unset defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/063 b/tests/btrfs/063
index 5ee2837f..99d9d2c1 100755
--- a/tests/btrfs/063
+++ b/tests/btrfs/063
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto balance remount compress scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$balance_pid" ]; then
+		_btrfs_kill_stress_balance_pid $balance_pid
+	fi
+	if [ ! -z "$remount_pid" ]; then
+		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
+	unset balance_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	unset remount_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/064 b/tests/btrfs/064
index 9e0b3b30..663442c6 100755
--- a/tests/btrfs/064
+++ b/tests/btrfs/064
@@ -12,6 +12,22 @@
 . ./common/preamble
 _begin_fstest auto balance replace volume scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$balance_pid" ]; then
+		_btrfs_kill_stress_balance_pid $balance_pid
+	fi
+	if [ ! -z "$replace_pid" ]; then
+		_btrfs_kill_stress_replace_pid $replace_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -63,8 +79,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_balance_pid $balance_pid
+	unset balance_pid
 	_btrfs_kill_stress_replace_pid $replace_pid
+	unset replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/065 b/tests/btrfs/065
index f9e43cdc..b1e54fc8 100755
--- a/tests/btrfs/065
+++ b/tests/btrfs/065
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto subvol replace volume scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	fi
+	if [ ! -z "$replace_pid" ]; then
+		_btrfs_kill_stress_replace_pid $replace_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -21,12 +37,13 @@ _require_scratch_dev_pool 5
 _require_scratch_dev_pool_equal_size
 _btrfs_get_profile_configs replace
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
 	local mkfs_opts=$1
 	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
 	local subvol_mnt=$TEST_DIR/$seq.mnt
-	local stop_file=$TEST_DIR/$seq.stop.$$
 
 	echo "Test $mkfs_opts" >>$seqres.full
 
@@ -61,9 +78,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	unset subvol_pid
 	_btrfs_kill_stress_replace_pid $replace_pid
+	unset replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/066 b/tests/btrfs/066
index b6f904ac..feb6062e 100755
--- a/tests/btrfs/066
+++ b/tests/btrfs/066
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto subvol scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	fi
+	if [ ! -z "$scrub_pid" ]; then
+		_btrfs_kill_stress_scrub_pid $scrub_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,11 +36,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
 	local mkfs_opts=$1
 	local subvol_mnt=$TEST_DIR/$seq.mnt
-	local stop_file=$TEST_DIR/$seq.stop.$$
 
 	echo "Test $mkfs_opts" >>$seqres.full
 
@@ -53,9 +70,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	unset subvol_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	unset scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/067 b/tests/btrfs/067
index 7be09d52..0bbfe83f 100755
--- a/tests/btrfs/067
+++ b/tests/btrfs/067
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto subvol defrag compress scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	fi
+	if [ ! -z "$defrag_pid" ]; then
+		_btrfs_kill_stress_defrag_pid $defrag_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,12 +36,13 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
 	local mkfs_opts=$1
 	local with_compress=$2
 	local subvol_mnt=$TEST_DIR/$seq.mnt
-	local stop_file=$TEST_DIR/$seq.stop.$$
 
 	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -54,9 +71,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	unset subvol_pid
 	_btrfs_kill_stress_defrag_pid $defrag_pid
+	unset defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/068 b/tests/btrfs/068
index 19e37010..7ab6feca 100755
--- a/tests/btrfs/068
+++ b/tests/btrfs/068
@@ -11,6 +11,22 @@
 . ./common/preamble
 _begin_fstest auto subvol remount compress scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	fi
+	if [ ! -z "$remount_pid" ]; then
+		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -21,11 +37,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
 	local mkfs_opts=$1
 	local subvol_mnt=$TEST_DIR/$seq.mnt
-	local stop_file=$TEST_DIR/$seq.stop.$$
 
 	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -54,9 +71,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+	unset subvol_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	unset remount_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/069 b/tests/btrfs/069
index ad1609d4..3fbfecdb 100755
--- a/tests/btrfs/069
+++ b/tests/btrfs/069
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto replace scrub volume
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$replace_pid" ]; then
+		_btrfs_kill_stress_replace_pid $replace_pid
+	fi
+	if [ ! -z "$scrub_pid" ]; then
+		_btrfs_kill_stress_scrub_pid $scrub_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -59,8 +75,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	unset scrub_pid
 	_btrfs_kill_stress_replace_pid $replace_pid
+	unset replace_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/070 b/tests/btrfs/070
index 3054c270..11fddc86 100755
--- a/tests/btrfs/070
+++ b/tests/btrfs/070
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto replace defrag compress volume scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$replace_pid" ]; then
+		_btrfs_kill_stress_replace_pid $replace_pid
+	fi
+	if [ ! -z "$defrag_pid" ]; then
+		_btrfs_kill_stress_defrag_pid $defrag_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -60,8 +76,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_replace_pid $replace_pid
+	unset replace_pid
 	_btrfs_kill_stress_defrag_pid $defrag_pid
+	unset defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/071 b/tests/btrfs/071
index 36b39341..1a91ec45 100755
--- a/tests/btrfs/071
+++ b/tests/btrfs/071
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto replace remount compress volume scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$replace_pid" ]; then
+		_btrfs_kill_stress_replace_pid $replace_pid
+	fi
+	if [ ! -z "$remount_pid" ]; then
+		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -59,8 +75,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_replace_pid $replace_pid
+	unset replace_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	unset remount_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/072 b/tests/btrfs/072
index 505d0b57..e66e49c9 100755
--- a/tests/btrfs/072
+++ b/tests/btrfs/072
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto scrub defrag compress
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$defrag_pid" ]; then
+		_btrfs_kill_stress_defrag_pid $defrag_pid
+	fi
+	if [ ! -z "$scrub_pid" ]; then
+		_btrfs_kill_stress_scrub_pid $scrub_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,9 +68,12 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 
 	_btrfs_kill_stress_defrag_pid $defrag_pid
+	unset defrag_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	unset scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/073 b/tests/btrfs/073
index 50358286..e6cfd92a 100755
--- a/tests/btrfs/073
+++ b/tests/btrfs/073
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto scrub remount compress
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$remount_pid" ]; then
+		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	fi
+	if [ ! -z "$scrub_pid" ]; then
+		_btrfs_kill_stress_scrub_pid $scrub_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	unset remount_pid
 	_btrfs_kill_stress_scrub_pid $scrub_pid
+	unset scrub_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
diff --git a/tests/btrfs/074 b/tests/btrfs/074
index 6e93b36a..1dd88bcd 100755
--- a/tests/btrfs/074
+++ b/tests/btrfs/074
@@ -10,6 +10,22 @@
 . ./common/preamble
 _begin_fstest auto defrag remount compress scrub
 
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+	if [ ! -z "$remount_pid" ]; then
+		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	fi
+	if [ ! -z "$defrag_pid" ]; then
+		_btrfs_kill_stress_defrag_pid $defrag_pid
+	fi
+	if [ ! -z "$fsstress_pid" ]; then
+		kill $fsstress_pid &> /dev/null
+		wait $fsstress_pid &> /dev/null
+	fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,8 +68,11 @@ run_test()
 
 	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
 	wait $fsstress_pid
+	unset fsstress_pid
 	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+	unset remount_pid
 	_btrfs_kill_stress_defrag_pid $defrag_pid
+	unset defrag_pid
 
 	echo "Scrub the filesystem" >>$seqres.full
 	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance
  2024-03-27 17:11 ` [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance fdmanana
@ 2024-03-28  8:16   ` Anand Jain
  2024-03-28  9:21     ` Filipe Manana
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28  8:16 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Killing a background process running _btrfs_stress_balance() is not as
> simple as sending a signal to the process and waiting for it to die.
> Therefore we have the following logic to terminate such process:
> 
>     kill $pid
>     wait $pid
>     # Wait for the balance operation to finish.
>     while ps aux | grep "balance start" | grep -qv grep; do


>         sleep 1
>     done
> 
> Since this is repeated in several test cases, move this logic to a common
> helper and use it in all affected test cases. This will help to avoid
> repeating the same code again several times in upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

A few minor things below.

> ---
>   common/btrfs    | 14 ++++++++++++++
>   tests/btrfs/060 |  8 ++------
>   tests/btrfs/061 | 10 ++++------
>   tests/btrfs/062 | 10 ++++------
>   tests/btrfs/063 | 10 ++++------
>   tests/btrfs/064 | 10 ++++------
>   tests/btrfs/255 |  8 ++------
>   7 files changed, 34 insertions(+), 36 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index aa344706..e95cff7f 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -308,6 +308,20 @@ _btrfs_stress_balance()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_balance()
> +_btrfs_kill_stress_balance_pid()
> +{
> +	local balance_pid=$1
> +
> +	# Ignore if process already died.
> +	kill $balance_pid &> /dev/null
> +	wait $balance_pid &> /dev/null
> +	# Wait for the balance operation to finish.
> +	while ps aux | grep "balance start" | grep -qv grep; do


  We can use pgrep instead. I will make the following changes before
  merging if you are okay with it.

-       while ps aux | grep "balance start" | grep -qv grep; do
+       while pgrep -f "btrfs balance start" > /dev/null; do



> +		sleep 1
> +	done
> +}
> +
>   # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
>   _btrfs_stress_subvolume()
>   {
> diff --git a/tests/btrfs/060 b/tests/btrfs/060
> index a0184891..58167cc6 100755
> --- a/tests/btrfs/060
> +++ b/tests/btrfs/060
> @@ -57,12 +57,8 @@ run_test()
>   	wait $fsstress_pid
>   
>   	touch $stop_file
> -	kill $balance_pid
> -	wait
> -	# wait for the balance operation to finish
> -	while ps aux | grep "balance start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	wait $subvol_pid
> +	_btrfs_kill_stress_balance_pid $balance_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/061 b/tests/btrfs/061
> index c1010413..d0b55e48 100755
> --- a/tests/btrfs/061
> +++ b/tests/btrfs/061
> @@ -51,12 +51,10 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $balance_pid $scrub_pid
> -	wait
> -	# wait for the balance and scrub operations to finish
> -	while ps aux | grep "balance start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_balance_pid $balance_pid
> +	kill $scrub_pid
> +	wait $scrub_pid
> +	# wait for the crub operation to finish

s/crub/scrub/

Thanks, Anand

>   	while ps aux | grep "scrub start" | grep -qv grep; do
>   		sleep 1
>   	done
> diff --git a/tests/btrfs/062 b/tests/btrfs/062
> index 818a0156..a2639d6c 100755
> --- a/tests/btrfs/062
> +++ b/tests/btrfs/062
> @@ -52,12 +52,10 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $balance_pid $defrag_pid
> -	wait
> -	# wait for the balance and defrag operations to finish
> -	while ps aux | grep "balance start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_balance_pid $balance_pid
> +	kill $defrag_pid
> +	wait $defrag_pid
> +	# wait for the defrag operation to finish
>   	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
>   		sleep 1
>   	done
> diff --git a/tests/btrfs/063 b/tests/btrfs/063
> index 2f771baf..baf0c356 100755
> --- a/tests/btrfs/063
> +++ b/tests/btrfs/063
> @@ -51,12 +51,10 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $balance_pid $remount_pid
> -	wait
> -	# wait for the balance and remount loop to finish
> -	while ps aux | grep "balance start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_balance_pid $balance_pid
> +	kill $remount_pid
> +	wait $remount_pid
> +	# wait for the remount loop to finish
>   	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>   		sleep 1
>   	done
> diff --git a/tests/btrfs/064 b/tests/btrfs/064
> index e9b46ce6..58b53afe 100755
> --- a/tests/btrfs/064
> +++ b/tests/btrfs/064
> @@ -63,12 +63,10 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $balance_pid $replace_pid
> -	wait
> -	# wait for the balance and replace operations to finish
> -	while ps aux | grep "balance start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_balance_pid $balance_pid
> +	kill $replace_pid
> +	wait $replace_pid
> +	# wait for the replace operation to finish
>   	while ps aux | grep "replace start" | grep -qv grep; do
>   		sleep 1
>   	done
> diff --git a/tests/btrfs/255 b/tests/btrfs/255
> index 7e70944a..aa250467 100755
> --- a/tests/btrfs/255
> +++ b/tests/btrfs/255
> @@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do
>   	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
>   	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
>   done
> -kill $balance_pid &> /dev/null
> -wait
> -# wait for the balance operation to finish
> -while ps aux | grep "balance start" | grep -qv grep; do
> -	sleep 1
> -done
> +
> +_btrfs_kill_stress_balance_pid $balance_pid
>   
>   echo "Silence is golden"
>   status=0


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub
  2024-03-27 17:11 ` [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub fdmanana
@ 2024-03-28  8:41   ` Anand Jain
  2024-03-28  9:27     ` Filipe Manana
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28  8:41 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Killing a background process running _btrfs_stress_scrub() is not as
> simple as sending a signal to the process and waiting for it to die.
> Therefore we have the following logic to terminate such process:
> 
>     kill $pid
>     wait $pid
>     while ps aux | grep "scrub start" | grep -qv grep; do
>         sleep 1
>     done
> 
> Since this is repeated in several test cases, move this logic to a common
> helper and use it in all affected test cases. This will help to avoid
> repeating the same code again several times in upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>   common/btrfs    | 14 ++++++++++++++
>   tests/btrfs/061 |  7 +------
>   tests/btrfs/066 |  8 ++------
>   tests/btrfs/069 | 11 +++++------
>   tests/btrfs/072 | 11 +++++------
>   tests/btrfs/073 | 11 +++++------
>   6 files changed, 32 insertions(+), 30 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index e95cff7f..d0adeea1 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -349,6 +349,20 @@ _btrfs_stress_scrub()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_scrub()
> +_btrfs_kill_stress_scrub_pid()
> +{
> +       local scrub_pid=$1
> +
> +       # Ignore if process already died.
> +       kill $scrub_pid &> /dev/null
> +       wait $scrub_pid &> /dev/null
> +       # Wait for the scrub operation to finish.


> +       while ps aux | grep "scrub start" | grep -qv grep; do

This can be replaced by pgrep. I'll make the change if there are
no objections.

       while pgrep -f "btrfs scrub start" > /dev/null; do

Thanks, Anand

> +               sleep 1
> +       done
> +}
> +
>   # stress btrfs by defragmenting every file/dir in a loop and compress file
>   # contents while defragmenting if second argument is not "nocompress"
>   _btrfs_stress_defrag()
> diff --git a/tests/btrfs/061 b/tests/btrfs/061
> index d0b55e48..b8b2706c 100755
> --- a/tests/btrfs/061
> +++ b/tests/btrfs/061
> @@ -52,12 +52,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> -	kill $scrub_pid
> -	wait $scrub_pid
> -	# wait for the crub operation to finish
> -	while ps aux | grep "scrub start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_scrub_pid $scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/066 b/tests/btrfs/066
> index a29034bb..29821fdd 100755
> --- a/tests/btrfs/066
> +++ b/tests/btrfs/066
> @@ -57,12 +57,8 @@ run_test()
>   	wait $fsstress_pid
>   
>   	touch $stop_file
> -	kill $scrub_pid
> -	wait
> -	# wait for the scrub operation to finish
> -	while ps aux | grep "scrub start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	wait $subvol_pid
> +	_btrfs_kill_stress_scrub_pid $scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/069 b/tests/btrfs/069
> index 139dde48..20f44b39 100755
> --- a/tests/btrfs/069
> +++ b/tests/btrfs/069
> @@ -59,17 +59,16 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $replace_pid $scrub_pid
> -	wait
> +	kill $replace_pid
> +	wait $replace_pid
>   
> -	# wait for the scrub and replace operations to finish
> -	while ps aux | grep "scrub start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	# wait for the replace operation to finish
>   	while ps aux | grep "replace start" | grep -qv grep; do
>   		sleep 1
>   	done
>   
> +	_btrfs_kill_stress_scrub_pid $scrub_pid
> +
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
>   	if [ $? -ne 0 ]; then
> diff --git a/tests/btrfs/072 b/tests/btrfs/072
> index 4b6b6fb5..6c15b51f 100755
> --- a/tests/btrfs/072
> +++ b/tests/btrfs/072
> @@ -52,16 +52,15 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $scrub_pid $defrag_pid
> -	wait
> -	# wait for the scrub and defrag operations to finish
> -	while ps aux | grep "scrub start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	kill $defrag_pid
> +	wait $defrag_pid
> +	# wait for the defrag operation to finish
>   	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
>   		sleep 1
>   	done
>   
> +	_btrfs_kill_stress_scrub_pid $scrub_pid
> +
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
>   	if [ $? -ne 0 ]; then
> diff --git a/tests/btrfs/073 b/tests/btrfs/073
> index b1604f94..49a4abd1 100755
> --- a/tests/btrfs/073
> +++ b/tests/btrfs/073
> @@ -51,16 +51,15 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $scrub_pid $remount_pid
> -	wait
> -	# wait for the scrub and remount operations to finish
> -	while ps aux | grep "scrub start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	kill $remount_pid
> +	wait $remount_pid
> +	# wait for the remount operation to finish
>   	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>   		sleep 1
>   	done
>   
> +	_btrfs_kill_stress_scrub_pid $scrub_pid
> +
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
>   	if [ $? -ne 0 ]; then


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid
  2024-03-27 17:11 ` [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid fdmanana
@ 2024-03-28  8:41   ` Anand Jain
  2024-03-28  9:25     ` Filipe Manana
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28  8:41 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Now that there's a helper to kill a background process that is running
> _btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the
> existing code in btrfs/028.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>   tests/btrfs/028 | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/btrfs/028 b/tests/btrfs/028
> index d860974e..8fbe8887 100755
> --- a/tests/btrfs/028
> +++ b/tests/btrfs/028
> @@ -44,12 +44,9 @@ balance_pid=$!
>   
>   # 30s is enough to trigger bug
>   sleep $((30*$TIME_FACTOR))
> -kill $fsstress_pid $balance_pid &> /dev/null
> -wait
> -
> -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel
> -# to cancel running or paused balance. > -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
> +kill $fsstress_pid &> /dev/null
> +wait $fsstress_pid &> /dev/null
> +_btrfs_kill_stress_balance_pid $balance_pid

  I didn't understand the point of replacing 'balance cancel'
  with 'kill'. The Git change log also doesn't say anything
  about it. The old code also tested BTRFS_IOC_BALANCE_CTL ioctl.

Thanks, Anand


>   _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
>   


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag
  2024-03-27 17:11 ` [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag fdmanana
@ 2024-03-28  9:18   ` Anand Jain
  2024-03-28  9:32     ` Filipe Manana
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:18 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Killing a background process running _btrfs_stress_defrag() is not as
> simple as sending a signal to the process and waiting for it to die.
> Therefore we have the following logic to terminate such process:
> 
>         kill $pid
>         wait $pid
>         while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
>             sleep 1
>         done
> 
> Since this is repeated in several test cases, move this logic to a common
> helper and use it in all affected test cases. This will help to avoid
> repeating the same code again several times in upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>   common/btrfs    | 14 ++++++++++++++
>   tests/btrfs/062 |  7 +------
>   tests/btrfs/067 |  8 ++------
>   tests/btrfs/070 | 11 +++++------
>   tests/btrfs/072 |  7 +------
>   tests/btrfs/074 | 11 +++++------
>   6 files changed, 28 insertions(+), 30 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index d0adeea1..46056d4a 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -383,6 +383,20 @@ _btrfs_stress_defrag()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_defrag()
> +_btrfs_kill_stress_defrag_pid()
> +{
> +       local defrag_pid=$1
> +
> +       # Ignore if process already died.
> +       kill $defrag_pid &> /dev/null
> +       wait $defrag_pid &> /dev/null
> +       # Wait for the defrag operation to finish.
> +       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do

The same comments apply here regarding the use of pgrep.

Looks good.
Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand

> +               sleep 1
> +       done
> +}
> +
>   # stress btrfs by remounting it with different compression algorithms in a loop
>   # run this with fsstress running at background could exercise the compression
>   # code path and ensure no race when switching compression algorithm with constant
> diff --git a/tests/btrfs/062 b/tests/btrfs/062
> index a2639d6c..59d581be 100755
> --- a/tests/btrfs/062
> +++ b/tests/btrfs/062
> @@ -53,12 +53,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> -	kill $defrag_pid
> -	wait $defrag_pid
> -	# wait for the defrag operation to finish
> -	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_defrag_pid $defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/067 b/tests/btrfs/067
> index 709db155..2bb00b87 100755
> --- a/tests/btrfs/067
> +++ b/tests/btrfs/067
> @@ -58,12 +58,8 @@ run_test()
>   	wait $fsstress_pid
>   
>   	touch $stop_file
> -	kill $defrag_pid
> -	wait
> -	# wait for btrfs defrag process to exit, otherwise it will block umount
> -	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> -		sleep 1
> -	done
> +	wait $subvol_pid
> +	_btrfs_kill_stress_defrag_pid $defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/070 b/tests/btrfs/070
> index 54aa275c..cefa5723 100755
> --- a/tests/btrfs/070
> +++ b/tests/btrfs/070
> @@ -60,17 +60,16 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $replace_pid $defrag_pid
> -	wait
> +	kill $replace_pid
> +	wait $replace_pid
>   
> -	# wait for the defrag and replace operations to finish
> -	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> -		sleep 1
> -	done
> +	# wait for the replace operation to finish
>   	while ps aux | grep "replace start" | grep -qv grep; do
>   		sleep 1
>   	done
>   
> +	_btrfs_kill_stress_defrag_pid $defrag_pid
> +
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
>   	if [ $? -ne 0 ]; then
> diff --git a/tests/btrfs/072 b/tests/btrfs/072
> index 6c15b51f..505d0b57 100755
> --- a/tests/btrfs/072
> +++ b/tests/btrfs/072
> @@ -52,13 +52,8 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $defrag_pid
> -	wait $defrag_pid
> -	# wait for the defrag operation to finish
> -	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> -		sleep 1
> -	done
>   
> +	_btrfs_kill_stress_defrag_pid $defrag_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/074 b/tests/btrfs/074
> index 9b22c620..d51922d0 100755
> --- a/tests/btrfs/074
> +++ b/tests/btrfs/074
> @@ -52,16 +52,15 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $defrag_pid $remount_pid
> -	wait
> -	# wait for the defrag and remount operations to finish
> -	while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> -		sleep 1
> -	done
> +	kill $remount_pid
> +	wait $remount_pid
> +	# wait for the remount operation to finish
>   	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>   		sleep 1
>   	done
>   
> +	_btrfs_kill_stress_defrag_pid $defrag_pid
> +
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
>   	if [ $? -ne 0 ]; then


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance
  2024-03-28  8:16   ` Anand Jain
@ 2024-03-28  9:21     ` Filipe Manana
  0 siblings, 0 replies; 27+ messages in thread
From: Filipe Manana @ 2024-03-28  9:21 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Mar 28, 2024 at 8:17 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> On 3/28/24 01:11, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > Killing a background process running _btrfs_stress_balance() is not as
> > simple as sending a signal to the process and waiting for it to die.
> > Therefore we have the following logic to terminate such process:
> >
> >     kill $pid
> >     wait $pid
> >     # Wait for the balance operation to finish.
> >     while ps aux | grep "balance start" | grep -qv grep; do
>
>
> >         sleep 1
> >     done
> >
> > Since this is repeated in several test cases, move this logic to a common
> > helper and use it in all affected test cases. This will help to avoid
> > repeating the same code again several times in upcoming changes.
> >
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
>
> Reviewed-by: Anand Jain <anand.jain@oracle.com>
>
> A few minor things below.
>
> > ---
> >   common/btrfs    | 14 ++++++++++++++
> >   tests/btrfs/060 |  8 ++------
> >   tests/btrfs/061 | 10 ++++------
> >   tests/btrfs/062 | 10 ++++------
> >   tests/btrfs/063 | 10 ++++------
> >   tests/btrfs/064 | 10 ++++------
> >   tests/btrfs/255 |  8 ++------
> >   7 files changed, 34 insertions(+), 36 deletions(-)
> >
> > diff --git a/common/btrfs b/common/btrfs
> > index aa344706..e95cff7f 100644
> > --- a/common/btrfs
> > +++ b/common/btrfs
> > @@ -308,6 +308,20 @@ _btrfs_stress_balance()
> >       done
> >   }
> >
> > +# Kill a background process running _btrfs_stress_balance()
> > +_btrfs_kill_stress_balance_pid()
> > +{
> > +     local balance_pid=$1
> > +
> > +     # Ignore if process already died.
> > +     kill $balance_pid &> /dev/null
> > +     wait $balance_pid &> /dev/null
> > +     # Wait for the balance operation to finish.
> > +     while ps aux | grep "balance start" | grep -qv grep; do
>
>
>   We can use pgrep instead. I will make the following changes before
>   merging if you are okay with it.

Not doing such a change was intentional, as the goal is just to move
repeated code into a helper.
I would prefer for such change to be done separately in its own patch.

>
> -       while ps aux | grep "balance start" | grep -qv grep; do
> +       while pgrep -f "btrfs balance start" > /dev/null; do
>
>
>
> > +             sleep 1
> > +     done
> > +}
> > +
> >   # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop
> >   _btrfs_stress_subvolume()
> >   {
> > diff --git a/tests/btrfs/060 b/tests/btrfs/060
> > index a0184891..58167cc6 100755
> > --- a/tests/btrfs/060
> > +++ b/tests/btrfs/060
> > @@ -57,12 +57,8 @@ run_test()
> >       wait $fsstress_pid
> >
> >       touch $stop_file
> > -     kill $balance_pid
> > -     wait
> > -     # wait for the balance operation to finish
> > -     while ps aux | grep "balance start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     wait $subvol_pid
> > +     _btrfs_kill_stress_balance_pid $balance_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> > diff --git a/tests/btrfs/061 b/tests/btrfs/061
> > index c1010413..d0b55e48 100755
> > --- a/tests/btrfs/061
> > +++ b/tests/btrfs/061
> > @@ -51,12 +51,10 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $balance_pid $scrub_pid
> > -     wait
> > -     # wait for the balance and scrub operations to finish
> > -     while ps aux | grep "balance start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_balance_pid $balance_pid
> > +     kill $scrub_pid
> > +     wait $scrub_pid
> > +     # wait for the crub operation to finish
>
> s/crub/scrub/

Yeah, but the comment is going away in the patch that adds the helper
to kill scrub.

Thanks.

>
> Thanks, Anand
>
> >       while ps aux | grep "scrub start" | grep -qv grep; do
> >               sleep 1
> >       done
> > diff --git a/tests/btrfs/062 b/tests/btrfs/062
> > index 818a0156..a2639d6c 100755
> > --- a/tests/btrfs/062
> > +++ b/tests/btrfs/062
> > @@ -52,12 +52,10 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $balance_pid $defrag_pid
> > -     wait
> > -     # wait for the balance and defrag operations to finish
> > -     while ps aux | grep "balance start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_balance_pid $balance_pid
> > +     kill $defrag_pid
> > +     wait $defrag_pid
> > +     # wait for the defrag operation to finish
> >       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> >               sleep 1
> >       done
> > diff --git a/tests/btrfs/063 b/tests/btrfs/063
> > index 2f771baf..baf0c356 100755
> > --- a/tests/btrfs/063
> > +++ b/tests/btrfs/063
> > @@ -51,12 +51,10 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $balance_pid $remount_pid
> > -     wait
> > -     # wait for the balance and remount loop to finish
> > -     while ps aux | grep "balance start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_balance_pid $balance_pid
> > +     kill $remount_pid
> > +     wait $remount_pid
> > +     # wait for the remount loop to finish
> >       while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> >               sleep 1
> >       done
> > diff --git a/tests/btrfs/064 b/tests/btrfs/064
> > index e9b46ce6..58b53afe 100755
> > --- a/tests/btrfs/064
> > +++ b/tests/btrfs/064
> > @@ -63,12 +63,10 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $balance_pid $replace_pid
> > -     wait
> > -     # wait for the balance and replace operations to finish
> > -     while ps aux | grep "balance start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_balance_pid $balance_pid
> > +     kill $replace_pid
> > +     wait $replace_pid
> > +     # wait for the replace operation to finish
> >       while ps aux | grep "replace start" | grep -qv grep; do
> >               sleep 1
> >       done
> > diff --git a/tests/btrfs/255 b/tests/btrfs/255
> > index 7e70944a..aa250467 100755
> > --- a/tests/btrfs/255
> > +++ b/tests/btrfs/255
> > @@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do
> >       $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
> >       $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
> >   done
> > -kill $balance_pid &> /dev/null
> > -wait
> > -# wait for the balance operation to finish
> > -while ps aux | grep "balance start" | grep -qv grep; do
> > -     sleep 1
> > -done
> > +
> > +_btrfs_kill_stress_balance_pid $balance_pid
> >
> >   echo "Silence is golden"
> >   status=0
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  2024-03-27 17:11 ` [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress fdmanana
@ 2024-03-28  9:24   ` Anand Jain
  2024-03-28 11:46     ` Anand Jain
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:24 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Killing a background process running _btrfs_stress_remount_compress() is
> not as simple as sending a signal to the process and waiting for it to
> die. Therefore we have the following logic to terminate such process:
> 
>      kill $pid
>      wait $pid
>      while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>          sleep 1
>      done
> 
> Since this is repeated in several test cases, move this logic to a common
> helper and use it in all affected test cases. This will help to avoid
> repeating the same code again several times in upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>


Thanks, Anand

> ---
>   common/btrfs    | 15 +++++++++++++++
>   tests/btrfs/063 |  7 +------
>   tests/btrfs/068 |  8 ++------
>   tests/btrfs/071 | 12 +++++-------
>   tests/btrfs/073 |  8 +-------
>   tests/btrfs/074 |  8 +-------
>   6 files changed, 25 insertions(+), 33 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index 46056d4a..66a3a347 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -411,6 +411,21 @@ _btrfs_stress_remount_compress()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_remount_compress()
> +_btrfs_kill_stress_remount_compress_pid()
> +{
> +	local remount_pid=$1
> +	local btrfs_mnt=$2
> +
> +	# Ignore if process already died.
> +	kill $remount_pid &> /dev/null
> +	wait $remount_pid &> /dev/null
> +	# Wait for the remount loop to finish.
> +	while ps aux | grep "mount.*${btrfs_mnt}" | grep -qv grep; do
> +		sleep 1
> +	done
> +}
> +
>   # stress btrfs by replacing devices in a loop
>   # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last
>   # device should be free(not used by btrfs)
> diff --git a/tests/btrfs/063 b/tests/btrfs/063
> index baf0c356..5ee2837f 100755
> --- a/tests/btrfs/063
> +++ b/tests/btrfs/063
> @@ -52,12 +52,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> -	kill $remount_pid
> -	wait $remount_pid
> -	# wait for the remount loop to finish
> -	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/068 b/tests/btrfs/068
> index 15fd41db..db53254a 100755
> --- a/tests/btrfs/068
> +++ b/tests/btrfs/068
> @@ -58,12 +58,8 @@ run_test()
>   	wait $fsstress_pid
>   
>   	touch $stop_file
> -	kill $remount_pid
> -	wait
> -	# wait for the remount loop process to finish
> -	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> -		sleep 1
> -	done
> +	wait $subvol_pid
> +	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/071 b/tests/btrfs/071
> index 6ebbd8cc..7ba15390 100755
> --- a/tests/btrfs/071
> +++ b/tests/btrfs/071
> @@ -58,17 +58,15 @@ run_test()
>   	echo "$remount_pid" >>$seqres.full
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> -	wait $fsstress_pid
> -	kill $replace_pid $remount_pid
> -	wait
> +	kill $replace_pid
> +	wait $fsstress_pid $replace_pid
>   
> -	# wait for the remount and replace operations to finish
> +	# wait for the replace operationss to finish
>   	while ps aux | grep "replace start" | grep -qv grep; do
>   		sleep 1
>   	done
> -	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> -		sleep 1
> -	done
> +
> +	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/073 b/tests/btrfs/073
> index 49a4abd1..50358286 100755
> --- a/tests/btrfs/073
> +++ b/tests/btrfs/073
> @@ -51,13 +51,7 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $remount_pid
> -	wait $remount_pid
> -	# wait for the remount operation to finish
> -	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> -		sleep 1
> -	done
> -
> +	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/074 b/tests/btrfs/074
> index d51922d0..6e93b36a 100755
> --- a/tests/btrfs/074
> +++ b/tests/btrfs/074
> @@ -52,13 +52,7 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $remount_pid
> -	wait $remount_pid
> -	# wait for the remount operation to finish
> -	while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> -		sleep 1
> -	done
> -
> +	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid
  2024-03-28  8:41   ` Anand Jain
@ 2024-03-28  9:25     ` Filipe Manana
  0 siblings, 0 replies; 27+ messages in thread
From: Filipe Manana @ 2024-03-28  9:25 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Mar 28, 2024 at 8:41 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> On 3/28/24 01:11, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > Now that there's a helper to kill a background process that is running
> > _btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the
> > existing code in btrfs/028.
> >
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> > ---
> >   tests/btrfs/028 | 9 +++------
> >   1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/tests/btrfs/028 b/tests/btrfs/028
> > index d860974e..8fbe8887 100755
> > --- a/tests/btrfs/028
> > +++ b/tests/btrfs/028
> > @@ -44,12 +44,9 @@ balance_pid=$!
> >
> >   # 30s is enough to trigger bug
> >   sleep $((30*$TIME_FACTOR))
> > -kill $fsstress_pid $balance_pid &> /dev/null
> > -wait
> > -
> > -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel
> > -# to cancel running or paused balance. > -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
> > +kill $fsstress_pid &> /dev/null
> > +wait $fsstress_pid &> /dev/null
> > +_btrfs_kill_stress_balance_pid $balance_pid
>
>   I didn't understand the point of replacing 'balance cancel'
>   with 'kill'. The Git change log also doesn't say anything
>   about it. The old code also tested BTRFS_IOC_BALANCE_CTL ioctl.

The point is to use the helper to kill the background task running
balance in a loop, so for every _btrfs_stress_balance() call we have a
matching _btrfs_kill_stress_balance_pid().

Doing the kill + cancel is equivalent to what the helper does, and the
goal of the test is not to exercise the balance cancel.

Thanks.


>
> Thanks, Anand
>
>
> >   _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
> >
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub
  2024-03-28  8:41   ` Anand Jain
@ 2024-03-28  9:27     ` Filipe Manana
  0 siblings, 0 replies; 27+ messages in thread
From: Filipe Manana @ 2024-03-28  9:27 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Mar 28, 2024 at 8:41 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> On 3/28/24 01:11, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > Killing a background process running _btrfs_stress_scrub() is not as
> > simple as sending a signal to the process and waiting for it to die.
> > Therefore we have the following logic to terminate such process:
> >
> >     kill $pid
> >     wait $pid
> >     while ps aux | grep "scrub start" | grep -qv grep; do
> >         sleep 1
> >     done
> >
> > Since this is repeated in several test cases, move this logic to a common
> > helper and use it in all affected test cases. This will help to avoid
> > repeating the same code again several times in upcoming changes.
> >
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> > ---
> >   common/btrfs    | 14 ++++++++++++++
> >   tests/btrfs/061 |  7 +------
> >   tests/btrfs/066 |  8 ++------
> >   tests/btrfs/069 | 11 +++++------
> >   tests/btrfs/072 | 11 +++++------
> >   tests/btrfs/073 | 11 +++++------
> >   6 files changed, 32 insertions(+), 30 deletions(-)
> >
> > diff --git a/common/btrfs b/common/btrfs
> > index e95cff7f..d0adeea1 100644
> > --- a/common/btrfs
> > +++ b/common/btrfs
> > @@ -349,6 +349,20 @@ _btrfs_stress_scrub()
> >       done
> >   }
> >
> > +# Kill a background process running _btrfs_stress_scrub()
> > +_btrfs_kill_stress_scrub_pid()
> > +{
> > +       local scrub_pid=$1
> > +
> > +       # Ignore if process already died.
> > +       kill $scrub_pid &> /dev/null
> > +       wait $scrub_pid &> /dev/null
> > +       # Wait for the scrub operation to finish.
>
>
> > +       while ps aux | grep "scrub start" | grep -qv grep; do
>
> This can be replaced by pgrep. I'll make the change if there are
> no objections.

Yes, but as previously pointed out, the goal of the patch is just to
move repeated code into a helper function.
I would prefer such a change to be done separately.

Thanks.

>
>        while pgrep -f "btrfs scrub start" > /dev/null; do
>
> Thanks, Anand
>
> > +               sleep 1
> > +       done
> > +}
> > +
> >   # stress btrfs by defragmenting every file/dir in a loop and compress file
> >   # contents while defragmenting if second argument is not "nocompress"
> >   _btrfs_stress_defrag()
> > diff --git a/tests/btrfs/061 b/tests/btrfs/061
> > index d0b55e48..b8b2706c 100755
> > --- a/tests/btrfs/061
> > +++ b/tests/btrfs/061
> > @@ -52,12 +52,7 @@ run_test()
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> >       _btrfs_kill_stress_balance_pid $balance_pid
> > -     kill $scrub_pid
> > -     wait $scrub_pid
> > -     # wait for the crub operation to finish
> > -     while ps aux | grep "scrub start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_scrub_pid $scrub_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> > diff --git a/tests/btrfs/066 b/tests/btrfs/066
> > index a29034bb..29821fdd 100755
> > --- a/tests/btrfs/066
> > +++ b/tests/btrfs/066
> > @@ -57,12 +57,8 @@ run_test()
> >       wait $fsstress_pid
> >
> >       touch $stop_file
> > -     kill $scrub_pid
> > -     wait
> > -     # wait for the scrub operation to finish
> > -     while ps aux | grep "scrub start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     wait $subvol_pid
> > +     _btrfs_kill_stress_scrub_pid $scrub_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> > diff --git a/tests/btrfs/069 b/tests/btrfs/069
> > index 139dde48..20f44b39 100755
> > --- a/tests/btrfs/069
> > +++ b/tests/btrfs/069
> > @@ -59,17 +59,16 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $replace_pid $scrub_pid
> > -     wait
> > +     kill $replace_pid
> > +     wait $replace_pid
> >
> > -     # wait for the scrub and replace operations to finish
> > -     while ps aux | grep "scrub start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     # wait for the replace operation to finish
> >       while ps aux | grep "replace start" | grep -qv grep; do
> >               sleep 1
> >       done
> >
> > +     _btrfs_kill_stress_scrub_pid $scrub_pid
> > +
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> >       if [ $? -ne 0 ]; then
> > diff --git a/tests/btrfs/072 b/tests/btrfs/072
> > index 4b6b6fb5..6c15b51f 100755
> > --- a/tests/btrfs/072
> > +++ b/tests/btrfs/072
> > @@ -52,16 +52,15 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $scrub_pid $defrag_pid
> > -     wait
> > -     # wait for the scrub and defrag operations to finish
> > -     while ps aux | grep "scrub start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     kill $defrag_pid
> > +     wait $defrag_pid
> > +     # wait for the defrag operation to finish
> >       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> >               sleep 1
> >       done
> >
> > +     _btrfs_kill_stress_scrub_pid $scrub_pid
> > +
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> >       if [ $? -ne 0 ]; then
> > diff --git a/tests/btrfs/073 b/tests/btrfs/073
> > index b1604f94..49a4abd1 100755
> > --- a/tests/btrfs/073
> > +++ b/tests/btrfs/073
> > @@ -51,16 +51,15 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $scrub_pid $remount_pid
> > -     wait
> > -     # wait for the scrub and remount operations to finish
> > -     while ps aux | grep "scrub start" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     kill $remount_pid
> > +     wait $remount_pid
> > +     # wait for the remount operation to finish
> >       while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> >               sleep 1
> >       done
> >
> > +     _btrfs_kill_stress_scrub_pid $scrub_pid
> > +
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> >       if [ $? -ne 0 ]; then
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag
  2024-03-28  9:18   ` Anand Jain
@ 2024-03-28  9:32     ` Filipe Manana
  0 siblings, 0 replies; 27+ messages in thread
From: Filipe Manana @ 2024-03-28  9:32 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Mar 28, 2024 at 9:19 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> On 3/28/24 01:11, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > Killing a background process running _btrfs_stress_defrag() is not as
> > simple as sending a signal to the process and waiting for it to die.
> > Therefore we have the following logic to terminate such process:
> >
> >         kill $pid
> >         wait $pid
> >         while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> >             sleep 1
> >         done
> >
> > Since this is repeated in several test cases, move this logic to a common
> > helper and use it in all affected test cases. This will help to avoid
> > repeating the same code again several times in upcoming changes.
> >
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> > ---
> >   common/btrfs    | 14 ++++++++++++++
> >   tests/btrfs/062 |  7 +------
> >   tests/btrfs/067 |  8 ++------
> >   tests/btrfs/070 | 11 +++++------
> >   tests/btrfs/072 |  7 +------
> >   tests/btrfs/074 | 11 +++++------
> >   6 files changed, 28 insertions(+), 30 deletions(-)
> >
> > diff --git a/common/btrfs b/common/btrfs
> > index d0adeea1..46056d4a 100644
> > --- a/common/btrfs
> > +++ b/common/btrfs
> > @@ -383,6 +383,20 @@ _btrfs_stress_defrag()
> >       done
> >   }
> >
> > +# Kill a background process running _btrfs_stress_defrag()
> > +_btrfs_kill_stress_defrag_pid()
> > +{
> > +       local defrag_pid=$1
> > +
> > +       # Ignore if process already died.
> > +       kill $defrag_pid &> /dev/null
> > +       wait $defrag_pid &> /dev/null
> > +       # Wait for the defrag operation to finish.
> > +       while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
>
> The same comments apply here regarding the use of pgrep.

Yes, but as previously pointed out, the goal of the patch is just to
move repeated code into a helper function.
I would prefer such a change to be done separately.

Thanks.

>
> Looks good.
> Reviewed-by: Anand Jain <anand.jain@oracle.com>
>
> Thanks, Anand
>
> > +               sleep 1
> > +       done
> > +}
> > +
> >   # stress btrfs by remounting it with different compression algorithms in a loop
> >   # run this with fsstress running at background could exercise the compression
> >   # code path and ensure no race when switching compression algorithm with constant
> > diff --git a/tests/btrfs/062 b/tests/btrfs/062
> > index a2639d6c..59d581be 100755
> > --- a/tests/btrfs/062
> > +++ b/tests/btrfs/062
> > @@ -53,12 +53,7 @@ run_test()
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> >       _btrfs_kill_stress_balance_pid $balance_pid
> > -     kill $defrag_pid
> > -     wait $defrag_pid
> > -     # wait for the defrag operation to finish
> > -     while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     _btrfs_kill_stress_defrag_pid $defrag_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> > diff --git a/tests/btrfs/067 b/tests/btrfs/067
> > index 709db155..2bb00b87 100755
> > --- a/tests/btrfs/067
> > +++ b/tests/btrfs/067
> > @@ -58,12 +58,8 @@ run_test()
> >       wait $fsstress_pid
> >
> >       touch $stop_file
> > -     kill $defrag_pid
> > -     wait
> > -     # wait for btrfs defrag process to exit, otherwise it will block umount
> > -     while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     wait $subvol_pid
> > +     _btrfs_kill_stress_defrag_pid $defrag_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> > diff --git a/tests/btrfs/070 b/tests/btrfs/070
> > index 54aa275c..cefa5723 100755
> > --- a/tests/btrfs/070
> > +++ b/tests/btrfs/070
> > @@ -60,17 +60,16 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $replace_pid $defrag_pid
> > -     wait
> > +     kill $replace_pid
> > +     wait $replace_pid
> >
> > -     # wait for the defrag and replace operations to finish
> > -     while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     # wait for the replace operation to finish
> >       while ps aux | grep "replace start" | grep -qv grep; do
> >               sleep 1
> >       done
> >
> > +     _btrfs_kill_stress_defrag_pid $defrag_pid
> > +
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> >       if [ $? -ne 0 ]; then
> > diff --git a/tests/btrfs/072 b/tests/btrfs/072
> > index 6c15b51f..505d0b57 100755
> > --- a/tests/btrfs/072
> > +++ b/tests/btrfs/072
> > @@ -52,13 +52,8 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $defrag_pid
> > -     wait $defrag_pid
> > -     # wait for the defrag operation to finish
> > -     while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> > -             sleep 1
> > -     done
> >
> > +     _btrfs_kill_stress_defrag_pid $defrag_pid
> >       _btrfs_kill_stress_scrub_pid $scrub_pid
> >
> >       echo "Scrub the filesystem" >>$seqres.full
> > diff --git a/tests/btrfs/074 b/tests/btrfs/074
> > index 9b22c620..d51922d0 100755
> > --- a/tests/btrfs/074
> > +++ b/tests/btrfs/074
> > @@ -52,16 +52,15 @@ run_test()
> >
> >       echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> >       wait $fsstress_pid
> > -     kill $defrag_pid $remount_pid
> > -     wait
> > -     # wait for the defrag and remount operations to finish
> > -     while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
> > -             sleep 1
> > -     done
> > +     kill $remount_pid
> > +     wait $remount_pid
> > +     # wait for the remount operation to finish
> >       while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> >               sleep 1
> >       done
> >
> > +     _btrfs_kill_stress_defrag_pid $defrag_pid
> > +
> >       echo "Scrub the filesystem" >>$seqres.full
> >       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> >       if [ $? -ne 0 ]; then
>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace
  2024-03-27 17:11 ` [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace fdmanana
@ 2024-03-28  9:35   ` Anand Jain
  0 siblings, 0 replies; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:35 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Killing a background process running _btrfs_stress_replace() is not as
> simple as sending a signal to the process and waiting for it to die.
> Therefore we have the following logic to terminate such process:
> 
>     kill $pid
>     wait $pid
>     while ps aux | grep "replace start" | grep -qv grep; do
>        sleep 1
>     done
> 
> Since this is repeated in several test cases, move this logic to a common
> helper and use it in all affected test cases. This will help to avoid
> repeating the same code again several times in upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>


Thanks, Anand

> ---
>   common/btrfs    | 14 ++++++++++++++
>   tests/btrfs/064 |  7 +------
>   tests/btrfs/065 |  8 ++------
>   tests/btrfs/069 |  9 +--------
>   tests/btrfs/070 |  9 +--------
>   tests/btrfs/071 | 10 ++--------
>   6 files changed, 21 insertions(+), 36 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index 66a3a347..6d7e7a68 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -475,6 +475,20 @@ _btrfs_stress_replace()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_replace()
> +_btrfs_kill_stress_replace_pid()
> +{
> +       local replace_pid=$1
> +
> +       # Ignore if process already died.
> +       kill $replace_pid &> /dev/null
> +       wait $replace_pid &> /dev/null
> +       # Wait for the replace operation to finish.
> +       while ps aux | grep "replace start" | grep -qv grep; do
> +               sleep 1
> +       done
> +}
> +
>   # find the right option to force output in bytes, older versions of btrfs-progs
>   # print that by default, newer print human readable numbers with unit suffix
>   _btrfs_qgroup_units()
> diff --git a/tests/btrfs/064 b/tests/btrfs/064
> index 58b53afe..9e0b3b30 100755
> --- a/tests/btrfs/064
> +++ b/tests/btrfs/064
> @@ -64,12 +64,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> -	kill $replace_pid
> -	wait $replace_pid
> -	# wait for the replace operation to finish
> -	while ps aux | grep "replace start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	_btrfs_kill_stress_replace_pid $replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/065 b/tests/btrfs/065
> index c4b6aafe..d2b04178 100755
> --- a/tests/btrfs/065
> +++ b/tests/btrfs/065
> @@ -65,12 +65,8 @@ run_test()
>   	wait $fsstress_pid
>   
>   	touch $stop_file
> -	kill $replace_pid
> -	wait
> -	# wait for the replace operation to finish
> -	while ps aux | grep "replace start" | grep -qv grep; do
> -		sleep 1
> -	done
> +	wait $subvol_pid
> +	_btrfs_kill_stress_replace_pid $replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/069 b/tests/btrfs/069
> index 20f44b39..ad1609d4 100755
> --- a/tests/btrfs/069
> +++ b/tests/btrfs/069
> @@ -59,15 +59,8 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $replace_pid
> -	wait $replace_pid
> -
> -	# wait for the replace operation to finish
> -	while ps aux | grep "replace start" | grep -qv grep; do
> -		sleep 1
> -	done
> -
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	_btrfs_kill_stress_replace_pid $replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/070 b/tests/btrfs/070
> index cefa5723..3054c270 100755
> --- a/tests/btrfs/070
> +++ b/tests/btrfs/070
> @@ -60,14 +60,7 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> -	kill $replace_pid
> -	wait $replace_pid
> -
> -	# wait for the replace operation to finish
> -	while ps aux | grep "replace start" | grep -qv grep; do
> -		sleep 1
> -	done
> -
> +	_btrfs_kill_stress_replace_pid $replace_pid
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/071 b/tests/btrfs/071
> index 7ba15390..36b39341 100755
> --- a/tests/btrfs/071
> +++ b/tests/btrfs/071
> @@ -58,14 +58,8 @@ run_test()
>   	echo "$remount_pid" >>$seqres.full
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
> -	kill $replace_pid
> -	wait $fsstress_pid $replace_pid
> -
> -	# wait for the replace operationss to finish
> -	while ps aux | grep "replace start" | grep -qv grep; do
> -		sleep 1
> -	done
> -
> +	wait $fsstress_pid
> +	_btrfs_kill_stress_replace_pid $replace_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   
>   	echo "Scrub the filesystem" >>$seqres.full


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume
  2024-03-27 17:11 ` [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume fdmanana
@ 2024-03-28  9:36   ` Anand Jain
  0 siblings, 0 replies; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:36 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We have this logic to stop a process running _btrfs_stress_subvolume()
> spread in several test cases:
> 
>     touch $stop_file
>     wait $subvol_pid
> 
> Add a helper to encapsulate that logic and also remove the stop file after
> the process terminated as there's no point having it around anymore.
> 
> This will help to avoid repeating the same code again several times in
> upcoming changes.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand

> ---
>   common/btrfs    | 12 ++++++++++++
>   tests/btrfs/060 |  3 +--
>   tests/btrfs/065 |  3 +--
>   tests/btrfs/066 |  3 +--
>   tests/btrfs/067 |  3 +--
>   tests/btrfs/068 |  3 +--
>   6 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index 6d7e7a68..e19a6ad1 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -340,6 +340,18 @@ _btrfs_stress_subvolume()
>   	done
>   }
>   
> +# Kill a background process running _btrfs_stress_subvolume()
> +_btrfs_kill_stress_subvolume_pid()
> +{
> +	local subvol_pid=$1
> +	local stop_file=$2
> +
> +	touch $stop_file
> +	# Ignore if process already died.
> +	wait $subvol_pid &> /dev/null
> +	rm -f $stop_file
> +}
> +
>   # stress btrfs by running scrub in a loop
>   _btrfs_stress_scrub()
>   {
> diff --git a/tests/btrfs/060 b/tests/btrfs/060
> index 58167cc6..87823aba 100755
> --- a/tests/btrfs/060
> +++ b/tests/btrfs/060
> @@ -56,8 +56,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   
> -	touch $stop_file
> -	wait $subvol_pid
> +	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
>   	_btrfs_kill_stress_balance_pid $balance_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/065 b/tests/btrfs/065
> index d2b04178..ddc28616 100755
> --- a/tests/btrfs/065
> +++ b/tests/btrfs/065
> @@ -64,8 +64,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   
> -	touch $stop_file
> -	wait $subvol_pid
> +	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
>   	_btrfs_kill_stress_replace_pid $replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/066 b/tests/btrfs/066
> index 29821fdd..c7488602 100755
> --- a/tests/btrfs/066
> +++ b/tests/btrfs/066
> @@ -56,8 +56,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   
> -	touch $stop_file
> -	wait $subvol_pid
> +	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/067 b/tests/btrfs/067
> index 2bb00b87..ebbec1be 100755
> --- a/tests/btrfs/067
> +++ b/tests/btrfs/067
> @@ -57,8 +57,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   
> -	touch $stop_file
> -	wait $subvol_pid
> +	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
> diff --git a/tests/btrfs/068 b/tests/btrfs/068
> index db53254a..5f41fb74 100755
> --- a/tests/btrfs/068
> +++ b/tests/btrfs/068
> @@ -57,8 +57,7 @@ run_test()
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
>   
> -	touch $stop_file
> -	wait $subvol_pid
> +	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>   
>   	echo "Scrub the filesystem" >>$seqres.full


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume
  2024-03-27 17:11 ` [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume fdmanana
@ 2024-03-28  9:38   ` Anand Jain
  0 siblings, 0 replies; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:38 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Instead of having every test case that uses _btrfs_stress_subvolume()
> removing the stop file before calling that function, do the file
> remove at _btrfs_stress_subvolume(). There's no point in doing it in
> every single test case.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>


Thanks Anand

> ---
>   common/btrfs    | 1 +
>   tests/btrfs/060 | 2 --
>   tests/btrfs/065 | 2 --
>   tests/btrfs/066 | 2 --
>   tests/btrfs/067 | 2 --
>   tests/btrfs/068 | 2 --
>   6 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index e19a6ad1..29061c23 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -331,6 +331,7 @@ _btrfs_stress_subvolume()
>   	local subvol_mnt=$4
>   	local stop_file=$5
>   
> +	rm -f $stop_file
>   	mkdir -p $subvol_mnt
>   	while [ ! -e $stop_file ]; do
>   		$BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
> diff --git a/tests/btrfs/060 b/tests/btrfs/060
> index 87823aba..53cbd3a0 100755
> --- a/tests/btrfs/060
> +++ b/tests/btrfs/060
> @@ -46,8 +46,6 @@ run_test()
>   	balance_pid=$!
>   	echo "$balance_pid" >>$seqres.full
>   
> -	# make sure the stop sign is not there
> -	rm -f $stop_file
>   	echo -n "Start subvolume worker: " >>$seqres.full
>   	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
>   	subvol_pid=$!
> diff --git a/tests/btrfs/065 b/tests/btrfs/065
> index ddc28616..f9e43cdc 100755
> --- a/tests/btrfs/065
> +++ b/tests/btrfs/065
> @@ -49,8 +49,6 @@ run_test()
>   	$FSSTRESS_PROG $args >>$seqres.full &
>   	fsstress_pid=$!
>   
> -	# make sure the stop sign is not there
> -	rm -f $stop_file
>   	echo -n "Start subvolume worker: " >>$seqres.full
>   	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
>   	subvol_pid=$!
> diff --git a/tests/btrfs/066 b/tests/btrfs/066
> index c7488602..b6f904ac 100755
> --- a/tests/btrfs/066
> +++ b/tests/btrfs/066
> @@ -41,8 +41,6 @@ run_test()
>   	$FSSTRESS_PROG $args >>$seqres.full &
>   	fsstress_pid=$!
>   
> -	# make sure the stop sign is not there
> -	rm -f $stop_file
>   	echo -n "Start subvolume worker: " >>$seqres.full
>   	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
>   	subvol_pid=$!
> diff --git a/tests/btrfs/067 b/tests/btrfs/067
> index ebbec1be..7be09d52 100755
> --- a/tests/btrfs/067
> +++ b/tests/btrfs/067
> @@ -42,8 +42,6 @@ run_test()
>   	$FSSTRESS_PROG $args >>$seqres.full &
>   	fsstress_pid=$!
>   
> -	# make sure the stop sign is not there
> -	rm -f $stop_file
>   	echo -n "Start subvolume worker: " >>$seqres.full
>   	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
>   	subvol_pid=$!
> diff --git a/tests/btrfs/068 b/tests/btrfs/068
> index 5f41fb74..19e37010 100755
> --- a/tests/btrfs/068
> +++ b/tests/btrfs/068
> @@ -42,8 +42,6 @@ run_test()
>   	$FSSTRESS_PROG $args >>$seqres.full &
>   	fsstress_pid=$!
>   
> -	# make sure the stop sign is not there
> -	rm -f $stop_file
>   	echo -n "Start subvolume worker: " >>$seqres.full
>   	_btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
>   	subvol_pid=$!


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
  2024-03-27 17:11 ` [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted fdmanana
@ 2024-03-28  9:48   ` Anand Jain
  0 siblings, 0 replies; 27+ messages in thread
From: Anand Jain @ 2024-03-28  9:48 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana

On 3/28/24 01:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent
> operations while fsstress is running in parallel, and all these are left
> as child processes running in the background, which are correctly stopped
> if the tests are not interrupted/killed. However if any of these tests is
> interrupted/killed, it often leaves child processes still running in the
> background, which prevent further running fstests again. For example:
> 
>    $ /check -g auto
>    (...)
>    btrfs/060 394s ...  264s
>    btrfs/061 83s ...  69s
>    btrfs/062 109s ...  105s
>    btrfs/063 52s ...  67s
>    btrfs/064 53s ...  51s
>    btrfs/065 88s ...  271s
>    btrfs/066 127s ...  241s
>    btrfs/067 435s ...  248s
>    btrfs/068 161s ... ^C^C
>    ^C
> 
>    $ ./check btrfs/068
>    FSTYP         -- btrfs
>    PLATFORM      -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar  4 17:19:19 WET 2024
>    MKFS_OPTIONS  -- /dev/sdb
>    MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1
> 
>    our local _scratch_mkfs routine ...
>    btrfs-progs v6.6.2
>    See https://btrfs.readthedocs.io for more information.
> 
>    ERROR: unable to open /dev/sdb: Device or resource busy
>    check: failed to mkfs $SCRATCH_DEV using specified options
>    Interrupted!
>    Passed all 0 tests
> 
> In this case there was still a process running _btrfs_stress_subvolume()
> from common/btrfs.
> 
> This is a bit annoying because it requires manually finding out which
> process is preventing unmounting the scratch device and then properly
> stop/kill it.
> 
> So fix this by adding a _cleanup() function to all these tests and then
> making sure it stops all the child processes it spawned and are running
> in the background.
> 
> All these tests have the same structure as they were part of the same
> patchset and from the same author.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand

> ---
>   tests/btrfs/060 | 22 +++++++++++++++++++++-
>   tests/btrfs/061 | 19 +++++++++++++++++++
>   tests/btrfs/062 | 19 +++++++++++++++++++
>   tests/btrfs/063 | 19 +++++++++++++++++++
>   tests/btrfs/064 | 19 +++++++++++++++++++
>   tests/btrfs/065 | 22 +++++++++++++++++++++-
>   tests/btrfs/066 | 22 +++++++++++++++++++++-
>   tests/btrfs/067 | 22 +++++++++++++++++++++-
>   tests/btrfs/068 | 22 +++++++++++++++++++++-
>   tests/btrfs/069 | 19 +++++++++++++++++++
>   tests/btrfs/070 | 19 +++++++++++++++++++
>   tests/btrfs/071 | 19 +++++++++++++++++++
>   tests/btrfs/072 | 19 +++++++++++++++++++
>   tests/btrfs/073 | 19 +++++++++++++++++++
>   tests/btrfs/074 | 19 +++++++++++++++++++
>   15 files changed, 295 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/btrfs/060 b/tests/btrfs/060
> index 53cbd3a0..f74d9593 100755
> --- a/tests/btrfs/060
> +++ b/tests/btrfs/060
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto balance subvol scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
> +		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	fi
> +	if [ ! -z "$balance_pid" ]; then
> +		_btrfs_kill_stress_balance_pid $balance_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -20,11 +36,12 @@ _require_scratch_nocheck
>   _require_scratch_dev_pool 4
>   _btrfs_get_profile_configs
>   
> +stop_file=$TEST_DIR/$seq.stop.$$
> +
>   run_test()
>   {
>   	local mkfs_opts=$1
>   	local subvol_mnt=$TEST_DIR/$seq.mnt
> -	local stop_file=$TEST_DIR/$seq.stop.$$
>   
>   	echo "Test $mkfs_opts" >>$seqres.full
>   
> @@ -53,9 +70,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	unset subvol_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> +	unset balance_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/061 b/tests/btrfs/061
> index b8b2706c..fec90882 100755
> --- a/tests/btrfs/061
> +++ b/tests/btrfs/061
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto balance scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$balance_pid" ]; then
> +		_btrfs_kill_stress_balance_pid $balance_pid
> +	fi
> +	if [ ! -z "$scrub_pid" ]; then
> +		_btrfs_kill_stress_scrub_pid $scrub_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -51,8 +67,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> +	unset balance_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	unset scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/062 b/tests/btrfs/062
> index 59d581be..0b57681f 100755
> --- a/tests/btrfs/062
> +++ b/tests/btrfs/062
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto balance defrag compress scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$balance_pid" ]; then
> +		_btrfs_kill_stress_balance_pid $balance_pid
> +	fi
> +	if [ ! -z "$defrag_pid" ]; then
> +		_btrfs_kill_stress_defrag_pid $defrag_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -52,8 +68,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> +	unset balance_pid
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
> +	unset defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/063 b/tests/btrfs/063
> index 5ee2837f..99d9d2c1 100755
> --- a/tests/btrfs/063
> +++ b/tests/btrfs/063
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto balance remount compress scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$balance_pid" ]; then
> +		_btrfs_kill_stress_balance_pid $balance_pid
> +	fi
> +	if [ ! -z "$remount_pid" ]; then
> +		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -51,8 +67,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> +	unset balance_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	unset remount_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/064 b/tests/btrfs/064
> index 9e0b3b30..663442c6 100755
> --- a/tests/btrfs/064
> +++ b/tests/btrfs/064
> @@ -12,6 +12,22 @@
>   . ./common/preamble
>   _begin_fstest auto balance replace volume scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$balance_pid" ]; then
> +		_btrfs_kill_stress_balance_pid $balance_pid
> +	fi
> +	if [ ! -z "$replace_pid" ]; then
> +		_btrfs_kill_stress_replace_pid $replace_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -63,8 +79,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_balance_pid $balance_pid
> +	unset balance_pid
>   	_btrfs_kill_stress_replace_pid $replace_pid
> +	unset replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/065 b/tests/btrfs/065
> index f9e43cdc..b1e54fc8 100755
> --- a/tests/btrfs/065
> +++ b/tests/btrfs/065
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto subvol replace volume scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
> +		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	fi
> +	if [ ! -z "$replace_pid" ]; then
> +		_btrfs_kill_stress_replace_pid $replace_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -21,12 +37,13 @@ _require_scratch_dev_pool 5
>   _require_scratch_dev_pool_equal_size
>   _btrfs_get_profile_configs replace
>   
> +stop_file=$TEST_DIR/$seq.stop.$$
> +
>   run_test()
>   {
>   	local mkfs_opts=$1
>   	local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
>   	local subvol_mnt=$TEST_DIR/$seq.mnt
> -	local stop_file=$TEST_DIR/$seq.stop.$$
>   
>   	echo "Test $mkfs_opts" >>$seqres.full
>   
> @@ -61,9 +78,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	unset subvol_pid
>   	_btrfs_kill_stress_replace_pid $replace_pid
> +	unset replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/066 b/tests/btrfs/066
> index b6f904ac..feb6062e 100755
> --- a/tests/btrfs/066
> +++ b/tests/btrfs/066
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto subvol scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
> +		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	fi
> +	if [ ! -z "$scrub_pid" ]; then
> +		_btrfs_kill_stress_scrub_pid $scrub_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -20,11 +36,12 @@ _require_scratch_nocheck
>   _require_scratch_dev_pool 4
>   _btrfs_get_profile_configs
>   
> +stop_file=$TEST_DIR/$seq.stop.$$
> +
>   run_test()
>   {
>   	local mkfs_opts=$1
>   	local subvol_mnt=$TEST_DIR/$seq.mnt
> -	local stop_file=$TEST_DIR/$seq.stop.$$
>   
>   	echo "Test $mkfs_opts" >>$seqres.full
>   
> @@ -53,9 +70,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	unset subvol_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	unset scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/067 b/tests/btrfs/067
> index 7be09d52..0bbfe83f 100755
> --- a/tests/btrfs/067
> +++ b/tests/btrfs/067
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto subvol defrag compress scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
> +		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	fi
> +	if [ ! -z "$defrag_pid" ]; then
> +		_btrfs_kill_stress_defrag_pid $defrag_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -20,12 +36,13 @@ _require_scratch_nocheck
>   _require_scratch_dev_pool 4
>   _btrfs_get_profile_configs
>   
> +stop_file=$TEST_DIR/$seq.stop.$$
> +
>   run_test()
>   {
>   	local mkfs_opts=$1
>   	local with_compress=$2
>   	local subvol_mnt=$TEST_DIR/$seq.mnt
> -	local stop_file=$TEST_DIR/$seq.stop.$$
>   
>   	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
>   
> @@ -54,9 +71,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	unset subvol_pid
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
> +	unset defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/068 b/tests/btrfs/068
> index 19e37010..7ab6feca 100755
> --- a/tests/btrfs/068
> +++ b/tests/btrfs/068
> @@ -11,6 +11,22 @@
>   . ./common/preamble
>   _begin_fstest auto subvol remount compress scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
> +		_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	fi
> +	if [ ! -z "$remount_pid" ]; then
> +		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -21,11 +37,12 @@ _require_scratch_nocheck
>   _require_scratch_dev_pool 4
>   _btrfs_get_profile_configs
>   
> +stop_file=$TEST_DIR/$seq.stop.$$
> +
>   run_test()
>   {
>   	local mkfs_opts=$1
>   	local subvol_mnt=$TEST_DIR/$seq.mnt
> -	local stop_file=$TEST_DIR/$seq.stop.$$
>   
>   	echo "Test $mkfs_opts with $with_compress" >>$seqres.full
>   
> @@ -54,9 +71,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
> +	unset subvol_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	unset remount_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/069 b/tests/btrfs/069
> index ad1609d4..3fbfecdb 100755
> --- a/tests/btrfs/069
> +++ b/tests/btrfs/069
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto replace scrub volume
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$replace_pid" ]; then
> +		_btrfs_kill_stress_replace_pid $replace_pid
> +	fi
> +	if [ ! -z "$scrub_pid" ]; then
> +		_btrfs_kill_stress_scrub_pid $scrub_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -59,8 +75,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	unset scrub_pid
>   	_btrfs_kill_stress_replace_pid $replace_pid
> +	unset replace_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/070 b/tests/btrfs/070
> index 3054c270..11fddc86 100755
> --- a/tests/btrfs/070
> +++ b/tests/btrfs/070
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto replace defrag compress volume scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$replace_pid" ]; then
> +		_btrfs_kill_stress_replace_pid $replace_pid
> +	fi
> +	if [ ! -z "$defrag_pid" ]; then
> +		_btrfs_kill_stress_defrag_pid $defrag_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -60,8 +76,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_replace_pid $replace_pid
> +	unset replace_pid
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
> +	unset defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/071 b/tests/btrfs/071
> index 36b39341..1a91ec45 100755
> --- a/tests/btrfs/071
> +++ b/tests/btrfs/071
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto replace remount compress volume scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$replace_pid" ]; then
> +		_btrfs_kill_stress_replace_pid $replace_pid
> +	fi
> +	if [ ! -z "$remount_pid" ]; then
> +		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -59,8 +75,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_replace_pid $replace_pid
> +	unset replace_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	unset remount_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/072 b/tests/btrfs/072
> index 505d0b57..e66e49c9 100755
> --- a/tests/btrfs/072
> +++ b/tests/btrfs/072
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto scrub defrag compress
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$defrag_pid" ]; then
> +		_btrfs_kill_stress_defrag_pid $defrag_pid
> +	fi
> +	if [ ! -z "$scrub_pid" ]; then
> +		_btrfs_kill_stress_scrub_pid $scrub_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -52,9 +68,12 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
> +	unset defrag_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	unset scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/073 b/tests/btrfs/073
> index 50358286..e6cfd92a 100755
> --- a/tests/btrfs/073
> +++ b/tests/btrfs/073
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto scrub remount compress
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$remount_pid" ]; then
> +		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	fi
> +	if [ ! -z "$scrub_pid" ]; then
> +		_btrfs_kill_stress_scrub_pid $scrub_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -51,8 +67,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	unset remount_pid
>   	_btrfs_kill_stress_scrub_pid $scrub_pid
> +	unset scrub_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
> diff --git a/tests/btrfs/074 b/tests/btrfs/074
> index 6e93b36a..1dd88bcd 100755
> --- a/tests/btrfs/074
> +++ b/tests/btrfs/074
> @@ -10,6 +10,22 @@
>   . ./common/preamble
>   _begin_fstest auto defrag remount compress scrub
>   
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +	if [ ! -z "$remount_pid" ]; then
> +		_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	fi
> +	if [ ! -z "$defrag_pid" ]; then
> +		_btrfs_kill_stress_defrag_pid $defrag_pid
> +	fi
> +	if [ ! -z "$fsstress_pid" ]; then
> +		kill $fsstress_pid &> /dev/null
> +		wait $fsstress_pid &> /dev/null
> +	fi
> +}
> +
>   # Import common functions.
>   . ./common/filter
>   
> @@ -52,8 +68,11 @@ run_test()
>   
>   	echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
>   	wait $fsstress_pid
> +	unset fsstress_pid
>   	_btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> +	unset remount_pid
>   	_btrfs_kill_stress_defrag_pid $defrag_pid
> +	unset defrag_pid
>   
>   	echo "Scrub the filesystem" >>$seqres.full
>   	$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  2024-03-28  9:24   ` Anand Jain
@ 2024-03-28 11:46     ` Anand Jain
  2024-03-28 12:03       ` Filipe Manana
  0 siblings, 1 reply; 27+ messages in thread
From: Anand Jain @ 2024-03-28 11:46 UTC (permalink / raw)
  To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana


>> diff --git a/tests/btrfs/071 b/tests/btrfs/071
>> index 6ebbd8cc..7ba15390 100755
>> --- a/tests/btrfs/071
>> +++ b/tests/btrfs/071
>> @@ -58,17 +58,15 @@ run_test()
>>       echo "$remount_pid" >>$seqres.full



>>       echo "Wait for fsstress to exit and kill all background workers" 
>> >>$seqres.full
>> -    wait $fsstress_pid
>> -    kill $replace_pid $remount_pid
>> -    wait
>> +    kill $replace_pid
>> +    wait $fsstress_pid $replace_pid

The change first kills the replace and then wait for fsstress. Was this
intentional?

This patch is causing a regression. The replace never gets killed, as
the echo-comment specifically states to wait for fsstress and then kill
the replace. Following it fixes the issue.

Which the patch 7/10 reversed the order to fix. But why?

Thanks, Anand


>> -    # wait for the remount and replace operations to finish
>> +    # wait for the replace operationss to finish




>>       while ps aux | grep "replace start" | grep -qv grep; do
>>           sleep 1
>>       done
>> -    while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>> -        sleep 1
>> -    done
>> +
>> +    _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>>       echo "Scrub the filesystem" >>$seqres.full
>>       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  2024-03-28 11:46     ` Anand Jain
@ 2024-03-28 12:03       ` Filipe Manana
  2024-03-28 12:50         ` Anand Jain
  0 siblings, 1 reply; 27+ messages in thread
From: Filipe Manana @ 2024-03-28 12:03 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, Filipe Manana

On Thu, Mar 28, 2024 at 11:46 AM Anand Jain <anand.jain@oracle.com> wrote:
>
>
> >> diff --git a/tests/btrfs/071 b/tests/btrfs/071
> >> index 6ebbd8cc..7ba15390 100755
> >> --- a/tests/btrfs/071
> >> +++ b/tests/btrfs/071
> >> @@ -58,17 +58,15 @@ run_test()
> >>       echo "$remount_pid" >>$seqres.full
>
>
>
> >>       echo "Wait for fsstress to exit and kill all background workers"
> >> >>$seqres.full
> >> -    wait $fsstress_pid
> >> -    kill $replace_pid $remount_pid
> >> -    wait
> >> +    kill $replace_pid
> >> +    wait $fsstress_pid $replace_pid
>
> The change first kills the replace and then wait for fsstress. Was this
> intentional?

It wasn't. But after all patches applied, everything's correct, we
wait for fsstress to finish and then kill replace.
Do you want me to fix that?

The sequence will have to be:

wait $fsstress_pid
kill $replace_pid
wait $replace_pid

Thanks.

>
> This patch is causing a regression. The replace never gets killed, as
> the echo-comment specifically states to wait for fsstress and then kill
> the replace. Following it fixes the issue.
>
> Which the patch 7/10 reversed the order to fix. But why?
>
> Thanks, Anand
>
>
> >> -    # wait for the remount and replace operations to finish
> >> +    # wait for the replace operationss to finish
>
>
>
>
> >>       while ps aux | grep "replace start" | grep -qv grep; do
> >>           sleep 1
> >>       done
> >> -    while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
> >> -        sleep 1
> >> -    done
> >> +
> >> +    _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
> >>       echo "Scrub the filesystem" >>$seqres.full
> >>       $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
  2024-03-28 12:03       ` Filipe Manana
@ 2024-03-28 12:50         ` Anand Jain
  0 siblings, 0 replies; 27+ messages in thread
From: Anand Jain @ 2024-03-28 12:50 UTC (permalink / raw)
  To: Filipe Manana; +Cc: fstests, linux-btrfs, Filipe Manana



On 3/28/24 20:03, Filipe Manana wrote:
> On Thu, Mar 28, 2024 at 11:46 AM Anand Jain <anand.jain@oracle.com> wrote:
>>
>>
>>>> diff --git a/tests/btrfs/071 b/tests/btrfs/071
>>>> index 6ebbd8cc..7ba15390 100755
>>>> --- a/tests/btrfs/071
>>>> +++ b/tests/btrfs/071
>>>> @@ -58,17 +58,15 @@ run_test()
>>>>        echo "$remount_pid" >>$seqres.full
>>
>>
>>
>>>>        echo "Wait for fsstress to exit and kill all background workers"
>>>>>> $seqres.full
>>>> -    wait $fsstress_pid
>>>> -    kill $replace_pid $remount_pid
>>>> -    wait
>>>> +    kill $replace_pid
>>>> +    wait $fsstress_pid $replace_pid
>>

>> The change first kills the replace and then wait for fsstress. Was this
>> intentional?
> 

> It wasn't.

Ok. Thanks for confirming. I will fix it.

-Anand


> But after all patches applied, everything's correct, we
> wait for fsstress to finish and then kill replace.
> Do you want me to fix that?
> 
> The sequence will have to be:
> 
> wait $fsstress_pid
> kill $replace_pid
> wait $replace_pid
> 
> Thanks.
> 
>>
>> This patch is causing a regression. The replace never gets killed, as
>> the echo-comment specifically states to wait for fsstress and then kill
>> the replace. Following it fixes the issue.
>>
>> Which the patch 7/10 reversed the order to fix. But why?
>>
>> Thanks, Anand
>>
>>
>>>> -    # wait for the remount and replace operations to finish
>>>> +    # wait for the replace operationss to finish
>>
>>
>>
>>
>>>>        while ps aux | grep "replace start" | grep -qv grep; do
>>>>            sleep 1
>>>>        done
>>>> -    while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
>>>> -        sleep 1
>>>> -    done
>>>> +
>>>> +    _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
>>>>        echo "Scrub the filesystem" >>$seqres.full
>>>>        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2024-03-28 12:50 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 17:11 [PATCH 00/10] fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4] fdmanana
2024-03-27 17:11 ` [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance fdmanana
2024-03-28  8:16   ` Anand Jain
2024-03-28  9:21     ` Filipe Manana
2024-03-27 17:11 ` [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid fdmanana
2024-03-28  8:41   ` Anand Jain
2024-03-28  9:25     ` Filipe Manana
2024-03-27 17:11 ` [PATCH 03/10] btrfs/028: removed redundant sync and scratch filesystem unmount fdmanana
2024-03-27 17:11 ` [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub fdmanana
2024-03-28  8:41   ` Anand Jain
2024-03-28  9:27     ` Filipe Manana
2024-03-27 17:11 ` [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag fdmanana
2024-03-28  9:18   ` Anand Jain
2024-03-28  9:32     ` Filipe Manana
2024-03-27 17:11 ` [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress fdmanana
2024-03-28  9:24   ` Anand Jain
2024-03-28 11:46     ` Anand Jain
2024-03-28 12:03       ` Filipe Manana
2024-03-28 12:50         ` Anand Jain
2024-03-27 17:11 ` [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace fdmanana
2024-03-28  9:35   ` Anand Jain
2024-03-27 17:11 ` [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume fdmanana
2024-03-28  9:36   ` Anand Jain
2024-03-27 17:11 ` [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume fdmanana
2024-03-28  9:38   ` Anand Jain
2024-03-27 17:11 ` [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted fdmanana
2024-03-28  9:48   ` Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.