All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: test compression attribute on filesystems mounted with nodatacow
@ 2026-11-02 19:57 fdmanana
  2026-11-04  5:22 ` David Disseldorp
  2026-11-04  6:23 ` Zorro Lang
  0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2026-11-02 19:57 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Test that if we mount a filesystem with "-o nodatacow", set the
compression attribute on a directory and then create a file under it, the
file should inherit compression and setting an additional attribute (like
+A, write append mode) should work.

This exercises a bug fixed by the following kernel patch:

  btrfs: dont propagate nodatacow mount option on files with inherited compression

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

diff --git a/tests/btrfs/364 b/tests/btrfs/364
new file mode 100755
index 00000000..d59e1cab
--- /dev/null
+++ b/tests/btrfs/364
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 364
+#
+# Test that if we mount a filesystem with "-o nodatacow", set the compression
+# attribute on a directory and then create a file under it, the file should
+# inherit compression and setting an additional attribute (like +A, write append
+# mode) should work.
+#
+. ./common/preamble
+_begin_fstest auto quick compress fiemap
+
+. ./common/filter
+. ./common/punch # for _filter_fiemap_flags
+
+_require_xfs_io_command "fiemap"
+_require_chattr c
+_require_chattr A
+_require_scratch
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+	"btrfs: dont propagate nodatacow mount option on files with inherited compression"
+
+_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount "-o nodatacow"
+
+# Create a directory with the compression attribute, so that all files created
+# under it inherit the compression attribute.
+mkdir $SCRATCH_MNT/dir
+$CHATTR_PROG +c $SCRATCH_MNT/dir
+
+# Now create a file with some data inside the directory.
+$XFS_IO_PROG -f -c "pwrite 0 128K" $SCRATCH_MNT/dir/foo | _filter_xfs_io
+
+# Now try to make the file append only, it should work.
+$CHATTR_PROG +A $SCRATCH_MNT/dir/foo
+
+# A fiemap should report an encoded extent, which means it's compressed.
+echo "Fiemap output:"
+$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/dir/foo | _filter_fiemap_flags 1
+
+# success, all done
+_exit 0
diff --git a/tests/btrfs/364.out b/tests/btrfs/364.out
new file mode 100644
index 00000000..205d5ca2
--- /dev/null
+++ b/tests/btrfs/364.out
@@ -0,0 +1,5 @@
+QA output created by 364
+wrote 131072/131072 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Fiemap output:
+0: [0..255]: encoded|last
-- 
2.53.0


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

end of thread, other threads:[~2026-11-04  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 19:57 [PATCH] btrfs: test compression attribute on filesystems mounted with nodatacow fdmanana
2026-11-04  5:22 ` David Disseldorp
2026-11-04  6:23 ` Zorro Lang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.