All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 05/10] common: add _filter_trailing_whitespace
@ 2023-12-29 12:22   ` Anand Jain
  0 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 11:01 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

The command 'btrfs inspect-internal dump-tree -t raid_stripe'
introduces trailing whitespace in its output.
Apply a filter to remove it. Used in btrfs/30[4-8][.out].

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/filter | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/filter b/common/filter
index 509ee95039ac..016d213b8bee 100644
--- a/common/filter
+++ b/common/filter
@@ -651,5 +651,10 @@ _filter_bash()
 	sed -e "s/^bash: line 1: /bash: /"
 }
 
+_filter_trailing_whitespace()
+{
+	sed -e "s/ $//"
+}
+
 # make sure this script returns success
 /bin/true
-- 
2.39.3


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

* [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature
@ 2023-12-29 12:22 Anand Jain
  2023-12-29 12:22   ` [PATCH v7 " Anand Jain
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

Changes in v7:
- Fixed trailing whitespace in the .out files
- Fixed the following test statement in 30[4-8]:
     test _get_page_size -eq 4096
- Link to v6: https://lore.kernel.org/r/20231213-btrfs-raid-v6-0-913738861069@wdc.com

--- original cover page from Johannes ----
Add tests for btrfs' raid-stripe-tree feature. All of these test work by
writing a specific pattern to a newly created filesystem and afterwards
using `btrfs inspect-internal -t raid-stripe $SCRATCH_DEV_POOL` to verify
the placement and the layout of the metadata.

The md5sum of each file will be compared as well after a re-mount of the
filesystem.

---
Changes in v6:
- require 4k pagesize for all tests as output depends on page size
- Add Filipe's Reviewed-by
- Link to v5: https://lore.kernel.org/r/20231207-btrfs-raid-v5-0-44aa1affe856@wdc.com

Changes in v5:
- add _require_btrfs_free_space_tree helper and use in tests
- Link to v4: https://lore.kernel.org/r/20231206-btrfs-raid-v4-0-578284dd3a70@wdc.com

Changes in v4:
- add _require_btrfs_no_compress to all tests
- add _require_btrfs_no_nodatacow helper and add to btrfs/308
- add _require_btrfs_feature "free_space_tree" to all tests
- Link to v3: https://lore.kernel.org/r/20231205-btrfs-raid-v3-0-0e857a5439a2@wdc.com

Changes in v3:
- added 'raid-stripe-tree' to mkfs options, as only zoned raid gets it
  automatically
- Rename test cases as btrfs/302 and btrfs/303 already exist upstream
- Link to v2: https://lore.kernel.org/r/20231205-btrfs-raid-v2-0-25f80eea345b@wdc.com

Changes in v2:
- Re-ordered series so the newly introduced group is added before the
  tests
- Changes Filipe requested to the tests.
- Link to v1: https://lore.kernel.org/r/20231204-btrfs-raid-v1-0-b254eb1bcff8@wdc.com

Anand Jain (1):
  common: add _filter_trailing_whitespace

Johannes Thumshirn (9):
  fstests: doc: add new raid-stripe-tree group
  common: add filter for btrfs raid-stripe dump
  common: add _require_btrfs_no_nodatacow helper
  common: add _require_btrfs_free_space_tree
  btrfs: add fstest for stripe-tree metadata with 4k write
  btrfs: add fstest for 8k write spanning two stripes on
    raid-stripe-tree
  btrfs: add fstest for writing to a file at an offset with RST
  btrfs: add fstests to write 128k to a RST filesystem
  btrfs: add fstest for overwriting a file partially with RST

 common/btrfs        |  17 +++++++
 common/filter       |   5 +++
 common/filter.btrfs |  14 ++++++
 doc/group-names.txt |   1 +
 tests/btrfs/304     |  59 ++++++++++++++++++++++++
 tests/btrfs/304.out |  58 ++++++++++++++++++++++++
 tests/btrfs/305     |  64 ++++++++++++++++++++++++++
 tests/btrfs/305.out |  82 ++++++++++++++++++++++++++++++++++
 tests/btrfs/306     |  62 ++++++++++++++++++++++++++
 tests/btrfs/306.out |  75 +++++++++++++++++++++++++++++++
 tests/btrfs/307     |  59 ++++++++++++++++++++++++
 tests/btrfs/307.out |  65 +++++++++++++++++++++++++++
 tests/btrfs/308     |  63 ++++++++++++++++++++++++++
 tests/btrfs/308.out | 106 ++++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 730 insertions(+)
 create mode 100755 tests/btrfs/304
 create mode 100644 tests/btrfs/304.out
 create mode 100755 tests/btrfs/305
 create mode 100644 tests/btrfs/305.out
 create mode 100755 tests/btrfs/306
 create mode 100644 tests/btrfs/306.out
 create mode 100755 tests/btrfs/307
 create mode 100644 tests/btrfs/307.out
 create mode 100755 tests/btrfs/308
 create mode 100644 tests/btrfs/308.out

-- 
2.39.3


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

* [PATCH v7 01/10] fstests: doc: add new raid-stripe-tree group
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
  2023-12-29 12:22   ` [PATCH v7 " Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 02/10] common: add filter for btrfs raid-stripe dump Anand Jain
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Add a new test group for testing the raid-stripe-tree feature of btrfs
with fstests.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 doc/group-names.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/group-names.txt b/doc/group-names.txt
index fec6bf71abcb..2ac95ac83a79 100644
--- a/doc/group-names.txt
+++ b/doc/group-names.txt
@@ -94,6 +94,7 @@ punch			fallocate FALLOC_FL_PUNCH_HOLE
 qgroup			btrfs qgroup feature
 quota			filesystem usage quotas
 raid			btrfs RAID
+raid-stripe-tree	btrfs raid-stripe-tree feature
 read_repair		btrfs error correction on read failure
 realtime		XFS realtime volumes
 recoveryloop		crash recovery loops
-- 
2.39.3


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

* [PATCH v7 02/10] common: add filter for btrfs raid-stripe dump
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
  2023-12-29 12:22   ` [PATCH v7 " Anand Jain
  2023-12-29 12:22 ` [PATCH v7 01/10] fstests: doc: add new raid-stripe-tree group Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 03/10] common: add _require_btrfs_no_nodatacow helper Anand Jain
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/filter.btrfs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/filter.btrfs b/common/filter.btrfs
index 8c6fe5793663..e570648bb5e6 100644
--- a/common/filter.btrfs
+++ b/common/filter.btrfs
@@ -126,5 +126,19 @@ _filter_btrfs_cloner_error()
 	sed -e "s/\(clone failed:\) Operation not supported/\1 Invalid argument/g"
 }
 
+# filter output of "btrfs inspect-internal dump-tree -t raid-stripe"
+_filter_stripe_tree()
+{
+	sed -E -e "s/leaf [0-9]+ items [0-9]+ free space [0-9]+ generation [0-9]+ owner RAID_STRIPE_TREE/leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE/" \
+		-e "s/leaf [0-9]+ flags 0x1\(WRITTEN\) backref revision 1/leaf XXXXXXXXX flags 0x1\(WRITTEN\) backref revision 1/" \
+		-e "s/checksum stored [0-9a-f]+/checksum stored <CHECKSUM>/"  \
+		-e "s/checksum calced [0-9a-f]+/checksum calced <CHECKSUM>/"  \
+		-e "s/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/<UUID>/" \
+		-e "s/item ([0-9]+) key \([0-9]+ RAID_STRIPE ([0-9]+)\) itemoff [0-9]+ itemsize ([0-9]+)/item \1 key \(XXXXXX RAID_STRIPE \2\) itemoff XXXXX itemsize \3/" \
+		-e "s/stripe ([0-9]+) devid ([0-9]+) physical [0-9]+/stripe \1 devid \2 physical XXXXXXXXX/" \
+		-e "s/total bytes [0-9]+/total bytes XXXXXXXX/" \
+		-e "s/bytes used [0-9]+/bytes used XXXXXX/"
+}
+
 # make sure this script returns success
 /bin/true
-- 
2.39.3


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

* [PATCH v7 03/10] common: add _require_btrfs_no_nodatacow helper
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (2 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 02/10] common: add filter for btrfs raid-stripe dump Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 04/10] common: add _require_btrfs_free_space_tree Anand Jain
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index f91f8dd869a1..9dd2a7f49e16 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -120,6 +120,13 @@ _require_btrfs_no_compress()
 	fi
 }
 
+_require_btrfs_no_nodatacow()
+{
+	if _normalize_mount_options "$MOUNT_OPTIONS" | grep -q "nodatacow"; then
+		_notrun "This test requires no nodatacow enabled"
+	fi
+}
+
 _check_btrfs_filesystem()
 {
 	device=$1
-- 
2.39.3


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

* [PATCH v7 04/10] common: add _require_btrfs_free_space_tree
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (3 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 03/10] common: add _require_btrfs_no_nodatacow helper Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 06/10] btrfs: add fstest for stripe-tree metadata with 4k write Anand Jain
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index 9dd2a7f49e16..e1b29c613767 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -127,6 +127,16 @@ _require_btrfs_no_nodatacow()
 	fi
 }
 
+_require_btrfs_free_space_tree()
+{
+	_scratch_mkfs > /dev/null 2>&1
+	if ! $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | \
+		grep -q "FREE_SPACE_TREE"
+	then
+		_notrun "This test requires a free-space-tree"
+	fi
+}
+
 _check_btrfs_filesystem()
 {
 	device=$1
-- 
2.39.3


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

* [PATCH v7 05/10] common: add _filter_trailing_whitespace
@ 2023-12-29 12:22   ` Anand Jain
  0 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

The command 'btrfs inspect-internal dump-tree -t raid_stripe'
introduces trailing whitespace in its output.
Apply a filter to remove it. Used in btrfs/30[4-8][.out].

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/filter | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/filter b/common/filter
index 509ee95039ac..016d213b8bee 100644
--- a/common/filter
+++ b/common/filter
@@ -651,5 +651,10 @@ _filter_bash()
 	sed -e "s/^bash: line 1: /bash: /"
 }
 
+_filter_trailing_whitespace()
+{
+	sed -e "s/ $//"
+}
+
 # make sure this script returns success
 /bin/true
-- 
2.39.3


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

* [PATCH v7 06/10] btrfs: add fstest for stripe-tree metadata with 4k write
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (4 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 04/10] common: add _require_btrfs_free_space_tree Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 07/10] btrfs: add fstest for 8k write spanning two stripes on raid-stripe-tree Anand Jain
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Test a simple 4k write on all RAID profiles currently supported with the
raid-stripe-tree.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[Fixed the test statement and trailing white space in the .out file.]
---
 tests/btrfs/304     | 59 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/304.out | 58 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100755 tests/btrfs/304
 create mode 100644 tests/btrfs/304.out

diff --git a/tests/btrfs/304 b/tests/btrfs/304
new file mode 100755
index 000000000000..186fa1646e48
--- /dev/null
+++ b/tests/btrfs/304
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Western Digital Cooperation.  All Rights Reserved.
+#
+# FS QA Test 304
+#
+# Test on-disk layout of RAID Stripe Tree Metadata writing 4k to a new file on
+# a pristine file system.
+#
+. ./common/preamble
+_begin_fstest auto quick raid remount volume raid-stripe-tree
+
+. ./common/filter
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_mkfs_feature "raid-stripe-tree"
+_require_scratch_dev_pool 4
+_require_btrfs_fs_feature "raid_stripe_tree"
+_require_btrfs_fs_feature "free_space_tree"
+_require_btrfs_free_space_tree
+_require_btrfs_no_compress
+
+test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+
+test_4k_write()
+{
+	local profile=$1
+	local ndevs=$2
+
+	_scratch_dev_pool_get $ndevs
+
+	echo "==== Testing $profile ===="
+	_scratch_pool_mkfs -d $profile -m $profile -O raid-stripe-tree
+	_scratch_mount
+
+	$XFS_IO_PROG -fc "pwrite 0 4k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+
+	_scratch_cycle_mount
+	md5sum "$SCRATCH_MNT/foo" | _filter_scratch
+
+	_scratch_unmount
+
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t raid_stripe $SCRATCH_DEV_POOL |\
+		_filter_trailing_whitespace |\
+		_filter_btrfs_version |  _filter_stripe_tree
+
+	_scratch_dev_pool_put
+}
+
+echo "= Test basic 4k write ="
+test_4k_write raid0 2
+test_4k_write raid1 2
+test_4k_write raid10 4
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/304.out b/tests/btrfs/304.out
new file mode 100644
index 000000000000..39f56f32274d
--- /dev/null
+++ b/tests/btrfs/304.out
@@ -0,0 +1,58 @@
+QA output created by 304
+= Test basic 4k write =
+==== Testing raid0 ====
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+5fed275e7617a806f94c173746a2a723  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid1 ====
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+5fed275e7617a806f94c173746a2a723  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid10 ====
+wrote 4096/4096 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+5fed275e7617a806f94c173746a2a723  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
-- 
2.39.3


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

* [PATCH v7 07/10] btrfs: add fstest for 8k write spanning two stripes on raid-stripe-tree
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (5 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 06/10] btrfs: add fstest for stripe-tree metadata with 4k write Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 08/10] btrfs: add fstest for writing to a file at an offset with RST Anand Jain
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Add a test-case writing 8k to a raid-stripe-tree formatted filesystem with
one stripe pre-filled to 60k so the 8k are split into a 4k write finishing
stripe 1 and a 4k write starting the next stripe.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[Fixed the test statement and trailing white space in the .out file.]
---
 tests/btrfs/305     | 64 +++++++++++++++++++++++++++++++++++
 tests/btrfs/305.out | 82 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 146 insertions(+)
 create mode 100755 tests/btrfs/305
 create mode 100644 tests/btrfs/305.out

diff --git a/tests/btrfs/305 b/tests/btrfs/305
new file mode 100755
index 000000000000..f3bf0faa414c
--- /dev/null
+++ b/tests/btrfs/305
@@ -0,0 +1,64 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Western Digital Cooperation.  All Rights Reserved.
+#
+# FS QA Test 305
+#
+# Test on-disk layout of RAID Stripe Tree Metadata by writing 8k to a new file
+# with a filesystem prepropulated, so that 4k of the write are written to the
+# 1st stripe and 4k start a new stripe.
+#
+. ./common/preamble
+_begin_fstest auto quick raid remount volume raid-stripe-tree
+
+. ./common/filter
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_mkfs_feature "raid-stripe-tree"
+_require_scratch_dev_pool 4
+_require_btrfs_fs_feature "raid_stripe_tree"
+_require_btrfs_fs_feature "free_space_tree"
+_require_btrfs_free_space_tree
+_require_btrfs_no_compress
+
+test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+
+test_8k_new_stripe()
+{
+	local profile=$1
+	local ndevs=$2
+
+	_scratch_dev_pool_get $ndevs
+
+	echo "==== Testing $profile ===="
+	_scratch_pool_mkfs -d $profile -m $profile -O raid-stripe-tree
+	_scratch_mount
+
+	# Fill the first stripe up to 64k - 4k
+	$XFS_IO_PROG -fc "pwrite 0 60k" -c fsync "$SCRATCH_MNT/bar" | _filter_xfs_io
+
+	# The actual 8k write
+	$XFS_IO_PROG -fc "pwrite 0 8k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+
+	_scratch_cycle_mount
+	md5sum "$SCRATCH_MNT/foo" | _filter_scratch
+
+	_scratch_unmount
+
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t raid_stripe $SCRATCH_DEV_POOL |\
+		_filter_trailing_whitespace |\
+		_filter_btrfs_version | _filter_stripe_tree
+
+	_scratch_dev_pool_put
+}
+
+echo "= Test 8k write to a new file so that 4k start a new stripe ="
+test_8k_new_stripe raid0 2
+test_8k_new_stripe raid1 2
+test_8k_new_stripe raid10 4
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/305.out b/tests/btrfs/305.out
new file mode 100644
index 000000000000..7090626c3036
--- /dev/null
+++ b/tests/btrfs/305.out
@@ -0,0 +1,82 @@
+QA output created by 305
+= Test 8k write to a new file so that 4k start a new stripe =
+==== Testing raid0 ====
+wrote 61440/61440 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+9d3940adb41dd525e008a847e01b15f4  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 61440) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 2 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid1 ====
+wrote 61440/61440 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+9d3940adb41dd525e008a847e01b15f4  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 61440) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid10 ====
+wrote 61440/61440 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+9d3940adb41dd525e008a847e01b15f4  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 61440) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 2 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 3 physical XXXXXXXXX
+			stripe 1 devid 4 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
-- 
2.39.3


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

* [PATCH v7 08/10] btrfs: add fstest for writing to a file at an offset with RST
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (6 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 07/10] btrfs: add fstest for 8k write spanning two stripes on raid-stripe-tree Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 09/10] btrfs: add fstests to write 128k to a RST filesystem Anand Jain
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Add a fstest writing 4k at offset 64k to a file with one RAID tripe
already pre-filled for a raid-stripe-tree formatted file system.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[Fixed the test statement and trailing white space in the .out file.]
---
 tests/btrfs/306     | 62 +++++++++++++++++++++++++++++++++++++
 tests/btrfs/306.out | 75 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 137 insertions(+)
 create mode 100755 tests/btrfs/306
 create mode 100644 tests/btrfs/306.out

diff --git a/tests/btrfs/306 b/tests/btrfs/306
new file mode 100755
index 000000000000..e2a9f804ac8b
--- /dev/null
+++ b/tests/btrfs/306
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Western Digital Cooperation.  All Rights Reserved.
+#
+# FS QA Test 306
+#
+# Test on-disk layout of RAID Stripe Tree Metadata by writing 4k to an emppty
+# file at offset 64k with one stripe pre-filled on an otherwise pristine
+# filesystem.
+#
+. ./common/preamble
+_begin_fstest auto quick raid remount volume raid-stripe-tree
+
+. ./common/filter
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_mkfs_feature "raid-stripe-tree"
+_require_scratch_dev_pool 4
+_require_btrfs_fs_feature "raid_stripe_tree"
+_require_btrfs_fs_feature "free_space_tree"
+_require_btrfs_free_space_tree
+_require_btrfs_no_compress
+
+test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+
+test_4k_write_64koff()
+{
+	local profile=$1
+	local ndevs=$2
+
+	_scratch_dev_pool_get $ndevs
+
+	echo "==== Testing $profile ===="
+	_scratch_pool_mkfs -d $profile -m $profile -O raid-stripe-tree
+	_scratch_mount
+
+	# precondition one stripe
+	$XFS_IO_PROG -fc "pwrite 0 64k" "$SCRATCH_MNT/bar" | _filter_xfs_io
+
+	$XFS_IO_PROG -fc "pwrite 64k 4k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+
+	_scratch_cycle_mount
+	md5sum "$SCRATCH_MNT/foo" | _filter_scratch
+
+	_scratch_unmount
+
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t raid_stripe $SCRATCH_DEV_POOL |\
+		_filter_trailing_whitespace |\
+		_filter_btrfs_version | _filter_stripe_tree
+
+	_scratch_dev_pool_put
+}
+echo "= Test 4k write to an empty file at offset 64k with one stripe prefilled ="
+test_4k_write_64koff raid0 2
+test_4k_write_64koff raid1 2
+test_4k_write_64koff raid10 4
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/306.out b/tests/btrfs/306.out
new file mode 100644
index 000000000000..25065674c77b
--- /dev/null
+++ b/tests/btrfs/306.out
@@ -0,0 +1,75 @@
+QA output created by 306
+= Test 4k write to an empty file at offset 64k with one stripe prefilled =
+==== Testing raid0 ====
+wrote 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 4096/4096 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+381b0e7d72cb4f75286fe2b445e8d92a  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid1 ====
+wrote 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 4096/4096 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+381b0e7d72cb4f75286fe2b445e8d92a  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid10 ====
+wrote 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 4096/4096 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+381b0e7d72cb4f75286fe2b445e8d92a  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 3 physical XXXXXXXXX
+			stripe 1 devid 4 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
-- 
2.39.3


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

* [PATCH v7 09/10] btrfs: add fstests to write 128k to a RST filesystem
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (7 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 08/10] btrfs: add fstest for writing to a file at an offset with RST Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:22 ` [PATCH v7 10/10] btrfs: add fstest for overwriting a file partially with RST Anand Jain
  2023-12-29 12:34 ` [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Add a test writing 128k to a file on an empty filesystem formatted with a
raid-stripe-tree.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[Fixed the test statement and trailing white space in the .out file.]
---
 tests/btrfs/307     | 59 ++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/307.out | 65 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100755 tests/btrfs/307
 create mode 100644 tests/btrfs/307.out

diff --git a/tests/btrfs/307 b/tests/btrfs/307
new file mode 100755
index 000000000000..30656bcf0d96
--- /dev/null
+++ b/tests/btrfs/307
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Western Digital Cooperation.  All Rights Reserved.
+#
+# FS QA Test 307
+#
+# Test on-disk layout of RAID Stripe Tree Metadata by writing 128k to a new
+# file on a pristine filesystem
+#
+. ./common/preamble
+_begin_fstest auto quick raid remount volume raid-stripe-tree
+
+. ./common/filter
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_mkfs_feature "raid-stripe-tree"
+_require_scratch_dev_pool 4
+_require_btrfs_fs_feature "raid_stripe_tree"
+_require_btrfs_fs_feature "free_space_tree"
+_require_btrfs_free_space_tree
+_require_btrfs_no_compress
+
+test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+
+test_128k_write()
+{
+	local profile=$1
+	local ndevs=$2
+
+	_scratch_dev_pool_get $ndevs
+
+	echo "==== Testing $profile ===="
+	_scratch_pool_mkfs -d $profile -m $profile -O raid-stripe-tree
+	_scratch_mount
+
+	$XFS_IO_PROG -fc "pwrite 0 128k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+
+	_scratch_cycle_mount
+	md5sum "$SCRATCH_MNT/foo" | _filter_scratch
+
+	_scratch_unmount
+
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t raid_stripe $SCRATCH_DEV_POOL |\
+		_filter_trailing_whitespace |\
+		_filter_btrfs_version | _filter_stripe_tree
+
+	_scratch_dev_pool_put
+}
+
+echo "= Test 128k write to empty file  ="
+test_128k_write raid0 2
+test_128k_write raid1 2
+test_128k_write raid10 4
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/307.out b/tests/btrfs/307.out
new file mode 100644
index 000000000000..2815d17d7f03
--- /dev/null
+++ b/tests/btrfs/307.out
@@ -0,0 +1,65 @@
+QA output created by 307
+= Test 128k write to empty file  =
+==== Testing raid0 ====
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid1 ====
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 131072) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid10 ====
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 3 physical XXXXXXXXX
+			stripe 1 devid 4 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
-- 
2.39.3


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

* [PATCH v7 10/10] btrfs: add fstest for overwriting a file partially with RST
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (8 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 09/10] btrfs: add fstests to write 128k to a RST filesystem Anand Jain
@ 2023-12-29 12:22 ` Anand Jain
  2023-12-29 12:34 ` [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:22 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

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

Add a test writing 128k to an empty file with one stripe already
pre-filled on-disk. Then overwrite a portion of the file in the middle.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[Fixed the test statement and trailing white space in the .out file.]
---
 tests/btrfs/308     |  63 ++++++++++++++++++++++++++
 tests/btrfs/308.out | 106 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 169 insertions(+)
 create mode 100755 tests/btrfs/308
 create mode 100644 tests/btrfs/308.out

diff --git a/tests/btrfs/308 b/tests/btrfs/308
new file mode 100755
index 000000000000..7d651b2b4c9c
--- /dev/null
+++ b/tests/btrfs/308
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Western Digital Cooperation.  All Rights Reserved.
+#
+# FS QA Test 308
+#
+# Test on-disk layout of RAID Stripe Tree Metadata by writing 128k to an empty
+# file on a filesystem that has one stripe already pre-filled. Afterwards
+# overwrite a portion of the file.
+#
+. ./common/preamble
+_begin_fstest auto quick raid remount volume raid-stripe-tree
+
+. ./common/filter
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_mkfs_feature "raid-stripe-tree"
+_require_scratch_dev_pool 4
+_require_btrfs_fs_feature "raid_stripe_tree"
+_require_btrfs_fs_feature "free_space_tree"
+_require_btrfs_free_space_tree
+_require_btrfs_no_compress
+_require_btrfs_no_nodatacow
+
+test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+
+test_128k_write_overwrite()
+{
+	local profile=$1
+	local ndevs=$2
+
+	_scratch_dev_pool_get $ndevs
+
+	echo "==== Testing $profile ===="
+	_scratch_pool_mkfs -d $profile -m $profile -O raid-stripe-tree
+	_scratch_mount
+
+	$XFS_IO_PROG -fc "pwrite -W 0 32k" "$SCRATCH_MNT/bar" | _filter_xfs_io
+	$XFS_IO_PROG -fc "pwrite -W 0 128k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+	$XFS_IO_PROG -fc "pwrite -W 64k 8k" "$SCRATCH_MNT/foo" | _filter_xfs_io
+
+	_scratch_cycle_mount
+	md5sum "$SCRATCH_MNT/foo" | _filter_scratch
+
+	_scratch_unmount
+
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t raid_stripe $SCRATCH_DEV_POOL |\
+		_filter_trailing_whitespace |\
+		_filter_btrfs_version | _filter_stripe_tree
+
+	_scratch_dev_pool_put
+}
+
+echo "= Test 128k write to empty file with 1st stripe partially prefilled then overwrite ="
+test_128k_write_overwrite raid0 2
+test_128k_write_overwrite raid1 2
+test_128k_write_overwrite raid10 4
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/308.out b/tests/btrfs/308.out
new file mode 100644
index 000000000000..23b31dd32959
--- /dev/null
+++ b/tests/btrfs/308.out
@@ -0,0 +1,106 @@
+QA output created by 308
+= Test 128k write to empty file with 1st stripe partially prefilled then overwrite =
+==== Testing raid0 ====
+wrote 32768/32768 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 2 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 2 physical XXXXXXXXX
+	item 3 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+	item 4 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 24
+			encoding: RAID0
+			stripe 0 devid 1 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid1 ====
+wrote 32768/32768 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 131072) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 2 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 40
+			encoding: RAID1
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
+==== Testing raid10 ====
+wrote 32768/32768 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 65536
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+d48858312a922db7eb86377f638dbc9f  SCRATCH_MNT/foo
+
+raid stripe tree key (RAID_STRIPE_TREE ROOT_ITEM 0)
+leaf XXXXXXXXX items X free space XXXXX generation X owner RAID_STRIPE_TREE
+leaf XXXXXXXXX flags 0x1(WRITTEN) backref revision 1
+checksum stored <CHECKSUM>
+checksum calced <CHECKSUM>
+fs uuid <UUID>
+chunk uuid <UUID>
+	item 0 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 1 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 2 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 3 physical XXXXXXXXX
+			stripe 1 devid 4 physical XXXXXXXXX
+	item 3 key (XXXXXX RAID_STRIPE 32768) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+	item 4 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 40
+			encoding: RAID10
+			stripe 0 devid 1 physical XXXXXXXXX
+			stripe 1 devid 2 physical XXXXXXXXX
+total bytes XXXXXXXX
+bytes used XXXXXX
+uuid <UUID>
-- 
2.39.3


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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2023-12-29 12:22   ` [PATCH v7 " Anand Jain
  (?)
@ 2023-12-29 12:29   ` Anand Jain
  2023-12-29 12:53     ` Filipe Manana
  -1 siblings, 1 reply; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:29 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

pls ignore this sole patch.

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

* Re: [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature
  2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
                   ` (9 preceding siblings ...)
  2023-12-29 12:22 ` [PATCH v7 10/10] btrfs: add fstest for overwriting a file partially with RST Anand Jain
@ 2023-12-29 12:34 ` Anand Jain
  10 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2023-12-29 12:34 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, johannes.thumshirn

On 29/12/2023 17:52, Anand Jain wrote:
> Changes in v7:
> - Fixed trailing whitespace in the .out files
> - Fixed the following test statement in 30[4-8]:
>       test _get_page_size -eq 4096
> - Link to v6: https://lore.kernel.org/r/20231213-btrfs-raid-v6-0-913738861069@wdc.com
   - Rebased on Zorro's for-next
     Staged at  https://github.com/asj/fstests/tree/ext-rst


> 
> --- original cover page from Johannes ----
> Add tests for btrfs' raid-stripe-tree feature. All of these test work by
> writing a specific pattern to a newly created filesystem and afterwards
> using `btrfs inspect-internal -t raid-stripe $SCRATCH_DEV_POOL` to verify
> the placement and the layout of the metadata.
> 
> The md5sum of each file will be compared as well after a re-mount of the
> filesystem.
> 
> ---
> Changes in v6:
> - require 4k pagesize for all tests as output depends on page size
> - Add Filipe's Reviewed-by
> - Link to v5: https://lore.kernel.org/r/20231207-btrfs-raid-v5-0-44aa1affe856@wdc.com
> 
> Changes in v5:
> - add _require_btrfs_free_space_tree helper and use in tests
> - Link to v4: https://lore.kernel.org/r/20231206-btrfs-raid-v4-0-578284dd3a70@wdc.com
> 
> Changes in v4:
> - add _require_btrfs_no_compress to all tests
> - add _require_btrfs_no_nodatacow helper and add to btrfs/308
> - add _require_btrfs_feature "free_space_tree" to all tests
> - Link to v3: https://lore.kernel.org/r/20231205-btrfs-raid-v3-0-0e857a5439a2@wdc.com
> 
> Changes in v3:
> - added 'raid-stripe-tree' to mkfs options, as only zoned raid gets it
>    automatically
> - Rename test cases as btrfs/302 and btrfs/303 already exist upstream
> - Link to v2: https://lore.kernel.org/r/20231205-btrfs-raid-v2-0-25f80eea345b@wdc.com
> 
> Changes in v2:
> - Re-ordered series so the newly introduced group is added before the
>    tests
> - Changes Filipe requested to the tests.
> - Link to v1: https://lore.kernel.org/r/20231204-btrfs-raid-v1-0-b254eb1bcff8@wdc.com
> 
> Anand Jain (1):
>    common: add _filter_trailing_whitespace
> 
> Johannes Thumshirn (9):
>    fstests: doc: add new raid-stripe-tree group
>    common: add filter for btrfs raid-stripe dump
>    common: add _require_btrfs_no_nodatacow helper
>    common: add _require_btrfs_free_space_tree
>    btrfs: add fstest for stripe-tree metadata with 4k write
>    btrfs: add fstest for 8k write spanning two stripes on
>      raid-stripe-tree
>    btrfs: add fstest for writing to a file at an offset with RST
>    btrfs: add fstests to write 128k to a RST filesystem
>    btrfs: add fstest for overwriting a file partially with RST
> 
>   common/btrfs        |  17 +++++++
>   common/filter       |   5 +++
>   common/filter.btrfs |  14 ++++++
>   doc/group-names.txt |   1 +
>   tests/btrfs/304     |  59 ++++++++++++++++++++++++
>   tests/btrfs/304.out |  58 ++++++++++++++++++++++++
>   tests/btrfs/305     |  64 ++++++++++++++++++++++++++
>   tests/btrfs/305.out |  82 ++++++++++++++++++++++++++++++++++
>   tests/btrfs/306     |  62 ++++++++++++++++++++++++++
>   tests/btrfs/306.out |  75 +++++++++++++++++++++++++++++++
>   tests/btrfs/307     |  59 ++++++++++++++++++++++++
>   tests/btrfs/307.out |  65 +++++++++++++++++++++++++++
>   tests/btrfs/308     |  63 ++++++++++++++++++++++++++
>   tests/btrfs/308.out | 106 ++++++++++++++++++++++++++++++++++++++++++++
>   14 files changed, 730 insertions(+)
>   create mode 100755 tests/btrfs/304
>   create mode 100644 tests/btrfs/304.out
>   create mode 100755 tests/btrfs/305
>   create mode 100644 tests/btrfs/305.out
>   create mode 100755 tests/btrfs/306
>   create mode 100644 tests/btrfs/306.out
>   create mode 100755 tests/btrfs/307
>   create mode 100644 tests/btrfs/307.out
>   create mode 100755 tests/btrfs/308
>   create mode 100644 tests/btrfs/308.out
> 


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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2023-12-29 12:29   ` [PATCH " Anand Jain
@ 2023-12-29 12:53     ` Filipe Manana
  0 siblings, 0 replies; 19+ messages in thread
From: Filipe Manana @ 2023-12-29 12:53 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Fri, Dec 29, 2023 at 12:30 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> pls ignore this sole patch.
>
How can it be ignored if other patches in this patchset that introduce
tests use the filter introduced by this patch?

Thanks.

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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2023-12-29 12:22   ` [PATCH v7 " Anand Jain
  (?)
  (?)
@ 2023-12-29 12:57   ` Filipe Manana
  2024-01-02  8:01     ` Anand Jain
  -1 siblings, 1 reply; 19+ messages in thread
From: Filipe Manana @ 2023-12-29 12:57 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Fri, Dec 29, 2023 at 11:02 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> The command 'btrfs inspect-internal dump-tree -t raid_stripe'
> introduces trailing whitespace in its output.
> Apply a filter to remove it. Used in btrfs/30[4-8][.out].
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  common/filter | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/common/filter b/common/filter
> index 509ee95039ac..016d213b8bee 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -651,5 +651,10 @@ _filter_bash()
>         sed -e "s/^bash: line 1: /bash: /"
>  }
>
> +_filter_trailing_whitespace()
> +{
> +       sed -e "s/ $//"
> +}

If we're having such a generic filter in common file, than I'd rather
have it delete any number of trailing white spaces, not just a single
one, and also account for tabs and other white spaces, so:

sed -e "s/\s+$//"

Also, since this is so specific to the raid stripe tree, I'd rather
have this filter included in the raid stripe tree filter introduced in
patch 2, _filter_stripe_tree(). That would make the tests shorter and
cleaner by avoiding piping yet over another filter that is used only
for the raid stripe tree dump...

Thanks.




> +
>  # make sure this script returns success
>  /bin/true
> --
> 2.39.3
>
>

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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2023-12-29 12:57   ` Filipe Manana
@ 2024-01-02  8:01     ` Anand Jain
  2024-01-02 11:17       ` Filipe Manana
  0 siblings, 1 reply; 19+ messages in thread
From: Anand Jain @ 2024-01-02  8:01 UTC (permalink / raw)
  To: Filipe Manana; +Cc: fstests, linux-btrfs



On 12/29/23 20:57, Filipe Manana wrote:
> On Fri, Dec 29, 2023 at 11:02 AM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> The command 'btrfs inspect-internal dump-tree -t raid_stripe'
>> introduces trailing whitespace in its output.
>> Apply a filter to remove it. Used in btrfs/30[4-8][.out].
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   common/filter | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/common/filter b/common/filter
>> index 509ee95039ac..016d213b8bee 100644
>> --- a/common/filter
>> +++ b/common/filter
>> @@ -651,5 +651,10 @@ _filter_bash()
>>          sed -e "s/^bash: line 1: /bash: /"
>>   }
>>
>> +_filter_trailing_whitespace()
>> +{
>> +       sed -e "s/ $//"
>> +}
> 
> If we're having such a generic filter in common file, than I'd rather
> have it delete any number of trailing white spaces, not just a single
> one, and also account for tabs and other white spaces, so:
> 
> sed -e "s/\s+$//"
> 

  I'll amend.


> Also, since this is so specific to the raid stripe tree, I'd rather
> have this filter included in the raid stripe tree filter introduced in
> patch 2, _filter_stripe_tree(). That would make the tests shorter and
> cleaner by avoiding piping yet over another filter that is used only
> for the raid stripe tree dump...

  I kept this as a separate function so that it can be used elsewhere
  when needed. Doesn't that make sense?

Thanks, Anand

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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2024-01-02  8:01     ` Anand Jain
@ 2024-01-02 11:17       ` Filipe Manana
  2024-01-04  4:02         ` Anand Jain
  0 siblings, 1 reply; 19+ messages in thread
From: Filipe Manana @ 2024-01-02 11:17 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Tue, Jan 2, 2024 at 8:02 AM Anand Jain <anand.jain@oracle.com> wrote:
>
>
>
> On 12/29/23 20:57, Filipe Manana wrote:
> > On Fri, Dec 29, 2023 at 11:02 AM Anand Jain <anand.jain@oracle.com> wrote:
> >>
> >> The command 'btrfs inspect-internal dump-tree -t raid_stripe'
> >> introduces trailing whitespace in its output.
> >> Apply a filter to remove it. Used in btrfs/30[4-8][.out].
> >>
> >> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> >> ---
> >>   common/filter | 5 +++++
> >>   1 file changed, 5 insertions(+)
> >>
> >> diff --git a/common/filter b/common/filter
> >> index 509ee95039ac..016d213b8bee 100644
> >> --- a/common/filter
> >> +++ b/common/filter
> >> @@ -651,5 +651,10 @@ _filter_bash()
> >>          sed -e "s/^bash: line 1: /bash: /"
> >>   }
> >>
> >> +_filter_trailing_whitespace()
> >> +{
> >> +       sed -e "s/ $//"
> >> +}
> >
> > If we're having such a generic filter in common file, than I'd rather
> > have it delete any number of trailing white spaces, not just a single
> > one, and also account for tabs and other white spaces, so:
> >
> > sed -e "s/\s+$//"
> >
>
>   I'll amend.
>
>
> > Also, since this is so specific to the raid stripe tree, I'd rather
> > have this filter included in the raid stripe tree filter introduced in
> > patch 2, _filter_stripe_tree(). That would make the tests shorter and
> > cleaner by avoiding piping yet over another filter that is used only
> > for the raid stripe tree dump...
>
>   I kept this as a separate function so that it can be used elsewhere
>   when needed. Doesn't that make sense?

Not so much if there's only one use case for it... specially if it's
such a trivial filter...

Even if we had multiple cases, doing this pattern in the tests:

$BTRFS_UTIL_PROG inspect-internal dump-tree (... ) |
_filter_trailing_whitespace | _filter_btrfs_version |
_filter_stripe_tree

Is ugly and verbose. The filtering could be done in
_filter_stripe_tree() by calling "_filter_triling_whitespace" there...
And mentioning that, we could also call _filter_btrfs_version there,
since it's always wanted and to make tests shorter and easier to read.

So in the end it would only be

$BTRFS_UTIL_PROG inspect-internal dump-tree (... ) | _filter_stripe_tree

With _filter_stripe_tree() as:

_filter_stripe_tree()
{
    _filter_trailing_whitespace | _filter_btrfs_version | sed -E -e (....)
}

Or:

_filter_stripe_tree()
{
    _filter_btrfs_version | sed -E -e "s/\s+$//" -e (...)
}

A lot more clean.

Thanks.


>
> Thanks, Anand

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

* Re: [PATCH 05/10] common: add _filter_trailing_whitespace
  2024-01-02 11:17       ` Filipe Manana
@ 2024-01-04  4:02         ` Anand Jain
  0 siblings, 0 replies; 19+ messages in thread
From: Anand Jain @ 2024-01-04  4:02 UTC (permalink / raw)
  To: Filipe Manana; +Cc: fstests, linux-btrfs



>>> Also, since this is so specific to the raid stripe tree, I'd rather
>>> have this filter included in the raid stripe tree filter introduced in
>>> patch 2, _filter_stripe_tree(). That would make the tests shorter and
>>> cleaner by avoiding piping yet over another filter that is used only
>>> for the raid stripe tree dump...
>>
>>    I kept this as a separate function so that it can be used elsewhere
>>    when needed. Doesn't that make sense?
> 
> Not so much if there's only one use case for it... specially if it's
> such a trivial filter...
> 

  Hmm. Yes. Also, a completely avoidable coding nitpick in btrfs-progs.

> Even if we had multiple cases, doing this pattern in the tests:
> 
> $BTRFS_UTIL_PROG inspect-internal dump-tree (... ) |
> _filter_trailing_whitespace | _filter_btrfs_version |
> _filter_stripe_tree
> 
> Is ugly and verbose. The filtering could be done in
> _filter_stripe_tree() by calling "_filter_triling_whitespace" there...
> And mentioning that, we could also call _filter_btrfs_version there,
> since it's always wanted and to make tests shorter and easier to read.
> 

  Yeah.

> So in the end it would only be
> 
> $BTRFS_UTIL_PROG inspect-internal dump-tree (... ) | _filter_stripe_tree
> 
> With _filter_stripe_tree() as:
> 
> _filter_stripe_tree()
> {
>      _filter_trailing_whitespace | _filter_btrfs_version | sed -E -e (....)
> }
> 
> Or:
> 
> _filter_stripe_tree()
> {
>      _filter_btrfs_version | sed -E -e "s/\s+$//" -e (...)
> }
> 
> A lot more clean.
> 

  I'm fine with either way. Since there is a choice here, I will keep 
the former.

  I'll send a reroll.

Thanks, Anand


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

end of thread, other threads:[~2024-01-04  4:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-29 12:22 [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain
2023-12-29 11:01 ` [PATCH 05/10] common: add _filter_trailing_whitespace Anand Jain
2023-12-29 12:22   ` [PATCH v7 " Anand Jain
2023-12-29 12:29   ` [PATCH " Anand Jain
2023-12-29 12:53     ` Filipe Manana
2023-12-29 12:57   ` Filipe Manana
2024-01-02  8:01     ` Anand Jain
2024-01-02 11:17       ` Filipe Manana
2024-01-04  4:02         ` Anand Jain
2023-12-29 12:22 ` [PATCH v7 01/10] fstests: doc: add new raid-stripe-tree group Anand Jain
2023-12-29 12:22 ` [PATCH v7 02/10] common: add filter for btrfs raid-stripe dump Anand Jain
2023-12-29 12:22 ` [PATCH v7 03/10] common: add _require_btrfs_no_nodatacow helper Anand Jain
2023-12-29 12:22 ` [PATCH v7 04/10] common: add _require_btrfs_free_space_tree Anand Jain
2023-12-29 12:22 ` [PATCH v7 06/10] btrfs: add fstest for stripe-tree metadata with 4k write Anand Jain
2023-12-29 12:22 ` [PATCH v7 07/10] btrfs: add fstest for 8k write spanning two stripes on raid-stripe-tree Anand Jain
2023-12-29 12:22 ` [PATCH v7 08/10] btrfs: add fstest for writing to a file at an offset with RST Anand Jain
2023-12-29 12:22 ` [PATCH v7 09/10] btrfs: add fstests to write 128k to a RST filesystem Anand Jain
2023-12-29 12:22 ` [PATCH v7 10/10] btrfs: add fstest for overwriting a file partially with RST Anand Jain
2023-12-29 12:34 ` [PATCH v7 0/10] fstests: add tests for btrfs' raid-stripe-tree feature Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.