Re: [PATCH v2] fstests: btrfs: check conversion of zoned fileystems

Johannes Thumshirn
2024-02-15T10:56:08Z

On 13.02.24 09:46, Anand Jain wrote:
>
>
> On 2/13/24 13:50, 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.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>> ---
>> tests/btrfs/310 | 75 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/310.out | 12 ++++++++
>> 2 files changed, 87 insertions(+)
>> create mode 100755 tests/btrfs/310
>> create mode 100644 tests/btrfs/310.out
>>
>> diff --git a/tests/btrfs/310 b/tests/btrfs/310
>> new file mode 100755
>> index 00000000..6b0846f0
>> --- /dev/null
>> +++ b/tests/btrfs/310
>> @@ -0,0 +1,75 @@
>> +#! /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
>> +. common/filter.btrfs
>
> common/filter.btrfs includes common/filter;
> So common/filter can be dropped.

Sure.

>
>> +
>> +_supported_fs btrfs
>> +_require_scratch_dev_pool 4
>
>> +_require_zoned_device "$SCRATCH_DEV"
>
> So, only the first device has to be a zone device?

Nope, but _require_zoned_device only accepts a single device ATM and if
device 1 is a zoned device, the FS is zoend, so adding non zoned devices
will treat them as zoned devices using the zone emulation layer. So I
think it is fine.

>
>> +
>> +
>> +_filter_convert()
>> +{
>> + _filter_scratch | \
>> + sed -e "s/relocate [0-9]\+ out of [0-9]\+ chunks/relocate X out of X chunks/g"
>> +}
>> +
>> +_filter_add()
>> +{
>> + _filter_scratch | _filter_scratch_pool | \
>> + sed -e "s/Resetting device zones SCRATCH_DEV ([0-9]\+/Resetting device zones SCRATCH_DEV (XXX/g"
>> +
>> +}
>> +
>
> Can we add the prefix 'balance' to these functions since they filter
> the balance output? Also, imo, it is better to move them to
> filter.btrfs.
>

Sure.

> and..
>
>> +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
>> +$BTRFS_UTIL_PROG balance start -f -mconvert=dup -sconvert=dup $SCRATCH_MNT 2>&1 | _filter_convert
>> +
>
> Why not update _run_btrfs_balance_start() to support argument passing
> and pass the options to it to run balance using the helper function?
>

I'll look into it.