* [PATCH] generic/301: skip extent count check on btrfs
@ 2026-03-24 20:40 Leo Martins
2026-03-24 20:49 ` Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Leo Martins @ 2026-03-24 20:40 UTC (permalink / raw)
To: linux-btrfs, kernel-team, fstests
The 2/3 fragmentation threshold was designed for XFS's cowextsize
mechanism and is not applicable to btrfs. After commit 0dc118b3c327
("btrfs: be less aggressive with metadata overcommit when we can do
full flushing"), btrfs commits transactions more frequently during
writeback, reducing the extent allocator's opportunity to coalesce
adjacent CoW extents. This causes the extent count to sometimes cross
the threshold, making the test flaky on btrfs.
Skip only the extent count assertion for btrfs while keeping the CoW
write + remount + md5sum data integrity checks, which remain useful.
Signed-off-by: Leo Martins <loemra.dev@gmail.com>
---
tests/generic/301 | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/generic/301 b/tests/generic/301
index 0303f25d..985d943a 100755
--- a/tests/generic/301
+++ b/tests/generic/301
@@ -62,7 +62,12 @@ new_extents=$(_count_extents $testdir/file2)
echo "old extents: $old_extents" >> $seqres.full
echo "new extents: $new_extents" >> $seqres.full
echo "maximum extents: $internal_blks" >> $seqres.full
-test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
+# btrfs CoW extent allocation depends on transaction commit frequency and
+# metadata reservation behavior, so the 2/3 fragmentation threshold (designed
+# for XFS cowextsize) is not applicable.
+if [ "$FSTYP" != "btrfs" ]; then
+ test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
+fi
# success, all done
status=0
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] generic/301: skip extent count check on btrfs
2026-03-24 20:40 [PATCH] generic/301: skip extent count check on btrfs Leo Martins
@ 2026-03-24 20:49 ` Darrick J. Wong
2026-03-24 21:07 ` Qu Wenruo
2026-03-25 5:48 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-03-24 20:49 UTC (permalink / raw)
To: Leo Martins; +Cc: linux-btrfs, kernel-team, fstests
On Tue, Mar 24, 2026 at 01:40:00PM -0700, Leo Martins wrote:
> The 2/3 fragmentation threshold was designed for XFS's cowextsize
> mechanism and is not applicable to btrfs. After commit 0dc118b3c327
> ("btrfs: be less aggressive with metadata overcommit when we can do
> full flushing"), btrfs commits transactions more frequently during
> writeback, reducing the extent allocator's opportunity to coalesce
> adjacent CoW extents. This causes the extent count to sometimes cross
> the threshold, making the test flaky on btrfs.
>
> Skip only the extent count assertion for btrfs while keeping the CoW
> write + remount + md5sum data integrity checks, which remain useful.
>
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>
Seems reasonable to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> tests/generic/301 | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tests/generic/301 b/tests/generic/301
> index 0303f25d..985d943a 100755
> --- a/tests/generic/301
> +++ b/tests/generic/301
> @@ -62,7 +62,12 @@ new_extents=$(_count_extents $testdir/file2)
> echo "old extents: $old_extents" >> $seqres.full
> echo "new extents: $new_extents" >> $seqres.full
> echo "maximum extents: $internal_blks" >> $seqres.full
> -test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
> +# btrfs CoW extent allocation depends on transaction commit frequency and
> +# metadata reservation behavior, so the 2/3 fragmentation threshold (designed
> +# for XFS cowextsize) is not applicable.
> +if [ "$FSTYP" != "btrfs" ]; then
> + test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
> +fi
>
> # success, all done
> status=0
> --
> 2.52.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] generic/301: skip extent count check on btrfs
2026-03-24 20:40 [PATCH] generic/301: skip extent count check on btrfs Leo Martins
2026-03-24 20:49 ` Darrick J. Wong
@ 2026-03-24 21:07 ` Qu Wenruo
2026-03-25 5:48 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-03-24 21:07 UTC (permalink / raw)
To: Leo Martins, linux-btrfs, kernel-team, fstests
在 2026/3/25 07:10, Leo Martins 写道:
> The 2/3 fragmentation threshold was designed for XFS's cowextsize
> mechanism and is not applicable to btrfs. After commit 0dc118b3c327
> ("btrfs: be less aggressive with metadata overcommit when we can do
> full flushing"), btrfs commits transactions more frequently during
> writeback, reducing the extent allocator's opportunity to coalesce
> adjacent CoW extents. This causes the extent count to sometimes cross
> the threshold, making the test flaky on btrfs.
>
> Skip only the extent count assertion for btrfs while keeping the CoW
> write + remount + md5sum data integrity checks, which remain useful.
>
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>
For the btrfs part:
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> tests/generic/301 | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tests/generic/301 b/tests/generic/301
> index 0303f25d..985d943a 100755
> --- a/tests/generic/301
> +++ b/tests/generic/301
> @@ -62,7 +62,12 @@ new_extents=$(_count_extents $testdir/file2)
> echo "old extents: $old_extents" >> $seqres.full
> echo "new extents: $new_extents" >> $seqres.full
> echo "maximum extents: $internal_blks" >> $seqres.full
> -test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
> +# btrfs CoW extent allocation depends on transaction commit frequency and
> +# metadata reservation behavior, so the 2/3 fragmentation threshold (designed
> +# for XFS cowextsize) is not applicable.
> +if [ "$FSTYP" != "btrfs" ]; then
> + test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
> +fi
>
> # success, all done
> status=0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] generic/301: skip extent count check on btrfs
2026-03-24 20:40 [PATCH] generic/301: skip extent count check on btrfs Leo Martins
2026-03-24 20:49 ` Darrick J. Wong
2026-03-24 21:07 ` Qu Wenruo
@ 2026-03-25 5:48 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-03-25 5:48 UTC (permalink / raw)
To: Leo Martins; +Cc: linux-btrfs, kernel-team, fstests
On Tue, Mar 24, 2026 at 01:40:00PM -0700, Leo Martins wrote:
> +# btrfs CoW extent allocation depends on transaction commit frequency and
> +# metadata reservation behavior, so the 2/3 fragmentation threshold (designed
> +# for XFS cowextsize) is not applicable.
It really is a quality of implementation issue and not specifically
designed for XFS. But I gues it is hard to force quality of
implementation on specific file systems.
> +if [ "$FSTYP" != "btrfs" ]; then
> + test $new_extents -lt $((internal_blks * 2 / 3)) || echo "file2 badly fragmented"
Please break the echo into a separate line to keep this readable,
either by just breaking using \ or by turning this into a proper if
statement.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-25 5:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 20:40 [PATCH] generic/301: skip extent count check on btrfs Leo Martins
2026-03-24 20:49 ` Darrick J. Wong
2026-03-24 21:07 ` Qu Wenruo
2026-03-25 5:48 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox