linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] Btrfs: fix fsync after succession of renames of different files
Date: Fri, 15 Feb 2019 18:47:05 +0100	[thread overview]
Message-ID: <20190215174704.GH9874@twin.jikos.cz> (raw)
In-Reply-To: <20190213121403.3386-1-fdmanana@kernel.org>

On Wed, Feb 13, 2019 at 12:14:03PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> After a succession of rename operations of different files and fsyncing
> one of them, such that each file gets a new name that corresponds to an
> old name of another file, we can end up with a log that will cause a
> failure when attempted to replay at mount time (an EEXIST error).
> We currently have correct behaviour when such succession of renames
> involves only two files, but if there are more files involved, we end up
> not logging all the inodes that are needed, therefore resulting in a
> failure when attempting to replay the log.
> 
> Example:
> 
>   $ mkfs.btrfs -f /dev/sdb
>   $ mount /dev/sdb /mnt
> 
>   $ mkdir /mnt/testdir
>   $ touch /mnt/testdir/fname1
>   $ touch /mnt/testdir/fname2
> 
>   $ sync
> 
>   $ mv /mnt/testdir/fname1 /mnt/testdir/fname3
>   $ mv /mnt/testdir/fname2 /mnt/testdir/fname4
>   $ ln /mnt/testdir/fname3 /mnt/testdir/fname2
> 
>   $ touch /mnt/testdir/fname1
>   $ xfs_io -c "fsync" /mnt/testdir/fname1
> 
>   <power failure>
> 
>   $ mount /dev/sdb /mnt
>   mount: mount /dev/sdb on /mnt failed: File exists
> 
> So fix this by checking all inode dependencies when logging an inode. That
> is, if one logged inode A has a new name that matches the old name of some
> other inode B, check if inode B has a new name that matches the old name
> of some other inode C, and so on. This fix is implemented not by doing any
> recursive function calls but by using an iterative method using a linked
> list that is used in a first-in-first-out fashion.
> 
> A test case for fstests follows soon.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

1 and 2 lightly reviewed, added to for-next and scheduled for 5.1.
Thanks.

      reply	other threads:[~2019-02-15 17:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 18:06 [PATCH 1/2] Btrfs: fix fsync after succession of renames of different files fdmanana
2019-02-13 12:14 ` [PATCH v2 " fdmanana
2019-02-15 17:47   ` David Sterba [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=20190215174704.GH9874@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=fdmanana@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;
as well as URLs for NNTP newsgroup(s).