On Thu, May 01, 2025 at 08:42:43AM -0500, Christoph Hellwig wrote: > Test that the zone allocator actually places by temperature bucket. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > --- > tests/xfs/4205 | 105 +++++++++++++++++++++++++++++++++++++++++++++ > tests/xfs/4205.out | 4 ++ > 2 files changed, 109 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..be508806ec0a > --- /dev/null > +++ b/tests/xfs/4205 > @@ -0,0 +1,105 @@ > +#! /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 > + > +_cleanup() > +{ > + cd / > + _scratch_unmount >/dev/null 2>&1 Is this unmount necessary here? If not, this _cleanup can be removed. > +} > + > +# Import common functions. > +. ./common/filter > + > +_require_scratch > + > +_filter_rgno() > +{ > + # the rg number is in column 4 of xfs_bmap output > + perl -ne ' > + $rg = (split /\s+/)[4] ; > + if ($rg =~ /\d+/) {print "$rg "} ; > + ' > +} > + > +_test_placement() I think we don't remind using "_" prefix for local function of each test case :) > +{ > + 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_rgno` > + for i in `seq 2 100`; do > + file=$SCRATCH_MNT/short.$i > + rg=`xfs_bmap -v $file | _filter_rgno` > + 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_rgno` > + 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_rgno` > + 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_rgno` > + 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 >