Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: fdmanana@kernel.org
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
	 Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] btrfs: test compression attribute on filesystems mounted with nodatacow
Date: Wed, 4 Nov 2026 14:23:04 +0800	[thread overview]
Message-ID: <aurOsMiyb2pP43eH@zlang-mailbox> (raw)
In-Reply-To: <19d06a11c66590ec2a053781c79bf00e39361a70.1793648537.git.fdmanana@suse.com>

On Mon, Nov 02, 2026 at 07:57:17PM +0000, fdmanana@kernel.org wrote:
> 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>
> ---

This test case is simple and good enough,

Reviewed-by: Zorro Lang <zlang@kernel.org>

>  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

I'll squash these two lines into one when merging (as David mentioned).

> +_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
> 
> 

      parent reply	other threads:[~2026-11-04  6:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=aurOsMiyb2pP43eH@zlang-mailbox \
    --to=zlang@kernel.org \
    --cc=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.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