Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: test that we don't create pointless compressed inline extents
@ 2026-09-14 17:54 fdmanana
  2026-09-15 11:44 ` David Disseldorp
  2026-09-15 15:05 ` [PATCH v2] " fdmanana
  0 siblings, 2 replies; 5+ messages in thread
From: fdmanana @ 2026-09-14 17:54 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Verify that we don't create compressed inline extents when the compressed
data size is not smaller than the uncompressed data size.

This exercises a regression introduced in kernel 7.1 and that is fixed by
the following patch:

  "btrfs: fix creation of compressed inline extents that don't save space"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/354     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/354.out |  2 ++
 2 files changed, 46 insertions(+)
 create mode 100755 tests/btrfs/354
 create mode 100644 tests/btrfs/354.out

diff --git a/tests/btrfs/354 b/tests/btrfs/354
new file mode 100755
index 00000000..801dc587
--- /dev/null
+++ b/tests/btrfs/354
@@ -0,0 +1,44 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 354
+#
+# Verify that we don't create compressed inline extents when the compressed
+# data size is not smaller than the uncompressed data size.
+#
+. ./common/preamble
+_begin_fstest auto quick compress
+
+. ./common/filter
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"btrfs: fix creation of compressed inline extents that don't save space"
+
+_require_scratch
+_require_btrfs_command inspect-internal dump-tree
+
+algo_list=($(_btrfs_compression_algos))
+for algo in ${algo_list[@]}; do
+	_scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
+	_scratch_mount "-o compress=$algo"
+
+	echo 'a file with test content' > $SCRATCH_MNT/foobar
+	_scratch_unmount
+	_check_scratch_fs
+
+	extent_size=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 5 $SCRATCH_DEV | \
+	      grep 'inline extent' | \
+	      $AWK_PROG '{ for (i = 1; i < NF; i++) if ($i ~ /^size$/) print $(i + 1) }')
+	ram_size=$($BTRFS_UTIL_PROG inspect-internal dump-tree -t 5 $SCRATCH_DEV | \
+		   grep 'inline extent' | \
+		   $AWK_PROG '{ for (i = 1; i < NF; i++) if ($i ~ /^ram_bytes$/) print $(i + 1) }')
+
+	if [ "$extent_size" -gt "$ram_size" ]; then
+		echo "inline extent size ($extent_size) greater than ram_size ($ram_size) for algo $algo"
+	fi
+done
+
+# success, all done
+echo "Silence is golden"
+_exit 0
diff --git a/tests/btrfs/354.out b/tests/btrfs/354.out
new file mode 100644
index 00000000..8bc7ecf6
--- /dev/null
+++ b/tests/btrfs/354.out
@@ -0,0 +1,2 @@
+QA output created by 354
+Silence is golden
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-15 22:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 17:54 [PATCH] btrfs: test that we don't create pointless compressed inline extents fdmanana
2026-09-15 11:44 ` David Disseldorp
2026-09-15 15:05   ` Filipe Manana
2026-09-15 15:05 ` [PATCH v2] " fdmanana
2026-09-15 22:16   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox