All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 251: Make fstrim call a bit more random
@ 2012-02-28 14:30 Lukas Czerner
  2012-03-01  8:15 ` [PATCH v2] " Lukas Czerner
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Czerner @ 2012-02-28 14:30 UTC (permalink / raw)
  To: xfs; +Cc: Lukas Czerner, aelder

To cover cases when fstrim arguments are not block/block group/file
system size aligned, we can be a bit more random. This commit changes
fstrim argument computing to use $RANDOM bash variable in order to have
different minlen, start, len argument settings and change the full fs
fstrim to be called randomly as well.

Also make kill and wait not complain about non existent process, since
it may have already finished before we attempt to kill it and wait for
it. No reason to fail the test.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 251 |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/251 b/251
index fa3d74a..0b68898 100755
--- a/251
+++ b/251
@@ -54,21 +54,21 @@ _cleanup()
 
 _destroy()
 {
-	kill $pids $fstrim_pid
-	wait $pids $fstrim_pid
+	kill $pids $fstrim_pid 2> /dev/null
+	wait $pids $fstrim_pid 2> /dev/null
 	rm -rf $tmp
 }
 
 _destroy_fstrim()
 {
-	kill $fpid
-	wait $fpid
+	kill $fpid 2> /dev/null
+	wait $fpid 2> /dev/null
 }
 
 _fail()
 {
 	echo "$1"
-	kill $mypid
+	kill $mypid 2> /dev/null
 }
 
 _check_fstrim_support()
@@ -87,13 +87,16 @@ fstrim_loop()
 	fsize=$(df | grep $SCRATCH_MNT | grep $SCRATCH_DEV  | awk '{print $2}')
 
 	while true ; do
-		step=1048576
+		step=$((RANDOM*$RANDOM))
+		minlen=$((RANDOM*($RANDOM%2+1)))
 		start=0
-		$here/src/fstrim $SCRATCH_MNT &
-		fpid=$!
-		wait $fpid
+		if [ $((RANDOM%10)) -gt 7 ]; then
+			$here/src/fstrim $SCRATCH_MNT &
+			fpid=$!
+			wait $fpid
+		fi
 		while [ $start -lt $fsize ] ; do
-			$here/src/fstrim -s ${start}k -l ${step}k $SCRATCH_MNT &
+			$here/src/fstrim -m ${minlen}k -s ${start}k -l ${step}k $SCRATCH_MNT &
 			fpid=$!
 			wait $fpid
 			start=$(( $start + $step ))
-- 
1.7.4.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH v2] 251: Make fstrim call a bit more random
  2012-02-28 14:30 [PATCH] 251: Make fstrim call a bit more random Lukas Czerner
@ 2012-03-01  8:15 ` Lukas Czerner
  2012-03-20 12:02   ` Lukas Czerner
  2012-03-31 20:13   ` [PATCH v2] 251: make " Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Lukas Czerner @ 2012-03-01  8:15 UTC (permalink / raw)
  To: xfs; +Cc: elder, Lukas Czerner

To cover cases when fstrim arguments are not block/block group/file
system size aligned, we can be a bit more random. This commit changes
fstrim argument computing to use $RANDOM bash variable in order to have
different minlen, start, len argument settings and change the full fs
fstrim to be called randomly as well.

Also make kill and wait not complain about non existent process, since
it may have already finished before we attempt to kill it and wait for
it. No reason to fail the test.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
v2: guess maximum minlen so we do not fail if milnen limitation
    of the fs is too small.

 251 |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/251 b/251
index fa3d74a..6d87bf4 100755
--- a/251
+++ b/251
@@ -54,21 +54,21 @@ _cleanup()
 
 _destroy()
 {
-	kill $pids $fstrim_pid
-	wait $pids $fstrim_pid
+	kill $pids $fstrim_pid 2> /dev/null
+	wait $pids $fstrim_pid 2> /dev/null
 	rm -rf $tmp
 }
 
 _destroy_fstrim()
 {
-	kill $fpid
-	wait $fpid
+	kill $fpid 2> /dev/null
+	wait $fpid 2> /dev/null
 }
 
 _fail()
 {
 	echo "$1"
-	kill $mypid
+	kill $mypid 2> /dev/null
 }
 
 _check_fstrim_support()
@@ -76,6 +76,16 @@ _check_fstrim_support()
 	$here/src/fstrim -l 10M $SCRATCH_MNT &> /dev/null
 }
 
+_guess_max_minlen()
+{
+	mmlen=100000
+	while [ $mmlen -gt 1 ]; do
+		$here/src/fstrim -l $(($mmlen*2))k -m ${mmlen}k $SCRATCH_MNT &> /dev/null && break
+		mmlen=$(($mmlen/2))
+	done
+	echo $mmlen
+}
+
 ##
 # Background FSTRIM loop. We are trimming the device in the loop and for
 # test coverage, we are doing whole device trim followed by several smaller
@@ -85,15 +95,19 @@ fstrim_loop()
 {
 	trap "_destroy_fstrim; exit \$status" 2 15
 	fsize=$(df | grep $SCRATCH_MNT | grep $SCRATCH_DEV  | awk '{print $2}')
+	mmlen=$(_guess_max_minlen)
 
 	while true ; do
-		step=1048576
-		start=0
-		$here/src/fstrim $SCRATCH_MNT &
-		fpid=$!
-		wait $fpid
+		step=$((RANDOM*$RANDOM))
+		minlen=$(((RANDOM*($RANDOM%2+1))%$mmlen))
+		start=$RANDOM
+		if [ $((RANDOM%10)) -gt 7 ]; then
+			$here/src/fstrim $SCRATCH_MNT &
+			fpid=$!
+			wait $fpid
+		fi
 		while [ $start -lt $fsize ] ; do
-			$here/src/fstrim -s ${start}k -l ${step}k $SCRATCH_MNT &
+			$here/src/fstrim -m ${minlen}k -s ${start}k -l ${step}k $SCRATCH_MNT &
 			fpid=$!
 			wait $fpid
 			start=$(( $start + $step ))
-- 
1.7.4.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH v2] 251: Make fstrim call a bit more random
  2012-03-01  8:15 ` [PATCH v2] " Lukas Czerner
@ 2012-03-20 12:02   ` Lukas Czerner
  2012-03-31 20:13   ` [PATCH v2] 251: make " Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Lukas Czerner @ 2012-03-20 12:02 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: elder, xfs

On Thu, 1 Mar 2012, Lukas Czerner wrote:

> To cover cases when fstrim arguments are not block/block group/file
> system size aligned, we can be a bit more random. This commit changes
> fstrim argument computing to use $RANDOM bash variable in order to have
> different minlen, start, len argument settings and change the full fs
> fstrim to be called randomly as well.
> 
> Also make kill and wait not complain about non existent process, since
> it may have already finished before we attempt to kill it and wait for
> it. No reason to fail the test.

ping

> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
> v2: guess maximum minlen so we do not fail if milnen limitation
>     of the fs is too small.
> 
>  251 |   36 +++++++++++++++++++++++++-----------
>  1 files changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/251 b/251
> index fa3d74a..6d87bf4 100755
> --- a/251
> +++ b/251
> @@ -54,21 +54,21 @@ _cleanup()
>  
>  _destroy()
>  {
> -	kill $pids $fstrim_pid
> -	wait $pids $fstrim_pid
> +	kill $pids $fstrim_pid 2> /dev/null
> +	wait $pids $fstrim_pid 2> /dev/null
>  	rm -rf $tmp
>  }
>  
>  _destroy_fstrim()
>  {
> -	kill $fpid
> -	wait $fpid
> +	kill $fpid 2> /dev/null
> +	wait $fpid 2> /dev/null
>  }
>  
>  _fail()
>  {
>  	echo "$1"
> -	kill $mypid
> +	kill $mypid 2> /dev/null
>  }
>  
>  _check_fstrim_support()
> @@ -76,6 +76,16 @@ _check_fstrim_support()
>  	$here/src/fstrim -l 10M $SCRATCH_MNT &> /dev/null
>  }
>  
> +_guess_max_minlen()
> +{
> +	mmlen=100000
> +	while [ $mmlen -gt 1 ]; do
> +		$here/src/fstrim -l $(($mmlen*2))k -m ${mmlen}k $SCRATCH_MNT &> /dev/null && break
> +		mmlen=$(($mmlen/2))
> +	done
> +	echo $mmlen
> +}
> +
>  ##
>  # Background FSTRIM loop. We are trimming the device in the loop and for
>  # test coverage, we are doing whole device trim followed by several smaller
> @@ -85,15 +95,19 @@ fstrim_loop()
>  {
>  	trap "_destroy_fstrim; exit \$status" 2 15
>  	fsize=$(df | grep $SCRATCH_MNT | grep $SCRATCH_DEV  | awk '{print $2}')
> +	mmlen=$(_guess_max_minlen)
>  
>  	while true ; do
> -		step=1048576
> -		start=0
> -		$here/src/fstrim $SCRATCH_MNT &
> -		fpid=$!
> -		wait $fpid
> +		step=$((RANDOM*$RANDOM))
> +		minlen=$(((RANDOM*($RANDOM%2+1))%$mmlen))
> +		start=$RANDOM
> +		if [ $((RANDOM%10)) -gt 7 ]; then
> +			$here/src/fstrim $SCRATCH_MNT &
> +			fpid=$!
> +			wait $fpid
> +		fi
>  		while [ $start -lt $fsize ] ; do
> -			$here/src/fstrim -s ${start}k -l ${step}k $SCRATCH_MNT &
> +			$here/src/fstrim -m ${minlen}k -s ${start}k -l ${step}k $SCRATCH_MNT &
>  			fpid=$!
>  			wait $fpid
>  			start=$(( $start + $step ))
> 

-- 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH v2] 251: make fstrim call a bit more random
  2012-03-01  8:15 ` [PATCH v2] " Lukas Czerner
  2012-03-20 12:02   ` Lukas Czerner
@ 2012-03-31 20:13   ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2012-03-31 20:13 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: elder, xfs

Thanks, applied.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2012-03-31 20:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 14:30 [PATCH] 251: Make fstrim call a bit more random Lukas Czerner
2012-03-01  8:15 ` [PATCH v2] " Lukas Czerner
2012-03-20 12:02   ` Lukas Czerner
2012-03-31 20:13   ` [PATCH v2] 251: make " Christoph Hellwig

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.