diff mbox series

[6/7] iotests/common.rc: add disk_usage function

Message ID 20231020215622.789260-7-andrey.drobyshev@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series qcow2: make subclusters discardable | expand

Commit Message

Andrey Drobyshev Oct. 20, 2023, 9:56 p.m. UTC
Move the definition from iotests/250 to common.rc.  This is used to
detect real disk usage of sparse files.  In particular, we want to use
it for checking subclusters-based discards.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
 tests/qemu-iotests/250       | 5 -----
 tests/qemu-iotests/common.rc | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)

Comments

Hanna Czenczek Nov. 3, 2023, 3:20 p.m. UTC | #1
On 20.10.23 23:56, Andrey Drobyshev wrote:
> Move the definition from iotests/250 to common.rc.  This is used to
> detect real disk usage of sparse files.  In particular, we want to use
> it for checking subclusters-based discards.
>
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> ---
>   tests/qemu-iotests/250       | 5 -----
>   tests/qemu-iotests/common.rc | 6 ++++++
>   2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250
> index af48f83aba..c0a0dbc0ff 100755
> --- a/tests/qemu-iotests/250
> +++ b/tests/qemu-iotests/250
> @@ -52,11 +52,6 @@ _unsupported_imgopts data_file
>   # bdrv_co_truncate(bs->file) call in qcow2_co_truncate(), which might succeed
>   # anyway.
>   
> -disk_usage()
> -{
> -    du --block-size=1 $1 | awk '{print $1}'
> -}
> -
>   size=2100M
>   
>   _make_test_img -o "cluster_size=1M,preallocation=metadata" $size
> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
> index 95c12577dd..5d2ea26c7f 100644
> --- a/tests/qemu-iotests/common.rc
> +++ b/tests/qemu-iotests/common.rc
> @@ -140,6 +140,12 @@ _optstr_add()
>       fi
>   }
>   
> +# report real disk usage for sparse files
> +disk_usage()
> +{
> +    du --block-size=1 $1 | awk '{print $1}'

Pre-existing, but since you’re touching this now: Can you please change 
the $1 to "$1"?

Hanna

> +}
> +
>   # Set the variables to the empty string to turn Valgrind off
>   # for specific processes, e.g.
>   # $ VALGRIND_QEMU_IO= ./check -qcow2 -valgrind 015
Andrey Drobyshev Nov. 9, 2023, 12:35 p.m. UTC | #2
On 11/3/23 17:20, Hanna Czenczek wrote:
> On 20.10.23 23:56, Andrey Drobyshev wrote:
>> Move the definition from iotests/250 to common.rc.  This is used to
>> detect real disk usage of sparse files.  In particular, we want to use
>> it for checking subclusters-based discards.
>>
>> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
>> ---
>>   tests/qemu-iotests/250       | 5 -----
>>   tests/qemu-iotests/common.rc | 6 ++++++
>>   2 files changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250
>> index af48f83aba..c0a0dbc0ff 100755
>> --- a/tests/qemu-iotests/250
>> +++ b/tests/qemu-iotests/250
>> @@ -52,11 +52,6 @@ _unsupported_imgopts data_file
>>   # bdrv_co_truncate(bs->file) call in qcow2_co_truncate(), which
>> might succeed
>>   # anyway.
>>   -disk_usage()
>> -{
>> -    du --block-size=1 $1 | awk '{print $1}'
>> -}
>> -
>>   size=2100M
>>     _make_test_img -o "cluster_size=1M,preallocation=metadata" $size
>> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
>> index 95c12577dd..5d2ea26c7f 100644
>> --- a/tests/qemu-iotests/common.rc
>> +++ b/tests/qemu-iotests/common.rc
>> @@ -140,6 +140,12 @@ _optstr_add()
>>       fi
>>   }
>>   +# report real disk usage for sparse files
>> +disk_usage()
>> +{
>> +    du --block-size=1 $1 | awk '{print $1}'
> 
> Pre-existing, but since you’re touching this now: Can you please change
> the $1 to "$1"?
>

Sure, will do in v2.

> Hanna
> 
> [...]
diff mbox series

Patch

diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250
index af48f83aba..c0a0dbc0ff 100755
--- a/tests/qemu-iotests/250
+++ b/tests/qemu-iotests/250
@@ -52,11 +52,6 @@  _unsupported_imgopts data_file
 # bdrv_co_truncate(bs->file) call in qcow2_co_truncate(), which might succeed
 # anyway.
 
-disk_usage()
-{
-    du --block-size=1 $1 | awk '{print $1}'
-}
-
 size=2100M
 
 _make_test_img -o "cluster_size=1M,preallocation=metadata" $size
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 95c12577dd..5d2ea26c7f 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -140,6 +140,12 @@  _optstr_add()
     fi
 }
 
+# report real disk usage for sparse files
+disk_usage()
+{
+    du --block-size=1 $1 | awk '{print $1}'
+}
+
 # Set the variables to the empty string to turn Valgrind off
 # for specific processes, e.g.
 # $ VALGRIND_QEMU_IO= ./check -qcow2 -valgrind 015