From: Dhruva G <goledhruva@gmail.com>
To: fstests@vger.kernel.org
Cc: Anand Jain <asj@kernel.org>, Filipe Manana <fdmanana@suse.com>,
Zorro Lang <zlang@kernel.org>,
linux-btrfs@vger.kernel.org, Qu Wenruo <quwenruo.btrfs@gmx.com>
Subject: [PATCH 2/3] btrfs: check NOCOMPRESS preserves holes and preallocation
Date: Mon, 12 Oct 2026 01:11:17 +0530 [thread overview]
Message-ID: <17ce825e-5edd-4bdb-8a0b-e4820c23ca80@gmail.com> (raw)
In-Reply-To: <cover.1791395660.git.goledhruva@gmail.com>
Place compressed data islands around holes and preallocated extents,
including a KEEP_SIZE reservation beyond EOF. Defragment the file with
--nocomp and require every data island to become uncompressed.
Check that each hole stays unmapped and both reservations retain their
complete physical mappings and UNWRITTEN state. Verify the layout,
contents, and file size again after remounting with compression enabled.
This extends btrfs/257 to NOCOMPRESS and compressed sparse files.
Signed-off-by: Dhruva Gole <goledhruva@gmail.com>
---
tests/btrfs/356 | 71 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/356.out | 2 ++
2 files changed, 73 insertions(+)
create mode 100755 tests/btrfs/356
create mode 100644 tests/btrfs/356.out
diff --git a/tests/btrfs/356 b/tests/btrfs/356
new file mode 100755
index 00000000..829c6e95
--- /dev/null
+++ b/tests/btrfs/356
@@ -0,0 +1,71 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+#
+# FS QA Test 356
+#
+# Verify NOCOMPRESS skips holes and preallocated extents.
+#
+. ./common/preamble
+_begin_fstest auto quick defrag compress prealloc fiemap
+
+. ./common/filter
+. ./common/btrfs_nocomp
+
+_nc_require
+_require_xfs_io_command falloc -k
+_scratch_mkfs -s 4k >> "$seqres.full" 2>&1 || _fail "mkfs failed"
+_scratch_mount -o compress=zlib
+_nc_probe
+
+file="$SCRATCH_MNT/islands"
+_nc_write "$file" 0 131072 0x31
+_nc_write "$file" 524288 131072 0x32
+_nc_write "$file" 1048576 131072 0x33
+for offset in 0 524288 1048576; do
+ _nc_check_range "$file" "$offset" 131072 compressed
+done
+$XFS_IO_PROG -c 'falloc 256K 128K' -c 'falloc -k 1280K 128K' -c fsync \
+ "$file" >> "$seqres.full" 2>&1 || _fail "fallocate failed"
+[ "$(stat -c %s "$file")" = 1179648 ] || _fail "fallocate extended EOF"
+_nc_save_file "$file"
+
+check_layout()
+{
+ local offset
+
+ for offset in 262144 1310720; do
+ _nc_check_range "$file" "$offset" 131072 prealloc
+ _nc_mapping "$file" "$offset" 131072 > "$tmp.prealloc-$offset-now"
+ cmp -s "$tmp.prealloc-$offset" "$tmp.prealloc-$offset-now" ||
+ _fail "prealloc mapping changed at $offset"
+ done
+ _nc_check_range "$file" 131072 131072 hole
+ _nc_check_range "$file" 393216 131072 hole
+ _nc_check_range "$file" 655360 393216 hole
+ _nc_check_range "$file" 1179648 131072 hole
+}
+
+# Include the KEEP_SIZE reservation beyond EOF in the baseline. FIEMAP
+# reports preallocation there even though there are no bytes to read.
+for offset in 262144 1310720; do
+ _nc_check_range "$file" "$offset" 131072 prealloc
+ _nc_mapping "$file" "$offset" 131072 > "$tmp.prealloc-$offset"
+done
+check_layout
+_nc_defrag "$file"
+for offset in 0 524288 1048576; do
+ _nc_check_range "$file" "$offset" 131072 regular
+done
+check_layout
+_nc_verify_files
+
+_scratch_cycle_mount compress=zlib
+_nc_verify_files
+check_layout
+for offset in 0 524288 1048576; do
+ _nc_check_range "$file" "$offset" 131072 regular
+done
+
+echo "Silence is golden"
+_exit 0
diff --git a/tests/btrfs/356.out b/tests/btrfs/356.out
new file mode 100644
index 00000000..78eedd26
--- /dev/null
+++ b/tests/btrfs/356.out
@@ -0,0 +1,2 @@
+QA output created by 356
+Silence is golden
--
2.43.0
next prev parent reply other threads:[~2026-10-11 19:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1791395660.git.goledhruva@gmail.com>
2026-10-11 19:40 ` [PATCH 1/3] btrfs: exercise NOCOMPRESS range and EOF handling Dhruva G
2026-10-11 22:00 ` Qu Wenruo
2026-10-13 18:08 ` Dhruva G
2026-10-12 11:04 ` Filipe Manana
2026-10-11 19:41 ` Dhruva G [this message]
2026-10-11 19:41 ` [PATCH 3/3] btrfs: cover NOCOMPRESS inline eligibility and short tails Dhruva G
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=17ce825e-5edd-4bdb-8a0b-e4820c23ca80@gmail.com \
--to=goledhruva@gmail.com \
--cc=asj@kernel.org \
--cc=fdmanana@suse.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--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