Message ID | 20240209115057.1918103-1-johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fstests: btrfs: check conversion of zoned fileystems | expand |
On Fri, Feb 9, 2024 at 11:51 AM Johannes Thumshirn <johannes.thumshirn@wdc.com> 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> > --- > tests/btrfs/310 | 75 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/310.out | 31 +++++++++++++++++++ > 2 files changed, 106 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..5a9664d1 > --- /dev/null > +++ b/tests/btrfs/310 > @@ -0,0 +1,75 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2024 Western Digital Corperation. All Rights Reserved. Typo here, "Corperation". > +# > +# 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 > + > +_supported_fs btrfs > +_require_scratch_dev_pool 4 > +_require_zoned_device "$SCRATCH_DEV" > + > + > +_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" > + > +} > + > +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 > + > +# Convert FS to data DUP, must fail > +$BTRFS_UTIL_PROG balance start -dconvert=dup $SCRATCH_MNT 2>&1 | _filter_convert > + > +# Add device > +$BTRFS_UTIL_PROG device add ${devs[1]} $SCRATCH_MNT | _filter_add > + > +# Convert FS to data RAID1, must fail > +$BTRFS_UTIL_PROG balance start -dconvert=raid1 $SCRATCH_MNT 2>&1 | _filter_convert > + > +# Convert FS to data RAID0, must fail > +$BTRFS_UTIL_PROG balance start -dconvert=raid0 $SCRATCH_MNT 2>&1 | _filter_convert > + > +# Add device > +$BTRFS_UTIL_PROG device add ${devs[2]} $SCRATCH_MNT | _filter_add > + > +# Convert FS to data RAID5, must fail > +$BTRFS_UTIL_PROG balance start -f -dconvert=raid5 $SCRATCH_MNT 2>&1 | _filter_convert > + > +# Add device > +$BTRFS_UTIL_PROG device add ${devs[3]} $SCRATCH_MNT | _filter_add > + > +# Convert FS to data RAID10, must fail > +$BTRFS_UTIL_PROG balance start -dconvert=raid10 $SCRATCH_MNT 2>&1 | _filter_convert > + > +# Convert FS to data RAID6, must fail > +$BTRFS_UTIL_PROG balance start -f -dconvert=raid6 $SCRATCH_MNT 2>&1 | _filter_convert > + > +# success, all done > +status=0 > +exit > diff --git a/tests/btrfs/310.out b/tests/btrfs/310.out > new file mode 100644 > index 00000000..f1e44af6 > --- /dev/null > +++ b/tests/btrfs/310.out > @@ -0,0 +1,31 @@ > +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 > +There may be more info in syslog - try dmesg | tail > +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 > +There may be more info in syslog - try dmesg | tail > +WARNING: > + > + RAID5/6 support has known problems and is strongly discouraged > + to be used besides testing or evaluation. It is recommended that > + you use one of the other RAID profiles. > + Safety timeout skipped due to --force Btw, instead of relying on all these lines staying the same across btrfs-progs releases, we could rely only on the first line only, the one with the error message or success indication, by piping into a "| head -1". But anyway, minor things. Reviewed-by: Filipe Manana <fdmanana@suse.com> > + > +Resetting device zones SCRATCH_DEV (XXX zones) ... > +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument > +There may be more info in syslog - try dmesg | tail > +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument > +There may be more info in syslog - try dmesg | tail > +WARNING: > + > + RAID5/6 support has known problems and is strongly discouraged > + to be used besides testing or evaluation. It is recommended that > + you use one of the other RAID profiles. > + Safety timeout skipped due to --force > + > -- > 2.35.3 > >
On 09.02.24 13:04, Filipe Manana wrote: >> +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument >> +There may be more info in syslog - try dmesg | tail >> +WARNING: >> + >> + RAID5/6 support has known problems and is strongly discouraged >> + to be used besides testing or evaluation. It is recommended that >> + you use one of the other RAID profiles. >> + Safety timeout skipped due to --force > > Btw, instead of relying on all these lines staying the same across > btrfs-progs releases, > we could rely only on the first line only, the one with the error > message or success indication, by piping into a "| head -1". > > But anyway, minor things. > > Reviewed-by: Filipe Manana <fdmanana@suse.com> Good idea, will update.
diff --git a/tests/btrfs/310 b/tests/btrfs/310 new file mode 100755 index 00000000..5a9664d1 --- /dev/null +++ b/tests/btrfs/310 @@ -0,0 +1,75 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Western Digital Corperation. 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 + +_supported_fs btrfs +_require_scratch_dev_pool 4 +_require_zoned_device "$SCRATCH_DEV" + + +_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" + +} + +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 + +# Convert FS to data DUP, must fail +$BTRFS_UTIL_PROG balance start -dconvert=dup $SCRATCH_MNT 2>&1 | _filter_convert + +# Add device +$BTRFS_UTIL_PROG device add ${devs[1]} $SCRATCH_MNT | _filter_add + +# Convert FS to data RAID1, must fail +$BTRFS_UTIL_PROG balance start -dconvert=raid1 $SCRATCH_MNT 2>&1 | _filter_convert + +# Convert FS to data RAID0, must fail +$BTRFS_UTIL_PROG balance start -dconvert=raid0 $SCRATCH_MNT 2>&1 | _filter_convert + +# Add device +$BTRFS_UTIL_PROG device add ${devs[2]} $SCRATCH_MNT | _filter_add + +# Convert FS to data RAID5, must fail +$BTRFS_UTIL_PROG balance start -f -dconvert=raid5 $SCRATCH_MNT 2>&1 | _filter_convert + +# Add device +$BTRFS_UTIL_PROG device add ${devs[3]} $SCRATCH_MNT | _filter_add + +# Convert FS to data RAID10, must fail +$BTRFS_UTIL_PROG balance start -dconvert=raid10 $SCRATCH_MNT 2>&1 | _filter_convert + +# Convert FS to data RAID6, must fail +$BTRFS_UTIL_PROG balance start -f -dconvert=raid6 $SCRATCH_MNT 2>&1 | _filter_convert + +# success, all done +status=0 +exit diff --git a/tests/btrfs/310.out b/tests/btrfs/310.out new file mode 100644 index 00000000..f1e44af6 --- /dev/null +++ b/tests/btrfs/310.out @@ -0,0 +1,31 @@ +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 +There may be more info in syslog - try dmesg | tail +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 +There may be more info in syslog - try dmesg | tail +WARNING: + + RAID5/6 support has known problems and is strongly discouraged + to be used besides testing or evaluation. It is recommended that + you use one of the other RAID profiles. + Safety timeout skipped due to --force + +Resetting device zones SCRATCH_DEV (XXX zones) ... +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument +There may be more info in syslog - try dmesg | tail +ERROR: error during balancing 'SCRATCH_MNT': Invalid argument +There may be more info in syslog - try dmesg | tail +WARNING: + + RAID5/6 support has known problems and is strongly discouraged + to be used besides testing or evaluation. It is recommended that + you use one of the other RAID profiles. + Safety timeout skipped due to --force +
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> --- tests/btrfs/310 | 75 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/310.out | 31 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100755 tests/btrfs/310 create mode 100644 tests/btrfs/310.out