diff mbox series

[v3,3/3] fstests: btrfs: check conversion of zoned fileystems

Message ID 20240215-balance-fix-v3-3-79df5d5a940f@wdc.com (mailing list archive)
State New, archived
Headers show
Series fstests: btrfs: add test for zoned balance profile conversion bug | expand

Commit Message

Johannes Thumshirn Feb. 15, 2024, 11:47 a.m. UTC
Recently we had a bug where a zoned filesystem could be converted to a
higher data redundancy profile than supported.

Add a test-case to check the conversion on zoned filesystems.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 tests/btrfs/310     | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/310.out | 12 ++++++++++
 2 files changed, 79 insertions(+)

Comments

Zorro Lang Feb. 27, 2024, 1:12 p.m. UTC | #1
On Thu, Feb 15, 2024 at 03:47:06AM -0800, Johannes Thumshirn wrote:
> Recently we had a bug where a zoned filesystem could be converted to a
> higher data redundancy profile than supported.
> 
> Add a test-case to check the conversion on zoned filesystems.
> 
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  tests/btrfs/310     | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/310.out | 12 ++++++++++
>  2 files changed, 79 insertions(+)
> 
> diff --git a/tests/btrfs/310 b/tests/btrfs/310
> new file mode 100755
> index 000000000000..c39f60168f8a
> --- /dev/null
> +++ b/tests/btrfs/310
> @@ -0,0 +1,67 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Western Digital Corporation.  All Rights Reserved.
> +#
> +# FS QA Test 310
> +#
> +# Test that btrfs convert can ony be run to convert to supported profiles on a
> +# zoned filesystem
> +#
> +. ./common/preamble
> +_begin_fstest volume raid convert

Don't you want to add it in "auto" group, to be a default test?

> +
> +_fixed_by_kernel_commit XXXXXXXXXX \
> +	"btrfs: zoned: don't skip block group profile checks on conv zones"
> +
> +. common/filter.btrfs
> +
> +_supported_fs btrfs
> +_require_scratch_dev_pool 4
> +_require_zoned_device "$SCRATCH_DEV"

OK, looks like don't need to check each devices of SCRATCH_DEV_POOL at here :)

> +
> +devs=( $SCRATCH_DEV_POOL )
> +
> +# Create and mount single device FS
> +_scratch_mkfs -msingle -dsingle 2>&1 > /dev/null

Mkfs with specific options might fail, so better to _fail if mkfs return non-zero,
and better to output the message into .full file, to know what's wrong.

Thanks,
Zorro

> +_scratch_mount
> +
> +# Convert FS to metadata/system DUP
> +_run_btrfs_balance_start -f -mconvert=dup -sconvert=dup $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert
> +
> +# Convert FS to data DUP, must fail
> +_run_btrfs_balance_start -dconvert=dup $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert
> +
> +# Add device
> +$BTRFS_UTIL_PROG device add ${devs[1]} $SCRATCH_MNT | _filter_device_add
> +
> +# Convert FS to data RAID1, must fail
> +_run_btrfs_balance_start -dconvert=raid1 $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert | head -1
> +
> +# Convert FS to data RAID0, must fail
> +_run_btrfs_balance_start -dconvert=raid0 $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert | head -1
> +
> +# Add device
> +$BTRFS_UTIL_PROG device add ${devs[2]} $SCRATCH_MNT | _filter_device_add
> +
> +# Convert FS to data RAID5, must fail
> +_run_btrfs_balance_start -f -dconvert=raid5 $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert | head -1
> +
> +# Add device
> +$BTRFS_UTIL_PROG device add ${devs[3]} $SCRATCH_MNT | _filter_device_add
> +
> +# Convert FS to data RAID10, must fail
> +_run_btrfs_balance_start -dconvert=raid10 $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert | head -1
> +
> +# Convert FS to data RAID6, must fail
> +_run_btrfs_balance_start -f -dconvert=raid6 $SCRATCH_MNT 2>&1 |\
> +	_filter_balance_convert | head -1
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/310.out b/tests/btrfs/310.out
> new file mode 100644
> index 000000000000..bc06b29ecf10
> --- /dev/null
> +++ b/tests/btrfs/310.out
> @@ -0,0 +1,12 @@
> +QA output created by 310
> +Done, had to relocate X out of X chunks
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> +There may be more info in syslog - try dmesg | tail
> +Resetting device zones SCRATCH_DEV (XXX zones) ...
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> +Resetting device zones SCRATCH_DEV (XXX zones) ...
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> +Resetting device zones SCRATCH_DEV (XXX zones) ...
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
> 
> -- 
> 2.43.0
>
Johannes Thumshirn Feb. 27, 2024, 5:34 p.m. UTC | #2
On 27.02.24 14:12, Zorro Lang wrote:
> On Thu, Feb 15, 2024 at 03:47:06AM -0800, Johannes Thumshirn wrote:
>> Recently we had a bug where a zoned filesystem could be converted to a
>> higher data redundancy profile than supported.
>>
>> Add a test-case to check the conversion on zoned filesystems.
>>
>> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> ---
>>   tests/btrfs/310     | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/310.out | 12 ++++++++++
>>   2 files changed, 79 insertions(+)
>>
>> diff --git a/tests/btrfs/310 b/tests/btrfs/310
>> new file mode 100755
>> index 000000000000..c39f60168f8a
>> --- /dev/null
>> +++ b/tests/btrfs/310
>> @@ -0,0 +1,67 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Western Digital Corporation.  All Rights Reserved.
>> +#
>> +# FS QA Test 310
>> +#
>> +# Test that btrfs convert can ony be run to convert to supported profiles on a
>> +# zoned filesystem
>> +#
>> +. ./common/preamble
>> +_begin_fstest volume raid convert
> 
> Don't you want to add it in "auto" group, to be a default test?

Actually I do and forgot about it, sorry.
Anand Jain Feb. 28, 2024, 9:52 a.m. UTC | #3
On 2/27/24 23:04, Johannes Thumshirn wrote:
> On 27.02.24 14:12, Zorro Lang wrote:
>> On Thu, Feb 15, 2024 at 03:47:06AM -0800, Johannes Thumshirn wrote:
>>> Recently we had a bug where a zoned filesystem could be converted to a
>>> higher data redundancy profile than supported.
>>>
>>> Add a test-case to check the conversion on zoned filesystems.
>>>
>>> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>> ---
>>>    tests/btrfs/310     | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>    tests/btrfs/310.out | 12 ++++++++++
>>>    2 files changed, 79 insertions(+)
>>>
>>> diff --git a/tests/btrfs/310 b/tests/btrfs/310
>>> new file mode 100755
>>> index 000000000000..c39f60168f8a
>>> --- /dev/null
>>> +++ b/tests/btrfs/310
>>> @@ -0,0 +1,67 @@
>>> +#! /bin/bash
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +# Copyright (c) 2024 Western Digital Corporation.  All Rights Reserved.
>>> +#
>>> +# FS QA Test 310
>>> +#
>>> +# Test that btrfs convert can ony be run to convert to supported profiles on a
>>> +# zoned filesystem
>>> +#
>>> +. ./common/preamble
>>> +_begin_fstest volume raid convert
>>
>> Don't you want to add it in "auto" group, to be a default test?
> 
> Actually I do and forgot about it, sorry.
> 

I missed it too. I'll add it before the PR. I've updated the
mkfs as Zorro suggests.


----------
<snap>

+_begin_fstest auto volume raid convert

<snap>

+_scratch_mkfs -msingle -dsingle 2>&1 >> $seqres.full || _fail "mkfs failed"

<snap>
----------

Thanks, Anand
diff mbox series

Patch

diff --git a/tests/btrfs/310 b/tests/btrfs/310
new file mode 100755
index 000000000000..c39f60168f8a
--- /dev/null
+++ b/tests/btrfs/310
@@ -0,0 +1,67 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 310
+#
+# Test that btrfs convert can ony be run to convert to supported profiles on a
+# zoned filesystem
+#
+. ./common/preamble
+_begin_fstest volume raid convert
+
+_fixed_by_kernel_commit XXXXXXXXXX \
+	"btrfs: zoned: don't skip block group profile checks on conv zones"
+
+. common/filter.btrfs
+
+_supported_fs btrfs
+_require_scratch_dev_pool 4
+_require_zoned_device "$SCRATCH_DEV"
+
+devs=( $SCRATCH_DEV_POOL )
+
+# Create and mount single device FS
+_scratch_mkfs -msingle -dsingle 2>&1 > /dev/null
+_scratch_mount
+
+# Convert FS to metadata/system DUP
+_run_btrfs_balance_start -f -mconvert=dup -sconvert=dup $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert
+
+# Convert FS to data DUP, must fail
+_run_btrfs_balance_start -dconvert=dup $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert
+
+# Add device
+$BTRFS_UTIL_PROG device add ${devs[1]} $SCRATCH_MNT | _filter_device_add
+
+# Convert FS to data RAID1, must fail
+_run_btrfs_balance_start -dconvert=raid1 $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert | head -1
+
+# Convert FS to data RAID0, must fail
+_run_btrfs_balance_start -dconvert=raid0 $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert | head -1
+
+# Add device
+$BTRFS_UTIL_PROG device add ${devs[2]} $SCRATCH_MNT | _filter_device_add
+
+# Convert FS to data RAID5, must fail
+_run_btrfs_balance_start -f -dconvert=raid5 $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert | head -1
+
+# Add device
+$BTRFS_UTIL_PROG device add ${devs[3]} $SCRATCH_MNT | _filter_device_add
+
+# Convert FS to data RAID10, must fail
+_run_btrfs_balance_start -dconvert=raid10 $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert | head -1
+
+# Convert FS to data RAID6, must fail
+_run_btrfs_balance_start -f -dconvert=raid6 $SCRATCH_MNT 2>&1 |\
+	_filter_balance_convert | head -1
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/310.out b/tests/btrfs/310.out
new file mode 100644
index 000000000000..bc06b29ecf10
--- /dev/null
+++ b/tests/btrfs/310.out
@@ -0,0 +1,12 @@ 
+QA output created by 310
+Done, had to relocate X out of X chunks
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+There may be more info in syslog - try dmesg | tail
+Resetting device zones SCRATCH_DEV (XXX zones) ...
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+Resetting device zones SCRATCH_DEV (XXX zones) ...
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+Resetting device zones SCRATCH_DEV (XXX zones) ...
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument