All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2] btrfs: test a directory fsync scenaro after replacing a subdir with a file
Date: Tue, 3 Mar 2026 10:16:44 -0800	[thread overview]
Message-ID: <20260303181644.GG13843@frogsfrogsfrogs> (raw)
In-Reply-To: <7997e07a4f530bc52edd1b93e662907c4cd07377.1772561118.git.fdmanana@suse.com>

On Tue, Mar 03, 2026 at 06:07:33PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Test a scenario where we remove a directory previously persisted, create
> a file with the same name and parent directory, create two directories in
> the same parent directory, create a hard link for the new file in one of
> the new directories, fsync the directory with the hard link and fsync the
> parent directory. After a power failure we expect both directories to be
> persisted as well as the new file and its hard link.
> 
> This exercises a bug on btrfs fixed by the following kernel patch:
> 
>   "btrfs: log new dentries when logging parent dir of a conflicting inode"
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> 
> V2: Add missing scratch filter for the ls output.

Looks good to me now,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> 
>  tests/generic/790     | 70 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/790.out | 12 ++++++++
>  2 files changed, 82 insertions(+)
>  create mode 100755 tests/generic/790
>  create mode 100644 tests/generic/790.out
> 
> diff --git a/tests/generic/790 b/tests/generic/790
> new file mode 100755
> index 00000000..c9bac6d0
> --- /dev/null
> +++ b/tests/generic/790
> @@ -0,0 +1,70 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
> +#
> +# FS QA Test 790
> +#
> +# Test a scenario where we remove a directory previously persisted, create a
> +# file with the same name and parent directory, create two directories in the
> +# same parent directory, create a hard link for the new file in one of the
> +# new directories, fsync the directory with the hard link and fsync the parent
> +# directory. After a power failure we expect both directories to be persisted
> +# as well as the new file and its hard link.
> +#
> +. ./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: log new dentries when logging parent dir of a conflicting inode"
> +
> +_scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
> +_require_metadata_journaling $SCRATCH_DEV
> +_init_flakey
> +_scratch_mount
> +
> +mkdir $SCRATCH_MNT/foo
> +
> +_scratch_sync
> +
> +rmdir $SCRATCH_MNT/foo
> +
> +# Create two new directories in the same parent directory as the new file.
> +mkdir $SCRATCH_MNT/dir1
> +mkdir $SCRATCH_MNT/dir2
> +
> +# Create a file with the name of the directly we deleted and was persisted
> +# before.
> +touch $SCRATCH_MNT/foo
> +
> +# Create a hard link for the new file inside one of the new directories.
> +ln $SCRATCH_MNT/foo $SCRATCH_MNT/dir2/link
> +
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir2
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/
> +
> +# Simulate a power failure and then mount again the filesystem to replay the
> +# journal/log.
> +_flakey_drop_and_remount
> +
> +# We expect to see dir1, dir2, file foo and its hard link, since dir2 was
> +# explicitly fsynced as well as the parent directory.
> +echo -e "Filesystem content after power failure:\n"
> +# Exclude 'lost+found' dir from ext4 and last line if it's blank (due to removal
> +# of 'lost+found').
> +ls -R $SCRATCH_MNT/ | grep -v 'lost+found' | sed -e '${/^$/d;}' | _filter_scratch
> +
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/790.out b/tests/generic/790.out
> new file mode 100644
> index 00000000..d9c0592d
> --- /dev/null
> +++ b/tests/generic/790.out
> @@ -0,0 +1,12 @@
> +QA output created by 790
> +Filesystem content after power failure:
> +
> +SCRATCH_MNT/:
> +dir1
> +dir2
> +foo
> +
> +SCRATCH_MNT/dir1:
> +
> +SCRATCH_MNT/dir2:
> +link
> -- 
> 2.47.2
> 
> 

  reply	other threads:[~2026-03-03 18:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 17:20 [PATCH] btrfs: test a directory fsync scenaro after replacing a subdir with a file fdmanana
2026-03-03 18:01 ` Darrick J. Wong
2026-03-03 18:08   ` Filipe Manana
2026-03-03 18:07 ` [PATCH v2] " fdmanana
2026-03-03 18:16   ` Darrick J. Wong [this message]
2026-03-04 13:05   ` Christoph Hellwig
2026-03-04 15:03     ` Filipe Manana
2026-03-04 15:18     ` Zorro Lang
2026-03-04 15:25       ` Christoph Hellwig
2026-03-04 15:56         ` Zorro Lang

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=20260303181644.GG13843@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 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.