All of lore.kernel.org
 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] Btrfs: fix mount failure after fsync due to hard link recreation
Date: Thu, 2 Aug 2018 17:06:27 +0200	[thread overview]
Message-ID: <20180802150626.GP3218@twin.jikos.cz> (raw)
In-Reply-To: <20180720095906.3675-1-fdmanana@kernel.org>

On Fri, Jul 20, 2018 at 10:59:06AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If we end up with logging an inode reference item which has the same name
> but different index from the one we have persisted, we end up failing when
> replaying the log with an errno value of -EEXIST. The error comes from
> btrfs_add_link(), which is called from add_inode_ref(), when we are
> replaying an inode reference item.
> 
> Example scenario where this happens:
> 
>   $ mkfs.btrfs -f /dev/sdb
>   $ mount /dev/sdb /mnt
> 
>   $ touch /mnt/foo
>   $ ln /mnt/foo /mnt/bar
> 
>   $ sync
> 
>   # Rename the first hard link (foo) to a new name and rename the second
>   # hard link (bar) to the old name of the first hard link (foo).
>   $ mv /mnt/foo /mnt/qwerty
>   $ mv /mnt/bar /mnt/foo
> 
>   # Create a new file, in the same parent directory, with the old name of
>   # the second hard link (bar) and fsync this new file.
>   # We do this instead of calling fsync on foo/qwerty because if we did
>   # that the fsync resulted in a full transaction commit, not triggering
>   # the problem.
>   $ touch /mnt/bar
>   $ xfs_io -c "fsync" /mnt/bar
> 
>   <power fail>
> 
>   $ mount /dev/sdb /mnt
>   mount: mount /dev/sdb on /mnt failed: File exists
> 
> So fix this by checking if a conflicting inode reference exists (same
> name, same parent but different index), removing it (and the associated
> dir index entries from the parent inode) if it exists, before attempting
> to add the new reference.
> 
> A test case for fstests follows soon.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

The patch has been in misc-next for more than a weak but I probably did
not let you know, so here goes. Thanks.

      reply	other threads:[~2018-08-02 16:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 18:01 [PATCH] Btrfs: fix mount failure after fsync due to hard link recreation fdmanana
2018-07-20  9:59 ` [PATCH v2] " fdmanana
2018-08-02 15:06   ` 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=20180802150626.GP3218@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 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.