Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v4 0/3] fstests: btrfs: add test for zoned balance profile conversion bug
@ 2024-02-27 12:25 Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 1/3] filter.brtfs: add filter for conversion Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-02-27 12:25 UTC (permalink / raw)
  To: Anand Jain
  Cc: Johannes Thumshirn, linux-btrfs, fstests, Zorro Lang,
	Johannes Thumshirn, Filipe Manana

Recently we had a report, that a zoned filesystem can be converted to a
RAID although the RAID stripe tree feature was not enabled.

Add a regression test for the fix commit.

---
Changes in v4:
- Remove zone reset message in filer
- Update golden output
- Link to v3: https://lore.kernel.org/r/20240215-balance-fix-v3-0-79df5d5a940f@wdc.com

---
Johannes Thumshirn (3):
      filter.brtfs: add filter for conversion
      filter.btrfs: add filter for btrfs device add
      fstests: btrfs: check conversion of zoned fileystems

 common/filter.btrfs | 15 ++++++++++++
 tests/btrfs/310     | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/310.out |  9 +++++++
 3 files changed, 91 insertions(+)
---
base-commit: c46ca4d1f6c0c45f9a3ea18bc31ba5ae89e02c70
change-id: 20240227-balance-fix-d4936e8060da

Best regards,
-- 
Johannes Thumshirn <jth@kernel.org>


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

* [PATCH v4 1/3] filter.brtfs: add filter for conversion
  2024-02-27 12:25 [PATCH v4 0/3] fstests: btrfs: add test for zoned balance profile conversion bug Johannes Thumshirn
@ 2024-02-27 12:25 ` Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 2/3] filter.btrfs: add filter for btrfs device add Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 3/3] fstests: btrfs: check conversion of zoned fileystems Johannes Thumshirn
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-02-27 12:25 UTC (permalink / raw)
  To: Anand Jain
  Cc: Johannes Thumshirn, linux-btrfs, fstests, Zorro Lang,
	Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Add a filter for the output of btrfs-balance with a convert argument.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 common/filter.btrfs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/filter.btrfs b/common/filter.btrfs
index 8ab76fcb..ea76e729 100644
--- a/common/filter.btrfs
+++ b/common/filter.btrfs
@@ -141,5 +141,11 @@ _filter_stripe_tree()
 		-e "s/bytes used [0-9]+/bytes used XXXXXX/"
 }
 
+# filter output of "btrfs balance start -[smd] convert
+_filter_balance_convert()
+{
+	_filter_scratch | \
+	sed -e "s/relocate [0-9]\+ out of [0-9]\+ chunks/relocate X out of X chunks/g"
+}
 # make sure this script returns success
 /bin/true

-- 
2.35.3


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

* [PATCH v4 2/3] filter.btrfs: add filter for btrfs device add
  2024-02-27 12:25 [PATCH v4 0/3] fstests: btrfs: add test for zoned balance profile conversion bug Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 1/3] filter.brtfs: add filter for conversion Johannes Thumshirn
@ 2024-02-27 12:25 ` Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 3/3] fstests: btrfs: check conversion of zoned fileystems Johannes Thumshirn
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-02-27 12:25 UTC (permalink / raw)
  To: Anand Jain
  Cc: Johannes Thumshirn, linux-btrfs, fstests, Zorro Lang,
	Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Add a filter for the output of btrfs device add.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 common/filter.btrfs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/common/filter.btrfs b/common/filter.btrfs
index ea76e729..9ef96761 100644
--- a/common/filter.btrfs
+++ b/common/filter.btrfs
@@ -147,5 +147,14 @@ _filter_balance_convert()
 	_filter_scratch | \
 	sed -e "s/relocate [0-9]\+ out of [0-9]\+ chunks/relocate X out of X chunks/g"
 }
+
+# filter output of "btrfs device add"
+_filter_device_add()
+{
+	_filter_scratch | _filter_scratch_pool | \
+	sed -e "/Resetting device zones SCRATCH_DEV ([0-9]\+/d"
+
+}
+
 # make sure this script returns success
 /bin/true

-- 
2.35.3


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

* [PATCH v4 3/3] fstests: btrfs: check conversion of zoned fileystems
  2024-02-27 12:25 [PATCH v4 0/3] fstests: btrfs: add test for zoned balance profile conversion bug Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 1/3] filter.brtfs: add filter for conversion Johannes Thumshirn
  2024-02-27 12:25 ` [PATCH v4 2/3] filter.btrfs: add filter for btrfs device add Johannes Thumshirn
@ 2024-02-27 12:25 ` Johannes Thumshirn
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-02-27 12:25 UTC (permalink / raw)
  To: Anand Jain
  Cc: Johannes Thumshirn, linux-btrfs, fstests, Zorro Lang,
	Johannes Thumshirn, Filipe Manana

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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 |  9 +++++++
 2 files changed, 76 insertions(+)

diff --git a/tests/btrfs/310 b/tests/btrfs/310
new file mode 100755
index 00000000..c39f6016
--- /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 00000000..cef2e5ab
--- /dev/null
+++ b/tests/btrfs/310.out
@@ -0,0 +1,9 @@
+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
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument
+ERROR: error during balancing 'SCRATCH_MNT': Invalid argument

-- 
2.35.3


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

end of thread, other threads:[~2024-02-27 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 12:25 [PATCH v4 0/3] fstests: btrfs: add test for zoned balance profile conversion bug Johannes Thumshirn
2024-02-27 12:25 ` [PATCH v4 1/3] filter.brtfs: add filter for conversion Johannes Thumshirn
2024-02-27 12:25 ` [PATCH v4 2/3] filter.btrfs: add filter for btrfs device add Johannes Thumshirn
2024-02-27 12:25 ` [PATCH v4 3/3] fstests: btrfs: check conversion of zoned fileystems Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox