diff mbox series

[01/10] generic/256: constrain runtime with TIME_FACTOR

Message ID 170620924382.3283496.6995781268514337077.stgit@frogsfrogsfrogs (mailing list archive)
State Superseded
Headers show
Series [01/10] generic/256: constrain runtime with TIME_FACTOR | expand

Commit Message

Darrick J. Wong Jan. 25, 2024, 7:04 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

This test runs 500 iterations of a "fill the fs and try to punch" test.
Hole punching can be particularly slow if, say, the filesystem is
mounted with -odiscard and the DISCARD operation takes a very long time.
In extreme cases, I can see test runtimes of 4+ hours.

Constrain the runtime of _test_full_fs_punch by establishing a deadline
of (30 seconds * TIME_FACTOR) and breaking out of the for loop if the
test goes beyond the time budget.  This keeps the runtime within the
customary 30 seconds.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/generic/256 |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Andrey Albershteyn Jan. 26, 2024, 12:32 p.m. UTC | #1
On 2024-01-25 11:04:14, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> This test runs 500 iterations of a "fill the fs and try to punch" test.
> Hole punching can be particularly slow if, say, the filesystem is
> mounted with -odiscard and the DISCARD operation takes a very long time.
> In extreme cases, I can see test runtimes of 4+ hours.
> 
> Constrain the runtime of _test_full_fs_punch by establishing a deadline
> of (30 seconds * TIME_FACTOR) and breaking out of the for loop if the
> test goes beyond the time budget.  This keeps the runtime within the
> customary 30 seconds.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  tests/generic/256 |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> 
> diff --git a/tests/generic/256 b/tests/generic/256
> index 808a730f3a..ea6cc2938a 100755
> --- a/tests/generic/256
> +++ b/tests/generic/256
> @@ -44,6 +44,8 @@ _test_full_fs_punch()
>  	local file_len=$(( $(( $hole_len + $hole_interval )) * $iterations ))
>  	local path=`dirname $file_name`
>  	local hole_offset=0
> +	local start_time
> +	local stop_time
>  
>  	if [ $# -ne 5 ]
>  	then
> @@ -57,6 +59,9 @@ _test_full_fs_punch()
>  		-c "fsync" $file_name &> /dev/null
>  	chmod 666 $file_name
>  
> +	start_time="$(date +%s)"
> +	stop_time=$(( start_time + (30 * TIME_FACTOR) ))
> +
>  	# All files are created as a non root user to prevent reserved blocks
>  	# from being consumed.
>  	_fill_fs $(( 1024 * 1024 * 1024 )) $path/fill $block_size 1 \
> @@ -64,6 +69,8 @@ _test_full_fs_punch()
>  
>  	for (( i=0; i<$iterations; i++ ))
>  	do
> +		test "$(date +%s)" -ge "$stop_time" && break
> +
>  		# This part must not be done as root in order to
>  		# test that reserved blocks are used when needed
>  		_user_do "$XFS_IO_PROG -f -c \"fpunch $hole_offset $hole_len\" $file_name"
> 
> 

LGTM
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
Christoph Hellwig Jan. 26, 2024, 1:30 p.m. UTC | #2
On Thu, Jan 25, 2024 at 11:04:14AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> This test runs 500 iterations of a "fill the fs and try to punch" test.
> Hole punching can be particularly slow if, say, the filesystem is
> mounted with -odiscard and the DISCARD operation takes a very long time.
> In extreme cases, I can see test runtimes of 4+ hours.
> 
> Constrain the runtime of _test_full_fs_punch by establishing a deadline
> of (30 seconds * TIME_FACTOR) and breaking out of the for loop if the
> test goes beyond the time budget.  This keeps the runtime within the
> customary 30 seconds.

Sounds good, this is can one of the slower 'quick' tests for sure:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/tests/generic/256 b/tests/generic/256
index 808a730f3a..ea6cc2938a 100755
--- a/tests/generic/256
+++ b/tests/generic/256
@@ -44,6 +44,8 @@  _test_full_fs_punch()
 	local file_len=$(( $(( $hole_len + $hole_interval )) * $iterations ))
 	local path=`dirname $file_name`
 	local hole_offset=0
+	local start_time
+	local stop_time
 
 	if [ $# -ne 5 ]
 	then
@@ -57,6 +59,9 @@  _test_full_fs_punch()
 		-c "fsync" $file_name &> /dev/null
 	chmod 666 $file_name
 
+	start_time="$(date +%s)"
+	stop_time=$(( start_time + (30 * TIME_FACTOR) ))
+
 	# All files are created as a non root user to prevent reserved blocks
 	# from being consumed.
 	_fill_fs $(( 1024 * 1024 * 1024 )) $path/fill $block_size 1 \
@@ -64,6 +69,8 @@  _test_full_fs_punch()
 
 	for (( i=0; i<$iterations; i++ ))
 	do
+		test "$(date +%s)" -ge "$stop_time" && break
+
 		# This part must not be done as root in order to
 		# test that reserved blocks are used when needed
 		_user_do "$XFS_IO_PROG -f -c \"fpunch $hole_offset $hole_len\" $file_name"