public inbox for linux-btrfs@vger.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 2/3] Btrfs: fix wrong ctime and mtime of a directory after log replay
Date: Tue, 28 May 2019 19:19:24 +0200	[thread overview]
Message-ID: <20190528171924.GV15290@twin.jikos.cz> (raw)
In-Reply-To: <20190515150247.24776-1-fdmanana@kernel.org>

On Wed, May 15, 2019 at 04:02:47PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> When replaying a log that contains a new file or directory name that needs
> to be added to its parent directory, we end up updating the mtime and the
> ctime of the parent directory to the current time after we have set their
> values to the correct ones (set at fsync time), efectivelly losing them.
> 
> Sample reproducer:
> 
>   $ mkfs.btrfs -f /dev/sdb
>   $ mount /dev/sdb /mnt
> 
>   $ mkdir /mnt/dir
>   $ touch /mnt/dir/file
> 
>   # fsync of the directory is optional, not needed
>   $ xfs_io -c fsync /mnt/dir
>   $ xfs_io -c fsync /mnt/dir/file
> 
>   $ stat -c %Y /mnt/dir
>   1557856079
> 
>   <power failure>
> 
>   $ sleep 3
>   $ mount /dev/sdb /mnt
>   $ stat -c %Y /mnt/dir
>   1557856082
> 
>     --> should have been 1557856079, the mtime is updated to the current
>         time when replaying the log
> 
> Fix this by not updating the mtime and ctime to the current time at
> btrfs_add_link() when we are replaying a log tree.
> 
> This could be triggered by my recent fsync fuzz tester for fstests, for
> which an fstests patch exists titled "fstests: generic, fsync fuzz tester
> with fsstress".
> 
> Fixes: e02119d5a7b43 ("Btrfs: Add a write ahead tree log to optimize synchronous operations")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Added to 5.2-rc queue, thanks.

      parent reply	other threads:[~2019-05-28 17:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 15:02 [PATCH 2/3] Btrfs: fix wrong ctime and mtime of a directory after log replay fdmanana
2019-05-16  7:09 ` Nikolay Borisov
2019-05-28 17:19 ` 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=20190528171924.GV15290@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