]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs: add a test for write lifetime hints
authorChristoph Hellwig <hch@lst.de>
Thu, 8 May 2025 05:34:36 +0000 (07:34 +0200)
committerZorro Lang <zlang@kernel.org>
Thu, 8 May 2025 19:17:17 +0000 (03:17 +0800)
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>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/638 [new file with mode: 0755]
tests/xfs/638.out [new file with mode: 0644]

diff --git a/tests/xfs/638 b/tests/xfs/638
new file mode 100755 (executable)
index 0000000..40768c5
--- /dev/null
@@ -0,0 +1,90 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Christoph Hellwig.
+#
+# FS QA Test No. 638
+#
+# 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/638.out b/tests/xfs/638.out
new file mode 100644 (file)
index 0000000..89c0212
--- /dev/null
@@ -0,0 +1,4 @@
+QA output created by 638
+Testing buffered I/O:
+Testing synchronous buffered I/O:
+Testing direct I/O: