linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* new tests for zoned xfs v3
@ 2025-05-08  5:34 Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 01/16] common: generalize _filter_agno Christoph Hellwig
                   ` (16 more replies)
  0 siblings, 17 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Hi all,

this series adds the various new tests for zoned xfs, including testing
data placement.

Changes since v2:
 - generalize the rgroup number filtering helper
 - add back the wp advance test

Changes since v1:
 - drop unneeded _cleanup routines
 - drop _-prefixes for internal functions
 - remove pointless sourcing of filters
 - drop the last new test for now as it doesn't handle internal
   RT device, it will be resent separately

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

* [PATCH 01/16] common: generalize _filter_agno
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08 15:12   ` Darrick J. Wong
  2025-05-08  5:34 ` [PATCH 02/16] add a new rw_hint helper Christoph Hellwig
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Rename and move to common/xfs so that it can be reused for rgnos in new
zoned tests.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 common/filestreams | 11 +----------
 common/xfs         | 10 ++++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/common/filestreams b/common/filestreams
index bb8459405b3e..ace8f3b74de6 100644
--- a/common/filestreams
+++ b/common/filestreams
@@ -42,19 +42,10 @@ _do_stream()
 	done
 }
 
-_filter_agno()
-{
-        # the ag number is in column 4 of xfs_bmap output
-        perl -ne '
-                $ag = (split /\s+/)[4] ;
-		if ($ag =~ /\d+/) {print "$ag "} ;
-        '
-}
-
 _get_stream_ags()
 {
         local directory_name=$1
-        local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
+        local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_bmap_gno`
         echo $stream_ags
 }
 
diff --git a/common/xfs b/common/xfs
index 39650bac6c23..061ca586c84f 100644
--- a/common/xfs
+++ b/common/xfs
@@ -2274,3 +2274,13 @@ _scratch_find_rt_metadir_entry() {
 
 	return 1
 }
+
+# extract the AG/RTG number from xfs_bmap output
+_filter_bmap_gno()
+{
+	# The AG/RG number is in column 4 of xfs_bmap output
+        perl -ne '
+                $ag = (split /\s+/)[4] ;
+		if ($ag =~ /\d+/) {print "$ag "} ;
+        '
+}
-- 
2.47.2


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

* [PATCH 02/16] add a new rw_hint helper
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 01/16] common: generalize _filter_agno Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 03/16] xfs: add a test for zoned block accounting after remount Christoph Hellwig
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Add a tool to set the life time hint via fcntl.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 .gitignore    |  1 +
 src/Makefile  |  3 ++-
 src/rw_hint.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 src/rw_hint.c

diff --git a/.gitignore b/.gitignore
index 4fd817243dca..f22cff8fb6c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -203,6 +203,7 @@ tags
 /src/aio-dio-regress/aio-last-ref-held-by-io
 /src/aio-dio-regress/aiocp
 /src/aio-dio-regress/aiodio_sparse2
+/src/rw_hint
 /src/vfs/vfstest
 /src/vfs/mount-idmapped
 /src/log-writes/replay-log
diff --git a/src/Makefile b/src/Makefile
index 6ac72b366257..2cc1fb40d9f1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -35,7 +35,8 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \
 	fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \
 	detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \
-	uuid_ioctl t_snapshot_deleted_subvolume fiemap-fault min_dio_alignment
+	uuid_ioctl t_snapshot_deleted_subvolume fiemap-fault min_dio_alignment \
+	rw_hint
 
 EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \
 	      btrfs_crc32c_forged_name.py popdir.pl popattr.py \
diff --git a/src/rw_hint.c b/src/rw_hint.c
new file mode 100644
index 000000000000..d4290e4ae369
--- /dev/null
+++ b/src/rw_hint.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 Christoph Hellwig
+ */
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+int main(int argc, char **argv)
+{
+	uint64_t hint = -1;
+	int fd;
+
+	if (argc < 3) {
+		fprintf(stderr,
+"usage: %s file not_set|none|short|medium|long|extreme\n",
+			argv[0]);
+		return 1;
+	}
+
+	if (!strcmp(argv[2], "not_set"))
+		hint = RWH_WRITE_LIFE_NOT_SET;
+	else if (!strcmp(argv[2], "none"))
+		hint = RWH_WRITE_LIFE_NONE;
+	else if (!strcmp(argv[2], "short"))
+		hint = RWH_WRITE_LIFE_SHORT;
+	else if (!strcmp(argv[2], "medium"))
+		hint = RWH_WRITE_LIFE_MEDIUM;
+	else if (!strcmp(argv[2], "long"))
+		hint = RWH_WRITE_LIFE_LONG;
+	else if (!strcmp(argv[2], "extreme"))
+		hint = RWH_WRITE_LIFE_EXTREME;
+
+	if (hint == -1) {
+		fprintf(stderr, "invalid hint %s\n", argv[2]);
+		return 1;
+	}
+
+	fd = open(argv[1], O_WRONLY);
+	if (fd < 0) {
+		perror("open");
+		return 1;
+	}
+	if (fcntl(fd, F_SET_RW_HINT, &hint))
+		perror("fcntl");
+	return 0;
+}
-- 
2.47.2


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

* [PATCH 03/16] xfs: add a test for zoned block accounting after remount
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 01/16] common: generalize _filter_agno Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 02/16] add a new rw_hint helper Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 04/16] xfs: add a zoned growfs test Christoph Hellwig
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test for a problem with an earlier version of the zoned XFS mount code
where freeded blocks in an open zone weren't properly accounted for.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4201     | 40 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4201.out |  6 ++++++
 2 files changed, 46 insertions(+)
 create mode 100755 tests/xfs/4201
 create mode 100644 tests/xfs/4201.out

diff --git a/tests/xfs/4201 b/tests/xfs/4201
new file mode 100755
index 000000000000..5fc27c4d3593
--- /dev/null
+++ b/tests/xfs/4201
@@ -0,0 +1,40 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4201
+#
+# Regression test for mount time accounting of an open zone with freed blocks.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone
+
+_require_scratch
+_require_odirect
+
+#
+# Create a 256MB file system.  This is picked as the lowest common zone size
+# to ensure both files are placed into the same zone.
+#
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mount
+
+dd if=/dev/zero of=$SCRATCH_MNT/test1 oflag=direct conv=fsync bs=1M count=32
+dd if=/dev/zero of=$SCRATCH_MNT/test2 oflag=direct conv=fsync bs=1M count=32
+rm $SCRATCH_MNT/test1
+
+# let delayed inode deactivate do its work
+sleep 1
+df -h $SCRATCH_MNT > $tmp.df.old
+
+_scratch_cycle_mount
+
+echo "Check that df output matches after remount"
+df -h $SCRATCH_MNT > $tmp.df.new
+diff -u $tmp.df.old $tmp.df.new
+
+_scratch_unmount
+
+status=0
+exit
diff --git a/tests/xfs/4201.out b/tests/xfs/4201.out
new file mode 100644
index 000000000000..4cff86d90b0f
--- /dev/null
+++ b/tests/xfs/4201.out
@@ -0,0 +1,6 @@
+QA output created by 4201
+32+0 records in
+32+0 records out
+32+0 records in
+32+0 records out
+Check that df output matches after remount
-- 
2.47.2


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

* [PATCH 04/16] xfs: add a zoned growfs test
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 03/16] xfs: add a test for zoned block accounting after remount Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 05/16] xfs: add test to check for block layer reordering Christoph Hellwig
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Zoned file systems require zone aligned RT volume sizes.  Because of
that xfs/596 won't work as-is.  Copy it and test two zone capacity
aligned values.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4202     | 78 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4202.out | 11 +++++++
 2 files changed, 89 insertions(+)
 create mode 100755 tests/xfs/4202
 create mode 100644 tests/xfs/4202.out

diff --git a/tests/xfs/4202 b/tests/xfs/4202
new file mode 100755
index 000000000000..461827a14522
--- /dev/null
+++ b/tests/xfs/4202
@@ -0,0 +1,78 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2024 Christoph Hellwig
+#
+# FS QA Test No. 4202
+#
+# growfs QA tests - repeatedly fill/grow the rt volume of the filesystem check
+# the filesystem contents after each operation.  This is the zoned equivalent of
+# xfs/596
+#
+. ./common/preamble
+_begin_fstest growfs ioctl auto zone
+
+_cleanup()
+{
+	rm -f $tmp.*
+}
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_realtime
+_require_no_large_scratch_dev
+
+zone_capacity=$(_zone_capacity 0 $SCRATCH_RTDEV)
+
+fill_fs()
+{
+    if [ $# -ne 1 ]; then echo "Usage: fill_fs \"path\"" 1>&2 ; exit 1; fi
+    _do "Fill filesystem" \
+	"$here/src/fill2fs --verbose --dir=$1 --seed=0 --filesize=65536 --stddev=32768 --list=- >>$tmp.manifest"
+}
+
+_do_die_on_error=message_only
+rtsize=$zone_capacity
+echo -n "Make rt filesystem on SCRATCH_DEV and mount... "
+_scratch_mkfs_xfs -r size=${rtsize} | \
+	_filter_mkfs 2> "$tmp.mkfs" >> $seqres.full
+
+# for $dbsize
+. $tmp.mkfs
+
+_scratch_mount
+_require_xfs_scratch_zoned
+
+# We're growing the realtime device, so force new file creation there
+_xfs_force_bdev realtime $SCRATCH_MNT
+
+echo "done"
+
+#
+# Zone RT devices can only grow by entire zones.
+# Do that twice.  The high starting code looks weird, but is neededed
+# due to the automatically added OP
+#
+for size in $(( 6 * $zone_capacity )) $(( 7 * $zone_capacity )); do
+    grow_size=$(( $size / $dbsize ))
+    fill_fs $SCRATCH_MNT/fill_$size
+    _do "Grow filesystem" "xfs_growfs -R $grow_size $SCRATCH_MNT"
+    echo -n "Flush filesystem... "
+    _do "_scratch_unmount"
+    _do "_try_scratch_mount"
+    echo "done"
+    echo -n "Check files... "
+    if ! _do "$here/src/fill2fs_check $tmp.manifest"; then
+      echo "fail (see $seqres.full)"
+      _do "cat $tmp.manifest"
+      _do "ls -altrR $SCRATCH_MNT"
+      status=1 ; exit
+    fi
+    echo "done"
+done
+
+# success, all done
+echo "Growfs tests passed."
+status=0 ; exit
diff --git a/tests/xfs/4202.out b/tests/xfs/4202.out
new file mode 100644
index 000000000000..66cab6aba8e2
--- /dev/null
+++ b/tests/xfs/4202.out
@@ -0,0 +1,11 @@
+QA output created by 4202
+Make rt filesystem on SCRATCH_DEV and mount... done
+Fill filesystem... done
+Grow filesystem... done
+Flush filesystem... done
+Check files... done
+Fill filesystem... done
+Grow filesystem... done
+Flush filesystem... done
+Check files... done
+Growfs tests passed.
-- 
2.47.2


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

* [PATCH 05/16] xfs: add test to check for block layer reordering
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 04/16] xfs: add a zoned growfs test Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 06/16] xfs: add a test to check that data growfs fails with internal rt device Christoph Hellwig
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Zoned writes using zone append can be easily fragmented when the block
layer or the driver reorders I/O.  Check that a simple sequential
direct write creates a single extent.  This was broken in the kernel
until recently when using the ->commit_rqs interface on devices with
a relatively small max_hw_sectors / max_zone_append_sectors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4203     | 37 +++++++++++++++++++++++++++++++++++++
 tests/xfs/4203.out |  5 +++++
 2 files changed, 42 insertions(+)
 create mode 100755 tests/xfs/4203
 create mode 100644 tests/xfs/4203.out

diff --git a/tests/xfs/4203 b/tests/xfs/4203
new file mode 100755
index 000000000000..9f0280c26fc8
--- /dev/null
+++ b/tests/xfs/4203
@@ -0,0 +1,37 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig
+#
+# FS QA Test No. 4203
+#
+# Ensure that direct I/O writes are not pointlessly reordered on zoned
+# devices.
+#
+# This is a regression test for the block layer or drivers reordering
+# writes and thus creating more extents than required.
+#
+. ./common/preamble
+_begin_fstest quick auto rw zone
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_realtime
+
+_scratch_mkfs >/dev/null 2>&1
+
+_scratch_mount
+_require_xfs_scratch_zoned
+_xfs_force_bdev realtime $SCRATCH_MNT
+
+dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=16 oflag=direct
+
+echo "Check extent counts"
+extents=$(_count_extents $SCRATCH_MNT/test)
+
+# There should not be more than a single extent when there are
+# no other concurrent writers
+echo "number of extents: $extents"
+
+status=0
diff --git a/tests/xfs/4203.out b/tests/xfs/4203.out
new file mode 100644
index 000000000000..f5aaece908fa
--- /dev/null
+++ b/tests/xfs/4203.out
@@ -0,0 +1,5 @@
+QA output created by 4203
+16+0 records in
+16+0 records out
+Check extent counts
+number of extents: 1
-- 
2.47.2


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

* [PATCH 06/16] xfs: add a test to check that data growfs fails with internal rt device
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (4 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 05/16] xfs: add test to check for block layer reordering Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 07/16] xfs: add a test for write lifetime hints Christoph Hellwig
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

The internal RT device directly follows the data device on the same
block device.  This implies the data device can't be grown, and growfs
should handle this gracefully.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4204     | 24 ++++++++++++++++++++++++
 tests/xfs/4204.out |  3 +++
 2 files changed, 27 insertions(+)
 create mode 100755 tests/xfs/4204
 create mode 100644 tests/xfs/4204.out

diff --git a/tests/xfs/4204 b/tests/xfs/4204
new file mode 100755
index 000000000000..753c414e38a2
--- /dev/null
+++ b/tests/xfs/4204
@@ -0,0 +1,24 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4204
+#
+# Check that trying to grow a data device followed by the internal RT device
+# fails gracefully with EINVAL.
+#
+. ./common/preamble
+_begin_fstest quick auto growfs ioctl zone
+
+_require_scratch
+_require_zoned_device $SCRATCH_DEV
+
+echo "Creating file system"
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+
+echo "Trying to grow file system (should fail)"
+$XFS_GROWFS_PROG -d $SCRATCH_MNT >>$seqres.full 2>&1
+
+status=0
+exit
diff --git a/tests/xfs/4204.out b/tests/xfs/4204.out
new file mode 100644
index 000000000000..b3593cf60d16
--- /dev/null
+++ b/tests/xfs/4204.out
@@ -0,0 +1,3 @@
+QA output created by 4204
+Creating file system
+Trying to grow file system (should fail)
-- 
2.47.2


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

* [PATCH 07/16] xfs: add a test for write lifetime hints
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (5 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 06/16] xfs: add a test to check that data growfs fails with internal rt device Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 08/16] xfs: add a test for writeback after close Christoph Hellwig
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test that the zone allocator actually places by temperature bucket.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4205     | 90 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4205.out |  4 +++
 2 files changed, 94 insertions(+)
 create mode 100755 tests/xfs/4205
 create mode 100644 tests/xfs/4205.out

diff --git a/tests/xfs/4205 b/tests/xfs/4205
new file mode 100755
index 000000000000..3b05eb4e1dbf
--- /dev/null
+++ b/tests/xfs/4205
@@ -0,0 +1,90 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4205
+#
+# Test data placement by write hints.
+#
+. ./common/preamble
+_begin_fstest auto rw zone
+
+. ./common/filter
+. ./common/xfs
+
+_require_scratch
+
+test_placement()
+{
+	xfs_io_opts=$1
+
+	_scratch_mkfs_xfs >>$seqres.full 2>&1
+	_scratch_mount
+	_require_xfs_scratch_zoned 3
+
+	# Create a bunch of files for the three major temperature buckets
+	for i in `seq 1 100`; do
+		for hint in "short" "medium" "long"; do
+			file=$SCRATCH_MNT/$hint.$i
+
+			touch $file
+			$here/src/rw_hint $file $hint
+			$XFS_IO_PROG ${xfs_io_opts} \
+				-c 'pwrite 0 1m' \
+				$file >>$seqres.full
+		done
+	done
+
+	sync
+
+	# Check that all short lifetime files are placed together
+	short_rg=`xfs_bmap -v $SCRATCH_MNT/short.1 | _filter_bmap_gno`
+	for i in `seq 2 100`; do
+		file=$SCRATCH_MNT/short.$i
+		rg=`xfs_bmap -v $file | _filter_bmap_gno`
+		if [ "${rg}" != "${short_rg}" ]; then
+			echo "short RG mismatch for file $i: $short_rg/$rg"
+		fi
+	done
+
+	# Check that all medium lifetime files are placed together,
+	# but not in the short RG
+	medium_rg=`xfs_bmap -v $SCRATCH_MNT/medium.1 | _filter_bmap_gno`
+	if [ "${medium}" == "${short_rg}" ]; then
+		echo "medium rg == short_rg"
+	fi
+	for i in `seq 2 100`; do
+		file=$SCRATCH_MNT/medium.$i
+		rg=`xfs_bmap -v $file | _filter_bmap_gno`
+		if [ "${rg}" != "${medium_rg}" ]; then
+			echo "medium RG mismatch for file $i: $medium_rg/$rg"
+		fi
+	done
+
+	# Check that none of the long lifetime files are colocated with
+	# short and medium ones
+	for i in `seq 1 100`; do
+		file=$SCRATCH_MNT/long.$i
+		rg=`xfs_bmap -v $file | _filter_bmap_gno`
+		if [ "${rg}" == "${short_rg}" ]; then
+			echo "long file $i placed into short RG "
+		fi
+		if [ "${rg}" == "${medium_rg}" ]; then
+			echo "long file $i placed into medium RG"
+		fi
+	done
+
+	_scratch_unmount
+}
+
+echo "Testing buffered I/O:"
+test_placement ""
+
+echo "Testing synchronous buffered I/O:"
+test_placement "-s"
+
+echo "Testing direct I/O:"
+test_placement "-d"
+
+status=0
+exit
diff --git a/tests/xfs/4205.out b/tests/xfs/4205.out
new file mode 100644
index 000000000000..3331e361a36d
--- /dev/null
+++ b/tests/xfs/4205.out
@@ -0,0 +1,4 @@
+QA output created by 4205
+Testing buffered I/O:
+Testing synchronous buffered I/O:
+Testing direct I/O:
-- 
2.47.2


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

* [PATCH 08/16] xfs: add a test for writeback after close
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (6 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 07/16] xfs: add a test for write lifetime hints Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 09/16] xfs: test zone stream separation for two direct writers Christoph Hellwig
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test that files written back after closing are packed tightly instead of
using up open zone resources.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4206     | 41 +++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4206.out |  1 +
 2 files changed, 42 insertions(+)
 create mode 100755 tests/xfs/4206
 create mode 100644 tests/xfs/4206.out

diff --git a/tests/xfs/4206 b/tests/xfs/4206
new file mode 100755
index 000000000000..aa352d674398
--- /dev/null
+++ b/tests/xfs/4206
@@ -0,0 +1,41 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4206
+#
+# Test that data is packed tighly for writeback after the files were
+# closed.
+#
+. ./common/preamble
+_begin_fstest auto quick rw zone
+
+. ./common/xfs
+
+_require_scratch
+
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+_require_xfs_scratch_zoned
+
+# Create a bunch of small files
+for i in `seq 1 100`; do
+	file=$SCRATCH_MNT/$i
+
+	$XFS_IO_PROG -f -c 'pwrite 0 8k' $file >>$seqres.full
+done
+
+sync
+
+# Check that all small files are placed together
+short_rg=`xfs_bmap -v $SCRATCH_MNT/1 | _filter_bmap_gno`
+for i in `seq 2 100`; do
+	file=$SCRATCH_MNT/$i
+	rg=`xfs_bmap -v $file | _filter_bmap_gno`
+	if [ "${rg}" != "${short_rg}" ]; then
+		echo "RG mismatch for file $i: $short_rg/$rg"
+	fi
+done
+
+status=0
+exit
diff --git a/tests/xfs/4206.out b/tests/xfs/4206.out
new file mode 100644
index 000000000000..4835b5053ae5
--- /dev/null
+++ b/tests/xfs/4206.out
@@ -0,0 +1 @@
+QA output created by 4206
-- 
2.47.2


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

* [PATCH 09/16] xfs: test zone stream separation for two direct writers
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (7 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 08/16] xfs: add a test for writeback after close Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 10/16] xfs: test zone stream separation for two buffered writers Christoph Hellwig
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Check that two parallel direct sequential writers are separated into
different zones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4207     | 65 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4207.out |  3 +++
 2 files changed, 68 insertions(+)
 create mode 100755 tests/xfs/4207
 create mode 100644 tests/xfs/4207.out

diff --git a/tests/xfs/4207 b/tests/xfs/4207
new file mode 100755
index 000000000000..cb5a2bb1f9e2
--- /dev/null
+++ b/tests/xfs/4207
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4207
+#
+# Test that multiple direct I/O write streams are directed to separate zones.
+#
+. ./common/preamble
+_begin_fstest quick auto rw zone
+
+. ./common/xfs
+
+_require_scratch
+_require_odirect
+_require_aio
+
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+_require_xfs_scratch_zoned 3
+
+fio_config=$tmp.fio
+fio_out=$tmp.fio.out
+fio_err=$tmp.fio.err
+
+cat >$fio_config <<EOF
+[global]
+bs=64k
+iodepth=16
+iodepth_batch=8
+size=1m
+directory=$SCRATCH_MNT
+ioengine=libaio
+rw=write
+direct=1
+
+[file1]
+filename=file1
+size=128m
+
+[file2]
+filename=file2
+size=128m
+EOF
+
+_require_fio $fio_config
+
+$FIO_PROG $fio_config --output=$fio_out
+cat $fio_out >> $seqres.full
+
+# Check the files only have a single extent each and are in separate zones
+extents1=$(_count_extents $SCRATCH_MNT/file1)
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+
+echo "number of file 1 extents: $extents1"
+echo "number of file 2 extents: $extents2"
+
+rg1=`xfs_bmap -v $SCRATCH_MNT/file1 | _filter_bmap_gno`
+rg2=`xfs_bmap -v $SCRATCH_MNT/file2 | _filter_bmap_gno`
+if [ "${rg1}" == "${rg2}" ]; then
+	echo "same RG used for both files"
+fi
+
+status=0
+exit
diff --git a/tests/xfs/4207.out b/tests/xfs/4207.out
new file mode 100644
index 000000000000..5d33658de474
--- /dev/null
+++ b/tests/xfs/4207.out
@@ -0,0 +1,3 @@
+QA output created by 4207
+number of file 1 extents: 1
+number of file 2 extents: 1
-- 
2.47.2


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

* [PATCH 10/16] xfs: test zone stream separation for two buffered writers
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (8 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 09/16] xfs: test zone stream separation for two direct writers Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 11/16] xfs: test zoned ENOSPC behavior with multiple writers Christoph Hellwig
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Check that two parallel buffered sequential writers are separated into
different zones when writeback happens before closing the files.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4208     | 65 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4208.out |  3 +++
 2 files changed, 68 insertions(+)
 create mode 100755 tests/xfs/4208
 create mode 100644 tests/xfs/4208.out

diff --git a/tests/xfs/4208 b/tests/xfs/4208
new file mode 100755
index 000000000000..b67422b5bbc0
--- /dev/null
+++ b/tests/xfs/4208
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4208
+#
+# Test that multiple buffered I/O write streams are directed to separate zones
+# when written back with the file still open.
+#
+. ./common/preamble
+_begin_fstest quick auto rw zone
+
+. ./common/xfs
+
+_require_scratch
+_require_odirect
+_require_aio
+
+_scratch_mkfs_xfs >>$seqres.full 2>&1
+_scratch_mount
+_require_xfs_scratch_zoned 3
+
+fio_config=$tmp.fio
+fio_out=$tmp.fio.out
+fio_err=$tmp.fio.err
+
+cat >$fio_config <<EOF
+[global]
+bs=64k
+iodepth=16
+iodepth_batch=8
+size=1m
+directory=$SCRATCH_MNT
+rw=write
+fsync_on_close=1
+
+[file1]
+filename=file1
+size=128m
+
+[file2]
+filename=file2
+size=128m
+EOF
+
+_require_fio $fio_config
+
+$FIO_PROG $fio_config --output=$fio_out
+cat $fio_out >> $seqres.full
+
+# Check the files only have a single extent each and are in separate zones
+extents1=$(_count_extents $SCRATCH_MNT/file1)
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+
+echo "number of file 1 extents: $extents1"
+echo "number of file 2 extents: $extents2"
+
+rg1=`xfs_bmap -v $SCRATCH_MNT/file1 | _filter_bmap_gno`
+rg2=`xfs_bmap -v $SCRATCH_MNT/file2 | _filter_bmap_gno`
+if [ "${rg1}" == "${rg2}" ]; then
+	echo "same RG used for both files"
+fi
+
+status=0
+exit
diff --git a/tests/xfs/4208.out b/tests/xfs/4208.out
new file mode 100644
index 000000000000..1aaea308fe6a
--- /dev/null
+++ b/tests/xfs/4208.out
@@ -0,0 +1,3 @@
+QA output created by 4208
+number of file 1 extents: 1
+number of file 2 extents: 1
-- 
2.47.2


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

* [PATCH 11/16] xfs: test zoned ENOSPC behavior with multiple writers
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (9 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 10/16] xfs: test zone stream separation for two buffered writers Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 12/16] xfs: test zoned GC file defragmentation for sequential writers Christoph Hellwig
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test that multiple parallel writers can't accidentally dip into the reserved
space pool.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4209     | 85 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4209.out |  2 ++
 2 files changed, 87 insertions(+)
 create mode 100755 tests/xfs/4209
 create mode 100644 tests/xfs/4209.out

diff --git a/tests/xfs/4209 b/tests/xfs/4209
new file mode 100755
index 000000000000..57fef69b49e7
--- /dev/null
+++ b/tests/xfs/4209
@@ -0,0 +1,85 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4209
+#
+# Test that multiple parallel writers can't accidentally dip into the reserved
+# space pool.
+#
+. ./common/preamble
+_begin_fstest quick auto rw zone enospc
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_odirect
+_require_aio
+
+_scratch_mkfs_sized $((256 * 1024 * 1024))  >>$seqres.full 2>&1
+
+# limit to two max open zones so that all writes get thrown into the blender
+export MOUNT_OPTIONS="$MOUNT_OPTIONS -o max_open_zones=2"
+_try_scratch_mount || _notrun "mount option not supported"
+_require_xfs_scratch_zoned
+
+fio_config=$tmp.fio
+
+cat >$fio_config <<EOF
+[global]
+bs=64k
+iodepth=16
+iodepth_batch=8
+directory=$SCRATCH_MNT
+ioengine=libaio
+rw=write
+direct=1
+size=60m
+
+[file1]
+filename=file1
+
+[file2]
+filename=file2
+
+[file3]
+filename=file3
+
+[file4]
+filename=file4
+
+[file5]
+filename=file5
+
+[file6]
+filename=file6
+
+[file7]
+filename=file7
+
+[file8]
+filename=file8
+EOF
+
+_require_fio $fio_config
+
+# try to overfill the file system
+$FIO_PROG $fio_config 2>&1 | \
+	grep -q "No space left on dev" || \
+	_fail "Overfill did not cause ENOSPC"
+
+sync
+
+#
+# Compare the df and du values to ensure we did not overshoot
+#
+# Use within_tolerance to paper over the fact that the du output includes
+# the root inode, which does not sit in the RT device, while df does not
+#
+df_val=`df --output=size $SCRATCH_MNT | tail -n 1`
+du_val=`du -s $SCRATCH_MNT | awk '{print $1}'`
+_within_tolerance "file space usage" $df_val $du_val 64 -v
+
+status=0
+exit
diff --git a/tests/xfs/4209.out b/tests/xfs/4209.out
new file mode 100644
index 000000000000..cb72138a1bf6
--- /dev/null
+++ b/tests/xfs/4209.out
@@ -0,0 +1,2 @@
+QA output created by 4209
+file space usage is in range
-- 
2.47.2


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

* [PATCH 12/16] xfs: test zoned GC file defragmentation for sequential writers
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (10 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 11/16] xfs: test zoned ENOSPC behavior with multiple writers Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 13/16] xfs: test zoned GC file defragmentation for random writers Christoph Hellwig
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test that zoned GC defragments sequential writers forced into the same
zone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4210     | 119 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4210.out |   5 ++
 2 files changed, 124 insertions(+)
 create mode 100755 tests/xfs/4210
 create mode 100644 tests/xfs/4210.out

diff --git a/tests/xfs/4210 b/tests/xfs/4210
new file mode 100755
index 000000000000..3311f5365c9f
--- /dev/null
+++ b/tests/xfs/4210
@@ -0,0 +1,119 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4210
+#
+# Test that GC defragments sequentially written files.
+#
+. ./common/preamble
+_begin_fstest auto rw zone
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_odirect
+_require_aio
+
+_scratch_mkfs_sized $((256 * 1024 * 1024))  >>$seqres.full 2>&1
+
+# limit to two max open zones so that all writes get thrown into the blender
+export MOUNT_OPTIONS="$MOUNT_OPTIONS -o max_open_zones=2"
+_try_scratch_mount || _notrun "mount option not supported"
+_require_xfs_scratch_zoned
+
+fio_config=$tmp.fio
+fio_out=$tmp.fio.out
+fio_err=$tmp.fio.err
+
+cat >$fio_config <<EOF
+[global]
+bs=64k
+iodepth=16
+iodepth_batch=8
+directory=$SCRATCH_MNT
+ioengine=libaio
+rw=write
+direct=1
+size=30m
+
+[file1]
+filename=file1
+
+[file2]
+filename=file2
+
+[file3]
+filename=file3
+
+[file4]
+filename=file4
+
+[file5]
+filename=file5
+
+[file6]
+filename=file6
+
+[file7]
+filename=file7
+
+[file8]
+filename=file8
+EOF
+
+_require_fio $fio_config
+
+# create fragmented files
+$FIO_PROG $fio_config --output=$fio_out
+cat $fio_out >> $seqres.full
+
+# fill up all remaining user capacity
+dd if=/dev/zero of=$SCRATCH_MNT/fill bs=4k >> $seqres.full 2>&1
+
+sync
+
+# all files should be badly fragmented now
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+echo "number of file 2 extents: $extents2" >>$seqres.full
+test $extents2 -gt 200 || _fail "fio did not fragment file"
+
+extents4=$(_count_extents $SCRATCH_MNT/file4)
+echo "number of file 4 extents: $extents4" >>$seqres.full
+test $extents4 -gt 200 || _fail "fio did not fragment file"
+
+extents6=$(_count_extents $SCRATCH_MNT/file6)
+echo "number of file 6 extents: $extents6" >>$seqres.full
+test $extents6 -gt 200 || _fail "fio did not fragment file"
+
+extents8=$(_count_extents $SCRATCH_MNT/file8)
+echo "number of file 8 extents: $extents8" >>$seqres.full
+test $extents8 -gt 200 || _fail "fio did not fragment file"
+
+# remove half of the files to create work for GC
+rm $SCRATCH_MNT/file1
+rm $SCRATCH_MNT/file3
+rm $SCRATCH_MNT/file5
+rm $SCRATCH_MNT/file7
+
+# fill up all remaining user capacity a few times to force GC
+for i in `seq 1 10`; do
+	dd if=/dev/zero of=$SCRATCH_MNT/fill bs=4k >> $seqres.full 2>&1
+	$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/fill >> $seqres.full 2>&1
+done
+
+#
+# All files should have a no more than a handful of extents now
+#
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+_within_tolerance "file 2 extents" $extents2 3 2 -v
+extents4=$(_count_extents $SCRATCH_MNT/file4)
+_within_tolerance "file 4 extents" $extents4 3 2 -v
+extents6=$(_count_extents $SCRATCH_MNT/file6)
+_within_tolerance "file 6 extents" $extents6 3 2 -v
+extents8=$(_count_extents $SCRATCH_MNT/file8)
+_within_tolerance "file 8 extents" $extents8 3 2 -v
+
+status=0
+exit
diff --git a/tests/xfs/4210.out b/tests/xfs/4210.out
new file mode 100644
index 000000000000..488dd9db790b
--- /dev/null
+++ b/tests/xfs/4210.out
@@ -0,0 +1,5 @@
+QA output created by 4210
+file 2 extents is in range
+file 4 extents is in range
+file 6 extents is in range
+file 8 extents is in range
-- 
2.47.2


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

* [PATCH 13/16] xfs: test zoned GC file defragmentation for random writers
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (11 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 12/16] xfs: test zoned GC file defragmentation for sequential writers Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 14/16] xfs: test that xfs_repair does not mess up the zone used counter Christoph Hellwig
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Test that zoned GC defragments sequential writers forced into the same
zone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4211     | 124 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4211.out |   5 ++
 2 files changed, 129 insertions(+)
 create mode 100755 tests/xfs/4211
 create mode 100644 tests/xfs/4211.out

diff --git a/tests/xfs/4211 b/tests/xfs/4211
new file mode 100755
index 000000000000..2b88e3bc3730
--- /dev/null
+++ b/tests/xfs/4211
@@ -0,0 +1,124 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4211
+#
+# Test that GC defragments randomly written files.
+#
+. ./common/preamble
+_begin_fstest auto rw zone
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_odirect
+_require_aio
+
+_scratch_mkfs_sized $((256 * 1024 * 1024))  >>$seqres.full 2>&1
+
+# limit to two max open zones so that all writes get thrown into the blender
+export MOUNT_OPTIONS="$MOUNT_OPTIONS -o max_open_zones=2"
+_try_scratch_mount || _notrun "mount option not supported"
+_require_xfs_scratch_zoned
+
+fio_config=$tmp.fio
+fio_out=$tmp.fio.out
+fio_err=$tmp.fio.err
+
+cat >$fio_config <<EOF
+[global]
+bs=64k
+iodepth=16
+iodepth_batch=8
+directory=$SCRATCH_MNT
+ioengine=libaio
+rw=randwrite
+direct=1
+size=30m
+
+[file1]
+filename=file1
+
+[file2]
+filename=file2
+
+[file3]
+filename=file3
+
+[file4]
+filename=file4
+
+[file5]
+filename=file5
+
+[file6]
+filename=file6
+
+[file7]
+filename=file7
+
+[file8]
+filename=file8
+EOF
+
+_require_fio $fio_config
+
+# create fragmented files
+$FIO_PROG $fio_config --output=$fio_out
+cat $fio_out >> $seqres.full
+
+# fill up all remaining user capacity
+dd if=/dev/zero of=$SCRATCH_MNT/fill bs=4k >> $seqres.full 2>&1
+
+sync
+
+# all files should be badly fragmented now
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+echo "number of file 2 extents: $extents2" >>$seqres.full
+test $extents2 -gt 200 || _fail "fio did not fragment file"
+
+extents4=$(_count_extents $SCRATCH_MNT/file4)
+echo "number of file 4 extents: $extents4" >>$seqres.full
+test $extents4 -gt 200 || _fail "fio did not fragment file"
+
+extents6=$(_count_extents $SCRATCH_MNT/file6)
+echo "number of file 6 extents: $extents6" >>$seqres.full
+test $extents6 -gt 200 || _fail "fio did not fragment file"
+
+extents8=$(_count_extents $SCRATCH_MNT/file8)
+echo "number of file 8 extents: $extents8" >>$seqres.full
+test $extents8 -gt 200 || _fail "fio did not fragment file"
+
+# remove half of the files to create work for GC
+rm $SCRATCH_MNT/file1
+rm $SCRATCH_MNT/file3
+rm $SCRATCH_MNT/file5
+rm $SCRATCH_MNT/file7
+
+#
+# Fill up all remaining user capacity a few times to force GC.
+#
+# This needs to be a very large number of larger zones sizes that have a lot
+# of OP for the small file system size
+#
+for i in `seq 1 200`; do
+	dd if=/dev/zero of=$SCRATCH_MNT/fill bs=4k >> $seqres.full 2>&1
+	$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/fill >> $seqres.full 2>&1
+done
+
+#
+# All files should have a no more than a handful of extents now
+#
+extents2=$(_count_extents $SCRATCH_MNT/file2)
+_within_tolerance "file 2 extents" $extents2 3 2 -v
+extents4=$(_count_extents $SCRATCH_MNT/file4)
+_within_tolerance "file 4 extents" $extents4 3 2 -v
+extents6=$(_count_extents $SCRATCH_MNT/file6)
+_within_tolerance "file 6 extents" $extents6 3 2 -v
+extents8=$(_count_extents $SCRATCH_MNT/file8)
+_within_tolerance "file 8 extents" $extents8 3 2 -v
+
+status=0
+exit
diff --git a/tests/xfs/4211.out b/tests/xfs/4211.out
new file mode 100644
index 000000000000..348e59950a47
--- /dev/null
+++ b/tests/xfs/4211.out
@@ -0,0 +1,5 @@
+QA output created by 4211
+file 2 extents is in range
+file 4 extents is in range
+file 6 extents is in range
+file 8 extents is in range
-- 
2.47.2


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

* [PATCH 14/16] xfs: test that xfs_repair does not mess up the zone used counter
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (12 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 13/16] xfs: test zoned GC file defragmentation for random writers Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 15/16] xfs: test that truncate does not spuriously return ENOSPC Christoph Hellwig
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

Check that xfs_repair actually rebuilds the used counter after blowing
away the rmap inode and recreating it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4212     | 32 ++++++++++++++++++++++++++++++++
 tests/xfs/4212.out |  5 +++++
 2 files changed, 37 insertions(+)
 create mode 100755 tests/xfs/4212
 create mode 100644 tests/xfs/4212.out

diff --git a/tests/xfs/4212 b/tests/xfs/4212
new file mode 100755
index 000000000000..f392a978c7a6
--- /dev/null
+++ b/tests/xfs/4212
@@ -0,0 +1,32 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4212
+#
+# Regression test for xfs_repair messing up the per-zone used counter.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone repair
+
+_require_scratch
+_require_odirect
+
+_scratch_mkfs >> $seqres.full 2>&1
+_scratch_mount
+
+dd if=/dev/zero of=$SCRATCH_MNT/test1 oflag=direct bs=1M count=64
+
+_scratch_unmount
+
+echo "Repairing"
+_scratch_xfs_repair 2>> $seqres.full
+
+echo "Removing file after repair"
+_scratch_mount
+rm -f $SCRATCH_MNT/test1
+_scratch_unmount
+
+status=0
+exit
diff --git a/tests/xfs/4212.out b/tests/xfs/4212.out
new file mode 100644
index 000000000000..70a45a381f2d
--- /dev/null
+++ b/tests/xfs/4212.out
@@ -0,0 +1,5 @@
+QA output created by 4212
+64+0 records in
+64+0 records out
+Repairing
+Removing file after repair
-- 
2.47.2


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

* [PATCH 15/16] xfs: test that truncate does not spuriously return ENOSPC
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (13 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 14/16] xfs: test that xfs_repair does not mess up the zone used counter Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08  5:34 ` [PATCH 16/16] xfs: test that we can handle spurious zone wp advancements Christoph Hellwig
  2025-05-08 18:43 ` new tests for zoned xfs v3 Zorro Lang
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

For zoned file systems, truncate to an offset not aligned to the block
size need to allocate a new block for zeroing the remainder.

Test that this allocation can dip into the reserved pool even when other
threads are waiting for space freed by GC.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4213     | 37 +++++++++++++++++++++++++++++++++++++
 tests/xfs/4213.out |  1 +
 2 files changed, 38 insertions(+)
 create mode 100755 tests/xfs/4213
 create mode 100644 tests/xfs/4213.out

diff --git a/tests/xfs/4213 b/tests/xfs/4213
new file mode 100755
index 000000000000..a99a34a1a220
--- /dev/null
+++ b/tests/xfs/4213
@@ -0,0 +1,37 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 4213
+#
+# Ensure that a truncate that needs to zero the EOFblock doesn't get ENOSPC
+# when another thread is waiting for space to become available through GC.
+#
+. ./common/preamble
+_begin_fstest auto rw zone
+
+. ./common/zoned
+
+_require_scratch
+
+_scratch_mkfs_sized $((256 * 1024 * 1024))  >>$seqres.full 2>&1
+_scratch_mount
+_require_xfs_scratch_zoned
+
+for i in `seq 1 20`; do
+	# fill up all user capacity
+	PUNCH_FILE=$SCRATCH_MNT/punch.$i
+	TEST_FILE=$SCRATCH_MNT/file.$i
+
+	dd if=/dev/zero of=$PUNCH_FILE bs=1M count=128 conv=fdatasync \
+		>> $seqres.full 2>&1
+
+	dd if=/dev/zero of=$TEST_FILE bs=4k >> $seqres.full 2>&1 &
+	# truncate to a value not rounded to the block size
+	$XFS_IO_PROG -c "truncate 3275" $PUNCH_FILE
+	sync $SCRATCH_MNT
+	rm -f $TEST_FILE
+done
+
+status=0
+exit
diff --git a/tests/xfs/4213.out b/tests/xfs/4213.out
new file mode 100644
index 000000000000..acf8716f9e13
--- /dev/null
+++ b/tests/xfs/4213.out
@@ -0,0 +1 @@
+QA output created by 4213
-- 
2.47.2


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

* [PATCH 16/16] xfs: test that we can handle spurious zone wp advancements
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (14 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 15/16] xfs: test that truncate does not spuriously return ENOSPC Christoph Hellwig
@ 2025-05-08  5:34 ` Christoph Hellwig
  2025-05-08 18:43 ` new tests for zoned xfs v3 Zorro Lang
  16 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-05-08  5:34 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs, Hans Holmberg

From: Hans Holmberg <Hans.Holmberg@wdc.com>

Test that we can gracefully handle spurious zone write pointer
advancements while unmounted.

Any space covered by the wp unexpectedly moving forward should just
be treated as unused space, so check that we can still mount the file
system and that the zone will be reset when all used blocks have been
freed.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 tests/xfs/4214     | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4214.out |  2 ++
 2 files changed, 73 insertions(+)
 create mode 100755 tests/xfs/4214
 create mode 100644 tests/xfs/4214.out

diff --git a/tests/xfs/4214 b/tests/xfs/4214
new file mode 100755
index 000000000000..f5262a40b229
--- /dev/null
+++ b/tests/xfs/4214
@@ -0,0 +1,71 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 4214
+#
+# Test that we can gracefully handle spurious zone write pointer
+# advancements while unmounted.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone
+
+# Import common functions.
+. ./common/zoned
+
+_require_scratch
+_require_realtime
+
+#
+# Figure out if the rt section is internal or not
+#
+if [ -z "$SCRATCH_RTDEV" ]; then
+	zdev=$SCRATCH_DEV
+else
+	zdev=$SCRATCH_RTDEV
+fi
+
+_require_zoned_device $zdev
+_require_command "$BLKZONE_PROG" blkzone
+
+_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+blksz=$(_get_file_block_size $SCRATCH_MNT)
+
+test_file=$SCRATCH_MNT/test.dat
+dd if=/dev/zero of=$test_file bs=1M count=16 oflag=direct >> $seqres.full 2>&1 \
+	|| _fail "file creation failed"
+
+_scratch_unmount
+
+#
+# Figure out which zone was opened to store the test file and where
+# the write pointer is in that zone
+#
+open_zone=$($BLKZONE_PROG report $zdev | \
+	$AWK_PROG '/oi/ { print $2 }' | sed 's/,//')
+open_zone_wp=$($BLKZONE_PROG report $zdev | \
+	grep "start: $open_zone" | $AWK_PROG '{ print $8 }')
+wp=$(( $open_zone + $open_zone_wp ))
+
+# Advance the write pointer manually by one block
+dd if=/dev/zero of=$zdev bs=$blksz count=1 seek=$(($wp * 512 / $blksz)) \
+	oflag=direct >> $seqres.full 2>&1 || _fail "wp advancement failed"
+
+_scratch_mount
+_scratch_unmount
+
+# Finish the open zone
+$BLKZONE_PROG finish -c 1 -o $open_zone $zdev
+
+_scratch_mount
+rm $test_file
+_scratch_unmount
+
+# The previously open zone, now finished and unused, should have been reset
+nr_open=$($BLKZONE_PROG report $zdev | grep -wc "oi")
+echo "Number of open zones: $nr_open"
+
+status=0
+exit
diff --git a/tests/xfs/4214.out b/tests/xfs/4214.out
new file mode 100644
index 000000000000..a746546bc8f6
--- /dev/null
+++ b/tests/xfs/4214.out
@@ -0,0 +1,2 @@
+QA output created by 4214
+Number of open zones: 0
-- 
2.47.2


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

* Re: [PATCH 01/16] common: generalize _filter_agno
  2025-05-08  5:34 ` [PATCH 01/16] common: generalize _filter_agno Christoph Hellwig
@ 2025-05-08 15:12   ` Darrick J. Wong
  0 siblings, 0 replies; 19+ messages in thread
From: Darrick J. Wong @ 2025-05-08 15:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Zorro Lang, Hans Holmberg, fstests, linux-xfs

On Thu, May 08, 2025 at 07:34:30AM +0200, Christoph Hellwig wrote:
> Rename and move to common/xfs so that it can be reused for rgnos in new
> zoned tests.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  common/filestreams | 11 +----------
>  common/xfs         | 10 ++++++++++
>  2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/common/filestreams b/common/filestreams
> index bb8459405b3e..ace8f3b74de6 100644
> --- a/common/filestreams
> +++ b/common/filestreams
> @@ -42,19 +42,10 @@ _do_stream()
>  	done
>  }
>  
> -_filter_agno()
> -{
> -        # the ag number is in column 4 of xfs_bmap output
> -        perl -ne '
> -                $ag = (split /\s+/)[4] ;
> -		if ($ag =~ /\d+/) {print "$ag "} ;
> -        '
> -}
> -
>  _get_stream_ags()
>  {
>          local directory_name=$1
> -        local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
> +        local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_bmap_gno`
>          echo $stream_ags
>  }
>  
> diff --git a/common/xfs b/common/xfs
> index 39650bac6c23..061ca586c84f 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -2274,3 +2274,13 @@ _scratch_find_rt_metadir_entry() {
>  
>  	return 1
>  }
> +
> +# extract the AG/RTG number from xfs_bmap output
> +_filter_bmap_gno()
> +{
> +	# The AG/RG number is in column 4 of xfs_bmap output
> +        perl -ne '
> +                $ag = (split /\s+/)[4] ;
> +		if ($ag =~ /\d+/) {print "$ag "} ;
> +        '
> +}
> -- 
> 2.47.2
> 
> 

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

* Re: new tests for zoned xfs v3
  2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
                   ` (15 preceding siblings ...)
  2025-05-08  5:34 ` [PATCH 16/16] xfs: test that we can handle spurious zone wp advancements Christoph Hellwig
@ 2025-05-08 18:43 ` Zorro Lang
  16 siblings, 0 replies; 19+ messages in thread
From: Zorro Lang @ 2025-05-08 18:43 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Darrick J. Wong, Hans Holmberg, fstests, linux-xfs

On Thu, May 08, 2025 at 07:34:29AM +0200, Christoph Hellwig wrote:
> Hi all,
> 
> this series adds the various new tests for zoned xfs, including testing
> data placement.
> 
> Changes since v2:
>  - generalize the rgroup number filtering helper
>  - add back the wp advance test

Thanks, this version is good to me now.

Reviewed-by: Zorro Lang <zlang@redhat.com>

> 
> Changes since v1:
>  - drop unneeded _cleanup routines
>  - drop _-prefixes for internal functions
>  - remove pointless sourcing of filters
>  - drop the last new test for now as it doesn't handle internal
>    RT device, it will be resent separately
> 

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

end of thread, other threads:[~2025-05-08 18:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08  5:34 new tests for zoned xfs v3 Christoph Hellwig
2025-05-08  5:34 ` [PATCH 01/16] common: generalize _filter_agno Christoph Hellwig
2025-05-08 15:12   ` Darrick J. Wong
2025-05-08  5:34 ` [PATCH 02/16] add a new rw_hint helper Christoph Hellwig
2025-05-08  5:34 ` [PATCH 03/16] xfs: add a test for zoned block accounting after remount Christoph Hellwig
2025-05-08  5:34 ` [PATCH 04/16] xfs: add a zoned growfs test Christoph Hellwig
2025-05-08  5:34 ` [PATCH 05/16] xfs: add test to check for block layer reordering Christoph Hellwig
2025-05-08  5:34 ` [PATCH 06/16] xfs: add a test to check that data growfs fails with internal rt device Christoph Hellwig
2025-05-08  5:34 ` [PATCH 07/16] xfs: add a test for write lifetime hints Christoph Hellwig
2025-05-08  5:34 ` [PATCH 08/16] xfs: add a test for writeback after close Christoph Hellwig
2025-05-08  5:34 ` [PATCH 09/16] xfs: test zone stream separation for two direct writers Christoph Hellwig
2025-05-08  5:34 ` [PATCH 10/16] xfs: test zone stream separation for two buffered writers Christoph Hellwig
2025-05-08  5:34 ` [PATCH 11/16] xfs: test zoned ENOSPC behavior with multiple writers Christoph Hellwig
2025-05-08  5:34 ` [PATCH 12/16] xfs: test zoned GC file defragmentation for sequential writers Christoph Hellwig
2025-05-08  5:34 ` [PATCH 13/16] xfs: test zoned GC file defragmentation for random writers Christoph Hellwig
2025-05-08  5:34 ` [PATCH 14/16] xfs: test that xfs_repair does not mess up the zone used counter Christoph Hellwig
2025-05-08  5:34 ` [PATCH 15/16] xfs: test that truncate does not spuriously return ENOSPC Christoph Hellwig
2025-05-08  5:34 ` [PATCH 16/16] xfs: test that we can handle spurious zone wp advancements Christoph Hellwig
2025-05-08 18:43 ` new tests for zoned xfs v3 Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).