From: Christoph Hellwig <hch@infradead.org>
To: fdmanana@kernel.org
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] generic/211: verify if the filesystem being tested supports in place writes
Date: Thu, 24 Jul 2025 00:17:39 -0700 [thread overview]
Message-ID: <aIHeE0a5SdFoCqaP@infradead.org> (raw)
In-Reply-To: <7ba7d315e60388593ccef0353cff58c4b5795615.1753272216.git.fdmanana@suse.com>
On Wed, Jul 23, 2025 at 01:04:06PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The test currently assumes the filesystem can do in place writes (no
> Copy-On-Write, no allocation of new extents) when overwriting a file.
> While that is the case for most filesystems in most configurations, there
> are exceptions such as zoned xfs where overwriting results in allocating
> new extents for the new data.
>
> So make the test check that in place writes are supported and skip the
> test if they are not supported.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> common/rc | 59 +++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/211 | 1 +
> 2 files changed, 60 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index 96578d15..52aade10 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -5873,6 +5873,65 @@ _require_program() {
> _have_program "$1" || _notrun "$tag required"
> }
>
> +# Test that a filesystem can do writes to a file in place (without allocating
> +# new extents, without Copy-On-Write semantics).
> +_require_inplace_writes()
> +{
> + _require_xfs_io_command "fiemap"
> +
> + local target=$1
> + local test_file="${target}/test_inplace_writes"
> + local fiemap_before
> + local fiemap_after
> +
> + if [ -z "$target" ]; then
> + _fail "Usage: _require_inplace_writes <filesystem path>"
> + fi
> +
> + rm -f "$test_file"
> + touch "$test_file"
> +
> + # Set the file to NOCOW mode on btrfs, which must be done while the file
> + # is empty, otherwise it fails.
> + if [ "$FSTYP" == "btrfs" ]; then
> + _require_chattr C
> + $CHATTR_PROG +C "$test_file"
> + fi
Can you factor this into a _force_inplace helper instead of spreading
file systems specific in random helpers (I know we have a few of those,
but we need to get rid of that to make things maintainable..)
> + # If the filesystem supports inplace writes, then the extent mapping is
> + # the same before and after overwriting.
> + if [ "${fiemap_after}" != "${fiemap_before}" ]; then
> + _notrun "inplace writes not supported"
I think in-place would be the more usual spelling instead of inplace.
Otherwise this looks great, thanks!
next prev parent reply other threads:[~2025-07-24 7:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 12:04 [PATCH] generic/211: verify if the filesystem being tested supports in place writes fdmanana
2025-07-23 14:49 ` Darrick J. Wong
2025-07-24 7:17 ` Christoph Hellwig [this message]
2025-07-24 12:05 ` [PATCH v2] " fdmanana
2025-07-29 7:46 ` Christoph Hellwig
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=aIHeE0a5SdFoCqaP@infradead.org \
--to=hch@infradead.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 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.