public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: fdmanana@kernel.org
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] generic: test fsync of directory after renaming new symlink
Date: Fri, 24 Oct 2025 06:41:41 -0700	[thread overview]
Message-ID: <aPuCFeWGuxG4am51@devvm12410.ftw0.facebook.com> (raw)
In-Reply-To: <54585ed26988fb88be1eab8211aa383a5e7cbd19.1761306683.git.fdmanana@suse.com>

On Fri, Oct 24, 2025 at 12:53:12PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Test that if we fsync a directory that has a new symlink, then rename the
> symlink and fsync again the directory, after a power failure the symlink
> exists with the new name and not the old one.
> 
> This is to exercise a bug in btrfs where we ended up not persisting the
> new name of the symlink. That is fixed by a kernel patch that has the
> following subject:
> 
>  "btrfs: set inode flag BTRFS_INODE_COPY_EVERYTHING when logging new name"
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Boris Burkov <boris@bur.io>

> ---
>  tests/generic/779     | 60 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/779.out |  2 ++
>  2 files changed, 62 insertions(+)
>  create mode 100755 tests/generic/779
>  create mode 100644 tests/generic/779.out
> 
> diff --git a/tests/generic/779 b/tests/generic/779
> new file mode 100755
> index 00000000..40d1a86c
> --- /dev/null
> +++ b/tests/generic/779
> @@ -0,0 +1,60 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 SUSE S.A.  All Rights Reserved.
> +#
> +# FS QA Test 779
> +#
> +# Test that if we fsync a directory that has a new symlink, then rename the
> +# symlink and fsync again the directory, after a power failure the symlink
> +# exists with the new name and not the old one.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick log
> +
> +_cleanup()
> +{
> +	_cleanup_flakey
> +	cd /
> +	rm -r -f $tmp.*
> +}
> +
> +. ./common/dmflakey
> +
> +_require_scratch
> +_require_symlinks
> +_require_dm_target flakey
> +
> +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit xxxxxxxxxxxx \
> +	"btrfs: set inode flag BTRFS_INODE_COPY_EVERYTHING when logging new name"
> +
> +rm -f $seqres.full
> +
> +_scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
> +_require_metadata_journaling $SCRATCH_DEV
> +_init_flakey
> +_mount_flakey
> +
> +# Create our test dir and add a symlink inside it.
> +mkdir $SCRATCH_MNT/dir
> +ln -s foobar $SCRATCH_MNT/dir/old-slink
> +
> +# Fsync the test dir, should persist the symlink.
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir
> +
> +# Rename the symlink and fsync the directory. It should persist the new symlink
> +# name.
> +mv $SCRATCH_MNT/dir/old-slink $SCRATCH_MNT/dir/new-slink
> +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/dir
> +
> +# Simulate a power failure and then mount again the filesystem to replay the
> +# journal/log.
> +_flakey_drop_and_remount
> +
> +# Check that the symlink exists with the new name and has the correct content.
> +[ -L $SCRATCH_MNT/dir/new-slink ] || echo "symlink dir/new-slink not found"
> +echo "symlink content: $(readlink $SCRATCH_MNT/dir/new-slink)"
> +
> +_unmount_flakey
> +
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/779.out b/tests/generic/779.out
> new file mode 100644
> index 00000000..c595cd01
> --- /dev/null
> +++ b/tests/generic/779.out
> @@ -0,0 +1,2 @@
> +QA output created by 779
> +symlink content: foobar
> -- 
> 2.47.2
> 

  reply	other threads:[~2025-10-24 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 11:53 [PATCH] generic: test fsync of directory after renaming new symlink fdmanana
2025-10-24 13:41 ` Boris Burkov [this message]
2025-10-25 10:13 ` Qu Wenruo
2025-10-25 19:39   ` Filipe Manana
2025-11-01  9:27     ` 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=aPuCFeWGuxG4am51@devvm12410.ftw0.facebook.com \
    --to=boris@bur.io \
    --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