fstests: btrfs/15[78]: Detect non-raid6 data chunks before doing the test
PATCH 1/1 fstests: btrfs/15[78]: Detect non-raid6 data chunks before doing the test
[BUG]
When certain older mkfs.btrfs is used, btrfs/157 and btrfs/158 fails like below:
btrfs/157 2s ... - output mismatch (see xfstests-dev/results//btrfs/157.out.bad)
--- tests/btrfs/157.out 2019-07-22 14:13:44.653333326 +0800
+++ results//btrfs/157.out.bad 2019-10-10 13:58:58.625454478 +0800
@@ -1,8 +1,9 @@
QA output created by 157
wrote 131072/131072 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 65536/65536 bytes at offset 9437184
-XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+non-numeric offset argument -- 13631488
+1048576
...[CAUSE]
Btrfs/157 assumes there is only one RADI6 data chunk, and uses the following grep to find the only RAID6 data chunk:
$BTRFS_UTIL_PROG ins dump-tree -t 3 $SCRATCH_DEV | grep " DATA\|RAID6"
However that grep line can also matches SINGLE data profile. For older mkfs which doesn't cleanup the SINGLE temporary chunks, it will cause several lines of output, and screw up the output of get_physical_stripe0()
[FIX]
Add an extra filter, check_data_chunk_profile() to make sure there is only 1 data chunk and only 1 raid6 data chunk.
---
Currently it will skip the test if the assumption is not met, but in fact the original failure detects a bug in my modification of mkfs.btrfs.
so I'm not completely sure if I should _fail or _notrun.
--- tests/btrfs/157 | 14 ++++++++++++++ tests/btrfs/158 | 14 ++++++++++++++ 2 files changed, 28 insertions(+)
tests/btrfs/157 +14 -0
@@ -51,6 +51,19 @@ _require_scratch_dev_pool 4 _require_btrfs_command inspect-internal dump-tree _require_btrfs_fs_feature raid56 +# Older mkfs.btrfs or regression could create SINGLE temporary chunks +# Detect those before they screw up get_physical_stripe*() functions +check_data_chunk_profile() +{ + nr_data_chunks=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 \ + $SCRATCH_DEV | grep "type DATA" | wc -l) + nr_raid6_data_chunks=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 \ + $SCRATCH_DEV | grep "type DATA.RAID6" | wc -l) + if [ $nr_data_chunks -ne $nr_raid6_data_chunks -o $nr_data_chunks -ne 1 ]; then + _notrun "non-raid6 data chunk detected" + fi +} + get_physical_stripe0() { $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
@@ -82,6 +95,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa 0 128K" -c "fsync" \ _scratch_unmount +check_data_chunk_profile stripe_0=`get_physical_stripe0` stripe_1=`get_physical_stripe1` dev4=`echo $SCRATCH_DEV_POOL | awk '{print $4}'`
tests/btrfs/158 +14 -0
@@ -43,6 +43,19 @@ _require_scratch_dev_pool 4 _require_btrfs_command inspect-internal dump-tree _require_btrfs_fs_feature raid56 +# Older mkfs.btrfs or regression could create SINGLE temporary chunks +# Detect those before they screw up get_physical_stripe*() functions +check_data_chunk_profile() +{ + nr_data_chunks=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 \ + $SCRATCH_DEV | grep "type DATA" | wc -l) + nr_raid6_data_chunks=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 \ + $SCRATCH_DEV | grep "type DATA.RAID6" | wc -l) + if [ $nr_data_chunks -ne $nr_raid6_data_chunks -o $nr_data_chunks -ne 1 ]; then + _notrun "non-raid6 data chunk detected" + fi +} + get_physical_stripe0() { $BTRFS_UTIL_PROG inspect-internal dump-tree -t 3 $SCRATCH_DEV | \
@@ -74,6 +87,7 @@ $XFS_IO_PROG -f -d -c "pwrite -S 0xaa 0 128K" -c "fsync" \ _scratch_unmount +check_data_chunk_profile stripe_0=`get_physical_stripe0` stripe_1=`get_physical_stripe1` dev4=`echo $SCRATCH_DEV_POOL | awk '{print $4}'`
Signature · 1 line
2.22.0