linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Zorro Lang <zlang@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 12/16] xfs: test zoned GC file defragmentation for sequential writers
Date: Thu,  8 May 2025 07:34:41 +0200	[thread overview]
Message-ID: <20250508053454.13687-13-hch@lst.de> (raw)
In-Reply-To: <20250508053454.13687-1-hch@lst.de>

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


  parent reply	other threads:[~2025-05-08  5:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Christoph Hellwig [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250508053454.13687-13-hch@lst.de \
    --to=hch@lst.de \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).