Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] fstests: btrfs/15[78]: Detect non-raid6 data chunks before doing the test
@ 2019-10-10  6:13 Qu Wenruo
  0 siblings, 0 replies; only message in thread
From: Qu Wenruo @ 2019-10-10  6:13 UTC (permalink / raw)
  To: linux-btrfs

[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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
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(+)

diff --git a/tests/btrfs/157 b/tests/btrfs/157
index 7f75c407..78dcea21 100755
--- a/tests/btrfs/157
+++ b/tests/btrfs/157
@@ -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}'`
diff --git a/tests/btrfs/158 b/tests/btrfs/158
index 603e8bea..441a33e8 100755
--- a/tests/btrfs/158
+++ b/tests/btrfs/158
@@ -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}'`
-- 
2.22.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  6:13 [PATCH] fstests: btrfs/15[78]: Detect non-raid6 data chunks before doing the test Qu Wenruo

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox