From 66f5b97a09fbb49bf27846dd3e0431e1b081ca66 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 8 May 2025 07:34:34 +0200 Subject: [PATCH] xfs: add test to check for block layer reordering 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 Reviewed-by: Darrick J. Wong Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- tests/xfs/636 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/636.out | 5 +++++ 2 files changed, 42 insertions(+) create mode 100755 tests/xfs/636 create mode 100644 tests/xfs/636.out diff --git a/tests/xfs/636 b/tests/xfs/636 new file mode 100755 index 00000000..872da416 --- /dev/null +++ b/tests/xfs/636 @@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Christoph Hellwig +# +# FS QA Test No. 636 +# +# 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/636.out b/tests/xfs/636.out new file mode 100644 index 00000000..e132f415 --- /dev/null +++ b/tests/xfs/636.out @@ -0,0 +1,5 @@ +QA output created by 636 +16+0 records in +16+0 records out +Check extent counts +number of extents: 1 -- 2.47.3