From: Chris Mason <clm@fb.com>
To: Filipe Manana <fdmanana@suse.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: fix data corruption after fast fsync and writeback error
Date: Mon, 8 Sep 2014 16:51:40 -0400 [thread overview]
Message-ID: <540E16DC.2040708@fb.com> (raw)
In-Reply-To: <1409926479-8870-1-git-send-email-fdmanana@suse.com>
On 09/05/2014 10:14 AM, Filipe Manana wrote:
> When we do a fast fsync, we start all ordered operations and then while
> they're running in parallel we visit the list of modified extent maps
> and construct their matching file extent items and write them to the
> log btree. After that, in btrfs_sync_log() we wait for all the ordered
> operations to finish (via btrfs_wait_logged_extents).
>
> The problem with this is that we were completely ignoring errors that
> can happen in the extent write path, such as -ENOSPC, a temporary -ENOMEM
> or -EIO errors for example. When such error happens, it means we have parts
> of the on disk extent that weren't written to, and so we end up logging
> file extent items that point to these extents that contain garbage/random
> data - so after a crash/reboot plus log replay, we get our inode's metadata
> pointing to those extents.
>
> This worked in contrast with the full (non-fast) fsync path, where we
> start all ordered operations, wait for them to finish and then write
> to the log btree. In this path, after each ordered operation completes
> we check if it's flagged with an error (BTRFS_ORDERED_IOERR) and return
> -EIO if so (via btrfs_wait_ordered_range).
>
> So if an error happens with any ordered operation, just return a -EIO
> error to userspace, so that it knows that not all of its previous writes
> were durably persisted and the application can take proper action (like
> redo the writes for e.g.) - and definitely not leave any file extent items
> in the log refer to non fully written extents.
Thanks Filipe,
I'm pushing this one off for the merge window. It's not that I think
it's wrong, but we're getting late in the rcs and I want to test it more.
-chris
prev parent reply other threads:[~2014-09-08 20:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 14:14 [PATCH] Btrfs: fix data corruption after fast fsync and writeback error Filipe Manana
2014-09-08 20:51 ` Chris Mason [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=540E16DC.2040708@fb.com \
--to=clm@fb.com \
--cc=fdmanana@suse.com \
--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).