diff mbox series

btrfs/081: wait for reader process to exit before cycle mounting

Message ID bdbff9712f32fe9458d9904f82bcc7cbf9892a4b.1719594258.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs/081: wait for reader process to exit before cycle mounting | expand

Commit Message

Filipe Manana June 28, 2024, 5:04 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

We send a kill signal to the reader process, check the md5sum of the
files and then cycle mount the scratch device. Most of the time the
reader process has already terminated before we attempt the cycle mount,
but sometimes it may still be alive in which case the cat command
executed by the reader process may fail because the scratch fs was
unmounted and the target file doesn't exist. This makes the cat command
print an error message and the test fail like this:

     Verifying file digests after cloning
     14968c092c68e32fa35e776392d14523  SCRATCH_MNT/foo
     14968c092c68e32fa35e776392d14523  SCRATCH_MNT/bar
    +cat: /opt/scratch/bar: No such file or directory
    +cat: /opt/scratch/bar: No such file or directory
    +cat: /opt/scratch/bar: No such file or directory
    +cat: /opt/scratch/bar: No such file or directory
    ...
    (Run diff -u /opt/xfstests/tests/btrfs/081.out

Fix this by making the test wait for the reader to terminate after
sending it the kill signal.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/081 | 1 +
 1 file changed, 1 insertion(+)

Comments

Boris Burkov June 28, 2024, 8:03 p.m. UTC | #1
On Fri, Jun 28, 2024 at 06:04:49PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We send a kill signal to the reader process, check the md5sum of the
> files and then cycle mount the scratch device. Most of the time the
> reader process has already terminated before we attempt the cycle mount,
> but sometimes it may still be alive in which case the cat command
> executed by the reader process may fail because the scratch fs was
> unmounted and the target file doesn't exist. This makes the cat command
> print an error message and the test fail like this:
> 
>      Verifying file digests after cloning
>      14968c092c68e32fa35e776392d14523  SCRATCH_MNT/foo
>      14968c092c68e32fa35e776392d14523  SCRATCH_MNT/bar
>     +cat: /opt/scratch/bar: No such file or directory
>     +cat: /opt/scratch/bar: No such file or directory
>     +cat: /opt/scratch/bar: No such file or directory
>     +cat: /opt/scratch/bar: No such file or directory
>     ...
>     (Run diff -u /opt/xfstests/tests/btrfs/081.out
> 
> Fix this by making the test wait for the reader to terminate after
> sending it the kill signal.
> 
Reviewed-by: Boris Burkov <boris@bur.io>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>  tests/btrfs/081 | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/btrfs/081 b/tests/btrfs/081
> index c3f84c77..64544da3 100755
> --- a/tests/btrfs/081
> +++ b/tests/btrfs/081
> @@ -82,6 +82,7 @@ $CLONER_PROG -s 0 -d 0 -l $(($num_extents * $extent_size)) \
>  	$SCRATCH_MNT/foo $SCRATCH_MNT/bar
>  
>  kill $reader_pid > /dev/null 2>&1
> +wait $reader_pid
>  
>  # Now both foo and bar should have exactly the same content.
>  # This didn't use to be the case before the btrfs kernel fix mentioned
> -- 
> 2.43.0
>
Anand Jain July 1, 2024, 9:51 a.m. UTC | #2
On 6/29/24 01:04, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We send a kill signal to the reader process, check the md5sum of the
> files and then cycle mount the scratch device. Most of the time the
> reader process has already terminated before we attempt the cycle mount,
> but sometimes it may still be alive in which case the cat command
> executed by the reader process may fail because the scratch fs was
> unmounted and the target file doesn't exist. This makes the cat command
> print an error message and the test fail like this:
> 
>       Verifying file digests after cloning
>       14968c092c68e32fa35e776392d14523  SCRATCH_MNT/foo
>       14968c092c68e32fa35e776392d14523  SCRATCH_MNT/bar
>      +cat: /opt/scratch/bar: No such file or directory
>      +cat: /opt/scratch/bar: No such file or directory
>      +cat: /opt/scratch/bar: No such file or directory
>      +cat: /opt/scratch/bar: No such file or directory
>      ...
>      (Run diff -u /opt/xfstests/tests/btrfs/081.out
> 
> Fix this by making the test wait for the reader to terminate after
> sending it the kill signal.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>


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

Thx, Anand

> ---
>   tests/btrfs/081 | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tests/btrfs/081 b/tests/btrfs/081
> index c3f84c77..64544da3 100755
> --- a/tests/btrfs/081
> +++ b/tests/btrfs/081
> @@ -82,6 +82,7 @@ $CLONER_PROG -s 0 -d 0 -l $(($num_extents * $extent_size)) \
>   	$SCRATCH_MNT/foo $SCRATCH_MNT/bar
>   
>   kill $reader_pid > /dev/null 2>&1
> +wait $reader_pid
>   
>   # Now both foo and bar should have exactly the same content.
>   # This didn't use to be the case before the btrfs kernel fix mentioned
diff mbox series

Patch

diff --git a/tests/btrfs/081 b/tests/btrfs/081
index c3f84c77..64544da3 100755
--- a/tests/btrfs/081
+++ b/tests/btrfs/081
@@ -82,6 +82,7 @@  $CLONER_PROG -s 0 -d 0 -l $(($num_extents * $extent_size)) \
 	$SCRATCH_MNT/foo $SCRATCH_MNT/bar
 
 kill $reader_pid > /dev/null 2>&1
+wait $reader_pid
 
 # Now both foo and bar should have exactly the same content.
 # This didn't use to be the case before the btrfs kernel fix mentioned