From: "Darrick J. Wong" <djwong@kernel.org>
To: fdmanana@kernel.org
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] generic: test a scenario of power failure after renames and fsyncs
Date: Mon, 1 Dec 2025 15:00:04 -0800 [thread overview]
Message-ID: <20251201230004.GB89454@frogsfrogsfrogs> (raw)
In-Reply-To: <5923d73eeeaf2b5d2e179c9be9cf3303149dc3f8.1764264859.git.fdmanana@suse.com>
On Thu, Nov 27, 2025 at 06:17:44PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> Test moving a directory to another location, create a file in the old
> location of the directory and with the same name, fsync the file, then
> move the file elsewhere and fsync again the file. After a power failure
> we expect to be able to mount the fs and have the same content as before
> the power failure.
>
> This exercises a bug fixed by the following kernel patch for btrfs:
>
> "btrfs: don't log conflicting inode if it's a dir moved in the current transaction"
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Seems reasonable to me.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> tests/generic/784 | 76 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/784.out | 19 +++++++++++
> 2 files changed, 95 insertions(+)
> create mode 100755 tests/generic/784
> create mode 100644 tests/generic/784.out
>
> diff --git a/tests/generic/784 b/tests/generic/784
> new file mode 100755
> index 00000000..8e01dff0
> --- /dev/null
> +++ b/tests/generic/784
> @@ -0,0 +1,76 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 SUSE S.A. All Rights Reserved.
> +#
> +# FS QA Test 784
> +#
> +# Test moving a directory to another location, create a file in the old location
> +# of the directory and with the same name, fsync the file, then move the file
> +# elsewhere and fsync again the file. After a power failure we expect to be able
> +# to mount the fs and have the same content as before the power failure.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick log
> +
> +_cleanup()
> +{
> + _cleanup_flakey
> + cd /
> + rm -r -f $tmp.*
> +}
> +
> +. ./common/filter
> +. ./common/dmflakey
> +
> +_require_scratch
> +_require_dm_target flakey
> +
> +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
> + "btrfs: don't log conflicting inode if it's a dir moved in the current transaction"
> +
> +_scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
> +_require_metadata_journaling $SCRATCH_DEV
> +_init_flakey
> +_mount_flakey
> +
> +list_fs_contents()
> +{
> + # Remove the 'lost+found' directory which only exists in some
> + # filesystems like extN and remove empty lines to have a consistent
> + # output regardless of the existence of the 'lost+found' directory.
> + ls -1R $SCRATCH_MNT/ | grep -v 'lost+found' | grep -v -e '^$' | \
> + _filter_scratch
> +}
> +
> +mkdir $SCRATCH_MNT/dir1
> +mkdir $SCRATCH_MNT/dir2
> +
> +_scratch_sync
> +
> +mv $SCRATCH_MNT/dir1 $SCRATCH_MNT/dir2
> +
> +# Create a file with the old name of the first directory and persist it with
> +# a fsync.
> +$XFS_IO_PROG -f -c "fsync" $SCRATCH_MNT/dir1
> +
> +# Move the file to some other location.
> +mv $SCRATCH_MNT/dir1 $SCRATCH_MNT/dir2/foo
> +
> +# Fsync again the file.
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir2/foo
> +
> +echo -e "\nfs contents before power failure:\n"
> +list_fs_contents
> +
> +# Simulate a power failure and then mount again the filesystem to replay the
> +# journal/log. We expect the mount to succeed.
> +_flakey_drop_and_remount
> +
> +# We expect the fs contents to be the same as before the power failure.
> +echo -e "\nfs contents after power failure:\n"
> +list_fs_contents
> +
> +_unmount_flakey
> +
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/784.out b/tests/generic/784.out
> new file mode 100644
> index 00000000..87942d04
> --- /dev/null
> +++ b/tests/generic/784.out
> @@ -0,0 +1,19 @@
> +QA output created by 784
> +
> +fs contents before power failure:
> +
> +SCRATCH_MNT/:
> +dir2
> +SCRATCH_MNT/dir2:
> +dir1
> +foo
> +SCRATCH_MNT/dir2/dir1:
> +
> +fs contents after power failure:
> +
> +SCRATCH_MNT/:
> +dir2
> +SCRATCH_MNT/dir2:
> +dir1
> +foo
> +SCRATCH_MNT/dir2/dir1:
> --
> 2.47.2
>
>
prev parent reply other threads:[~2025-12-01 23:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 18:17 [PATCH] generic: test a scenario of power failure after renames and fsyncs fdmanana
2025-12-01 23:00 ` Darrick J. Wong [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=20251201230004.GB89454@frogsfrogsfrogs \
--to=djwong@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