Re: [PATCH] xfs: new EOF fragmentation tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 01, 2024 at 07:59:44AM -0700, Darrick J. Wong wrote:
> On Tue, Sep 24, 2024 at 10:45:48AM +0200, Christoph Hellwig wrote:
> > From: Dave Chinner <dchinner@xxxxxxxxxx>
> > 
> > These tests create substantial file fragmentation as a result of
> > application actions that defeat post-EOF preallocation
> > optimisations. They are intended to replicate known vectors for
> > these problems, and provide a check that the fragmentation levels
> > have been controlled. The mitigations we make may not completely
> > remove fragmentation (e.g. they may demonstrate speculative delalloc
> > related extent size growth) so the checks don't assume we'll end up
> > with perfect layouts and hence check for an exceptable level of
> > fragmentation rather than none.
> > 
> > Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
> > [move to different test number, update to current xfstest APIs]
> > Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> > ---
> >  tests/xfs/1500     | 66 +++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/1500.out |  9 ++++++
> >  tests/xfs/1501     | 68 ++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/1501.out |  9 ++++++
> >  tests/xfs/1502     | 68 ++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/1502.out |  9 ++++++
> >  tests/xfs/1503     | 77 ++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/1503.out | 33 ++++++++++++++++++++
> >  8 files changed, 339 insertions(+)
> >  create mode 100755 tests/xfs/1500
> >  create mode 100644 tests/xfs/1500.out
> >  create mode 100755 tests/xfs/1501
> >  create mode 100644 tests/xfs/1501.out
> >  create mode 100755 tests/xfs/1502
> >  create mode 100644 tests/xfs/1502.out
> >  create mode 100755 tests/xfs/1503
> >  create mode 100644 tests/xfs/1503.out
> > 
> > diff --git a/tests/xfs/1500 b/tests/xfs/1500
> > new file mode 100755
> > index 000000000..de0e1df62
> > --- /dev/null
> > +++ b/tests/xfs/1500
> > @@ -0,0 +1,66 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
> > +#
> > +# FS QA Test xfs/500
> > +#
> > +# Post-EOF preallocation defeat test for O_SYNC buffered I/O.
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto quick prealloc rw
> > +
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +_require_scratch
> > +
> > +_cleanup()
> > +{
> > +	# try to kill all background processes
> > +	wait
> > +	cd /
> > +	rm -r -f $tmp.*
> > +}
> > +
> > +_scratch_mkfs > "$seqres.full" 2>&1
> > +_scratch_mount
> > +
> > +# Write multiple files in parallel using synchronous buffered writes. Aim is to
> > +# interleave allocations to fragment the files. Synchronous writes defeat the
> > +# open/write/close heuristics in xfs_file_release() that prevent EOF block
> > +# removal, so this should fragment badly. Typical problematic behaviour shows
> > +# per-file extent counts of >900 (almost worse case) whilst fixed behaviour
> > +# typically shows extent counts in the low 20s.
> 
> Now that these are in for-next, I've noticed that these new tests
> consistently fail in the above-documented manner on various configs --
> fsdax, always_cow, rtextsize > 1fsb, and sometimes 1k fsblock size.

Hi Christoph,

Thanks for reworking this patch, it's been merged into fstests, named
xfs/629~632. But now these 4 cases always fail on upstream xfs, e.g
(diff output) [1][2][3][4]. Could you help to take a look at the
failure which Darick metioned above too :)

Thanks,
Zorro

[1]
--- /dev/fd/63	2024-10-12 03:26:05.854655824 -0400
+++ xfs/629.out.bad	2024-10-12 03:26:05.196658410 -0400
@@ -1,9 +1,17 @@
 QA output created by 629
-file.0 extent count is in range
-file.1 extent count is in range
-file.2 extent count is in range
-file.3 extent count is in range
-file.4 extent count is in range
-file.5 extent count is in range
-file.6 extent count is in range
-file.7 extent count is in range
+file.0 extent count has value of 262
+file.0 extent count is NOT in range 2 .. 40
+file.1 extent count has value of 278
+file.1 extent count is NOT in range 2 .. 40
+file.2 extent count has value of 292
+file.2 extent count is NOT in range 2 .. 40
+file.3 extent count has value of 255
+file.3 extent count is NOT in range 2 .. 40
+file.4 extent count has value of 299
+file.4 extent count is NOT in range 2 .. 40
+file.5 extent count has value of 276
+file.5 extent count is NOT in range 2 .. 40
+file.6 extent count has value of 281
+file.6 extent count is NOT in range 2 .. 40
+file.7 extent count has value of 290
+file.7 extent count is NOT in range 2 .. 40

[2]
--- /dev/fd/63	2024-10-12 03:27:24.685345937 -0400
+++ xfs/630.out.bad	2024-10-12 03:27:24.002348622 -0400
@@ -1,9 +1,17 @@
 QA output created by 630
-file.0 extent count is in range
-file.1 extent count is in range
-file.2 extent count is in range
-file.3 extent count is in range
-file.4 extent count is in range
-file.5 extent count is in range
-file.6 extent count is in range
-file.7 extent count is in range
+file.0 extent count has value of 996
+file.0 extent count is NOT in range 1 .. 10
+file.1 extent count has value of 991
+file.1 extent count is NOT in range 1 .. 10
+file.2 extent count has value of 989
+file.2 extent count is NOT in range 1 .. 10
+file.3 extent count has value of 998
+file.3 extent count is NOT in range 1 .. 10
+file.4 extent count has value of 993
+file.4 extent count is NOT in range 1 .. 10
+file.5 extent count has value of 990
+file.5 extent count is NOT in range 1 .. 10
+file.6 extent count has value of 997
+file.6 extent count is NOT in range 1 .. 10
+file.7 extent count has value of 995
+file.7 extent count is NOT in range 1 .. 10

[3]
--- /dev/fd/63	2024-10-12 03:28:38.598055384 -0400
+++ xfs/631.out.bad	2024-10-12 03:28:37.973057841 -0400
@@ -1,9 +1,17 @@
 QA output created by 631
-file.0 extent count is in range
-file.1 extent count is in range
-file.2 extent count is in range
-file.3 extent count is in range
-file.4 extent count is in range
-file.5 extent count is in range
-file.6 extent count is in range
-file.7 extent count is in range
+file.0 extent count has value of 994
+file.0 extent count is NOT in range 1 .. 10
+file.1 extent count has value of 992
+file.1 extent count is NOT in range 1 .. 10
+file.2 extent count has value of 980
+file.2 extent count is NOT in range 1 .. 10
+file.3 extent count has value of 996
+file.3 extent count is NOT in range 1 .. 10
+file.4 extent count has value of 994
+file.4 extent count is NOT in range 1 .. 10
+file.5 extent count has value of 985
+file.5 extent count is NOT in range 1 .. 10
+file.6 extent count has value of 987
+file.6 extent count is NOT in range 1 .. 10
+file.7 extent count has value of 990
+file.7 extent count is NOT in range 1 .. 10

[4]
--- /dev/fd/63	2024-10-12 03:31:07.166471365 -0400
+++ xfs/632.out.bad	2024-10-12 03:31:06.487474034 -0400
@@ -1,33 +1,65 @@
 QA output created by 632
-file.0 extent count is in range
-file.1 extent count is in range
-file.2 extent count is in range
-file.3 extent count is in range
-file.4 extent count is in range
-file.5 extent count is in range
-file.6 extent count is in range
-file.7 extent count is in range
-file.8 extent count is in range
-file.9 extent count is in range
-file.10 extent count is in range
-file.11 extent count is in range
-file.12 extent count is in range
-file.13 extent count is in range
-file.14 extent count is in range
-file.15 extent count is in range
-file.16 extent count is in range
-file.17 extent count is in range
-file.18 extent count is in range
-file.19 extent count is in range
-file.20 extent count is in range
-file.21 extent count is in range
-file.22 extent count is in range
-file.23 extent count is in range
-file.24 extent count is in range
-file.25 extent count is in range
-file.26 extent count is in range
-file.27 extent count is in range
-file.28 extent count is in range
-file.29 extent count is in range
-file.30 extent count is in range
-file.31 extent count is in range
+file.0 extent count has value of 530
+file.0 extent count is NOT in range 1 .. 16
+file.1 extent count has value of 516
+file.1 extent count is NOT in range 1 .. 16
+file.2 extent count has value of 524
+file.2 extent count is NOT in range 1 .. 16
+file.3 extent count has value of 526
+file.3 extent count is NOT in range 1 .. 16
+file.4 extent count has value of 531
+file.4 extent count is NOT in range 1 .. 16
+file.5 extent count has value of 529
+file.5 extent count is NOT in range 1 .. 16
+file.6 extent count has value of 533
+file.6 extent count is NOT in range 1 .. 16
+file.7 extent count has value of 519
+file.7 extent count is NOT in range 1 .. 16
+file.8 extent count has value of 385
+file.8 extent count is NOT in range 1 .. 16
+file.9 extent count has value of 465
+file.9 extent count is NOT in range 1 .. 16
+file.10 extent count has value of 525
+file.10 extent count is NOT in range 1 .. 16
+file.11 extent count has value of 527
+file.11 extent count is NOT in range 1 .. 16
+file.12 extent count has value of 345
+file.12 extent count is NOT in range 1 .. 16
+file.13 extent count has value of 523
+file.13 extent count is NOT in range 1 .. 16
+file.14 extent count has value of 504
+file.14 extent count is NOT in range 1 .. 16
+file.15 extent count has value of 518
+file.15 extent count is NOT in range 1 .. 16
+file.16 extent count has value of 501
+file.16 extent count is NOT in range 1 .. 16
+file.17 extent count has value of 518
+file.17 extent count is NOT in range 1 .. 16
+file.18 extent count has value of 524
+file.18 extent count is NOT in range 1 .. 16
+file.19 extent count has value of 530
+file.19 extent count is NOT in range 1 .. 16
+file.20 extent count has value of 509
+file.20 extent count is NOT in range 1 .. 16
+file.21 extent count has value of 519
+file.21 extent count is NOT in range 1 .. 16
+file.22 extent count has value of 522
+file.22 extent count is NOT in range 1 .. 16
+file.23 extent count has value of 522
+file.23 extent count is NOT in range 1 .. 16
+file.24 extent count has value of 501
+file.24 extent count is NOT in range 1 .. 16
+file.25 extent count has value of 218
+file.25 extent count is NOT in range 1 .. 16
+file.26 extent count has value of 529
+file.26 extent count is NOT in range 1 .. 16
+file.27 extent count has value of 527
+file.27 extent count is NOT in range 1 .. 16
+file.28 extent count has value of 525
+file.28 extent count is NOT in range 1 .. 16
+file.29 extent count has value of 545
+file.29 extent count is NOT in range 1 .. 16
+file.30 extent count has value of 527
+file.30 extent count is NOT in range 1 .. 16
+file.31 extent count has value of 519
+file.31 extent count is NOT in range 1 .. 16

> 
> I'm not sure why this happens, but it probably needs to be looked at
> along with all the FALLOC_FL_UNSHARE_RANGE brokenness that's also been
> exposed by fstests that /does/ need to be fixed.
> 
> --D
> 
> > +# Failure is determined by golden output mismatch from _within_tolerance().
> > +
> > +workfile=$SCRATCH_MNT/file
> > +nfiles=8
> > +wsize=4096
> > +wcnt=1000
> > +
> > +write_sync_file()
> > +{
> > +	idx=$1
> > +
> > +	for ((cnt=0; cnt<$wcnt; cnt++)); do
> > +		$XFS_IO_PROG -f -s -c "pwrite $((cnt * wsize)) $wsize" $workfile.$idx
> > +	done
> > +}
> > +
> > +rm -f $workfile*
> > +for ((n=0; n<$nfiles; n++)); do
> > +	write_sync_file $n > /dev/null 2>&1 &
> > +done
> > +wait
> > +sync
> > +
> > +for ((n=0; n<$nfiles; n++)); do
> > +	count=$(_count_extents $workfile.$n)
> > +	# Acceptible extent count range is 1-40
> > +	_within_tolerance "file.$n extent count" $count 21 19 -v
> > +done
> > +
> > +status=0
> > +exit
> > diff --git a/tests/xfs/1500.out b/tests/xfs/1500.out
> > new file mode 100644
> > index 000000000..414df87ed
> > --- /dev/null
> > +++ b/tests/xfs/1500.out
> > @@ -0,0 +1,9 @@
> > +QA output created by 1500
> > +file.0 extent count is in range
> > +file.1 extent count is in range
> > +file.2 extent count is in range
> > +file.3 extent count is in range
> > +file.4 extent count is in range
> > +file.5 extent count is in range
> > +file.6 extent count is in range
> > +file.7 extent count is in range
> > diff --git a/tests/xfs/1501 b/tests/xfs/1501
> > new file mode 100755
> > index 000000000..cf3cbf8b5
> > --- /dev/null
> > +++ b/tests/xfs/1501
> > @@ -0,0 +1,68 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
> > +#
> > +# FS QA Test xfs/501
> > +#
> > +# Post-EOF preallocation defeat test for buffered I/O with extent size hints.
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto quick prealloc rw
> > +
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +_require_scratch
> > +
> > +_cleanup()
> > +{
> > +	# try to kill all background processes
> > +	wait
> > +	cd /
> > +	rm -r -f $tmp.*
> > +}
> > +
> > +_scratch_mkfs > "$seqres.full" 2>&1
> > +_scratch_mount
> > +
> > +# Write multiple files in parallel using buffered writes with extent size hints.
> > +# Aim is to interleave allocations to fragment the files. Writes w/ extent size
> > +# hints set defeat the open/write/close heuristics in xfs_file_release() that
> > +# prevent EOF block removal, so this should fragment badly. Typical problematic
> > +# behaviour shows per-file extent counts of 1000 (worst case!) whilst
> > +# fixed behaviour should show very few extents (almost best case).
> > +#
> > +# Failure is determined by golden output mismatch from _within_tolerance().
> > +
> > +workfile=$SCRATCH_MNT/file
> > +nfiles=8
> > +wsize=4096
> > +wcnt=1000
> > +extent_size=16m
> > +
> > +write_extsz_file()
> > +{
> > +	idx=$1
> > +
> > +	$XFS_IO_PROG -f -c "extsize $extent_size" $workfile.$idx
> > +	for ((cnt=0; cnt<$wcnt; cnt++)); do
> > +		$XFS_IO_PROG -f -c "pwrite $((cnt * wsize)) $wsize" $workfile.$idx
> > +	done
> > +}
> > +
> > +rm -f $workfile*
> > +for ((n=0; n<$nfiles; n++)); do
> > +	write_extsz_file $n > /dev/null 2>&1 &
> > +done
> > +wait
> > +sync
> > +
> > +for ((n=0; n<$nfiles; n++)); do
> > +	count=$(_count_extents $workfile.$n)
> > +	# Acceptible extent count range is 1-10
> > +	_within_tolerance "file.$n extent count" $count 2 1 8 -v
> > +done
> > +
> > +status=0
> > +exit
> > diff --git a/tests/xfs/1501.out b/tests/xfs/1501.out
> > new file mode 100644
> > index 000000000..a266ef74b
> > --- /dev/null
> > +++ b/tests/xfs/1501.out
> > @@ -0,0 +1,9 @@
> > +QA output created by 1501
> > +file.0 extent count is in range
> > +file.1 extent count is in range
> > +file.2 extent count is in range
> > +file.3 extent count is in range
> > +file.4 extent count is in range
> > +file.5 extent count is in range
> > +file.6 extent count is in range
> > +file.7 extent count is in range
> > diff --git a/tests/xfs/1502 b/tests/xfs/1502
> > new file mode 100755
> > index 000000000..f4228667a
> > --- /dev/null
> > +++ b/tests/xfs/1502
> > @@ -0,0 +1,68 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
> > +#
> > +# FS QA Test xfs/502
> > +#
> > +# Post-EOF preallocation defeat test for direct I/O with extent size hints.
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto quick prealloc rw
> > +
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +_require_scratch
> > +
> > +_cleanup()
> > +{
> > +	# try to kill all background processes
> > +	wait
> > +	cd /
> > +	rm -r -f $tmp.*
> > +}
> > +
> > +_scratch_mkfs > "$seqres.full" 2>&1
> > +_scratch_mount
> > +
> > +# Write multiple files in parallel using O_DIRECT writes w/ extent size hints.
> > +# Aim is to interleave allocations to fragment the files. O_DIRECT writes defeat
> > +# the open/write/close heuristics in xfs_file_release() that prevent EOF block
> > +# removal, so this should fragment badly. Typical problematic behaviour shows
> > +# per-file extent counts of ~1000 (worst case) whilst fixed behaviour typically
> > +# shows extent counts in the low single digits (almost best case)
> > +#
> > +# Failure is determined by golden output mismatch from _within_tolerance().
> > +
> > +workfile=$SCRATCH_MNT/file
> > +nfiles=8
> > +wsize=4096
> > +wcnt=1000
> > +extent_size=16m
> > +
> > +write_direct_file()
> > +{
> > +	idx=$1
> > +
> > +	$XFS_IO_PROG -f -c "extsize $extent_size" $workfile.$idx
> > +	for ((cnt=0; cnt<$wcnt; cnt++)); do
> > +		$XFS_IO_PROG -f -d -c "pwrite $((cnt * wsize)) $wsize" $workfile.$idx
> > +	done
> > +}
> > +
> > +rm -f $workfile*
> > +for ((n=0; n<$nfiles; n++)); do
> > +	write_direct_file $n > /dev/null 2>&1 &
> > +done
> > +wait
> > +sync
> > +
> > +for ((n=0; n<$nfiles; n++)); do
> > +	count=$(_count_extents $workfile.$n)
> > +	# Acceptible extent count range is 1-10
> > +	_within_tolerance "file.$n extent count" $count 2 1 8 -v
> > +done
> > +
> > +status=0
> > +exit
> > diff --git a/tests/xfs/1502.out b/tests/xfs/1502.out
> > new file mode 100644
> > index 000000000..82c8760a3
> > --- /dev/null
> > +++ b/tests/xfs/1502.out
> > @@ -0,0 +1,9 @@
> > +QA output created by 1502
> > +file.0 extent count is in range
> > +file.1 extent count is in range
> > +file.2 extent count is in range
> > +file.3 extent count is in range
> > +file.4 extent count is in range
> > +file.5 extent count is in range
> > +file.6 extent count is in range
> > +file.7 extent count is in range
> > diff --git a/tests/xfs/1503 b/tests/xfs/1503
> > new file mode 100755
> > index 000000000..9002f87e6
> > --- /dev/null
> > +++ b/tests/xfs/1503
> > @@ -0,0 +1,77 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
> > +#
> > +# FS QA Test xfs/503
> > +#
> > +# Post-EOF preallocation defeat test with O_SYNC buffered I/O that repeatedly
> > +# closes and reopens the files.
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto prealloc rw
> > +
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +_require_scratch
> > +
> > +_cleanup()
> > +{
> > +	# try to kill all background processes
> > +	wait
> > +	cd /
> > +	rm -r -f $tmp.*
> > +}
> > +
> > +_scratch_mkfs > "$seqres.full" 2>&1
> > +_scratch_mount
> > +
> > +# Write multiple files in parallel using synchronous buffered writes that
> > +# repeatedly close and reopen the fails. Aim is to interleave allocations to
> > +# fragment the files. Assuming we've fixed the synchronous write defeat, we can
> > +# still trigger the same issue with a open/read/close on O_RDONLY files. We
> > +# should not be triggering EOF preallocation removal on files we don't have
> > +# permission to write, so until this is fixed it should fragment badly.  Typical
> > +# problematic behaviour shows per-file extent counts of 50-350 whilst fixed
> > +# behaviour typically demonstrates post-eof speculative delalloc growth in
> > +# extent size (~6 extents for 50MB file).
> > +#
> > +# Failure is determined by golden output mismatch from _within_tolerance().
> > +
> > +workfile=$SCRATCH_MNT/file
> > +nfiles=32
> > +wsize=4096
> > +wcnt=1000
> > +
> > +write_file()
> > +{
> > +	idx=$1
> > +
> > +	$XFS_IO_PROG -f -s -c "pwrite -b 64k 0 50m" $workfile.$idx
> > +}
> > +
> > +read_file()
> > +{
> > +	idx=$1
> > +
> > +	for ((cnt=0; cnt<$wcnt; cnt++)); do
> > +		$XFS_IO_PROG -f -r -c "pread 0 28" $workfile.$idx
> > +	done
> > +}
> > +
> > +rm -f $workdir/file*
> > +for ((n=0; n<$((nfiles)); n++)); do
> > +	write_file $n > /dev/null 2>&1 &
> > +	read_file $n > /dev/null 2>&1 &
> > +done
> > +wait
> > +
> > +for ((n=0; n<$nfiles; n++)); do
> > +	count=$(_count_extents $workfile.$n)
> > +	# Acceptible extent count range is 1-40
> > +	_within_tolerance "file.$n extent count" $count 6 5 10 -v
> > +done
> > +
> > +status=0
> > +exit
> > diff --git a/tests/xfs/1503.out b/tests/xfs/1503.out
> > new file mode 100644
> > index 000000000..1780b16df
> > --- /dev/null
> > +++ b/tests/xfs/1503.out
> > @@ -0,0 +1,33 @@
> > +QA output created by 1503
> > +file.0 extent count is in range
> > +file.1 extent count is in range
> > +file.2 extent count is in range
> > +file.3 extent count is in range
> > +file.4 extent count is in range
> > +file.5 extent count is in range
> > +file.6 extent count is in range
> > +file.7 extent count is in range
> > +file.8 extent count is in range
> > +file.9 extent count is in range
> > +file.10 extent count is in range
> > +file.11 extent count is in range
> > +file.12 extent count is in range
> > +file.13 extent count is in range
> > +file.14 extent count is in range
> > +file.15 extent count is in range
> > +file.16 extent count is in range
> > +file.17 extent count is in range
> > +file.18 extent count is in range
> > +file.19 extent count is in range
> > +file.20 extent count is in range
> > +file.21 extent count is in range
> > +file.22 extent count is in range
> > +file.23 extent count is in range
> > +file.24 extent count is in range
> > +file.25 extent count is in range
> > +file.26 extent count is in range
> > +file.27 extent count is in range
> > +file.28 extent count is in range
> > +file.29 extent count is in range
> > +file.30 extent count is in range
> > +file.31 extent count is in range
> > -- 
> > 2.45.2
> > 
> > 
> 





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux