From: David Sterba <dsterba@suse.cz>
To: Filipe Manana <fdmanana@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2 v10] Btrfs: be aware of btree inode write errors to avoid fs corruption
Date: Thu, 25 Sep 2014 18:30:49 +0200 [thread overview]
Message-ID: <20140925163049.GE9715@twin.jikos.cz> (raw)
In-Reply-To: <1411663905-25543-1-git-send-email-fdmanana@suse.com>
On Thu, Sep 25, 2014 at 05:51:45PM +0100, Filipe Manana wrote:
> + switch (eb->log_index) {
> + case -1:
> + set_bit(BTRFS_INODE_BTREE_ERR, &btree_ino->runtime_flags);
> + break;
> + case 0:
> + set_bit(BTRFS_INODE_BTREE_LOG1_ERR, &btree_ino->runtime_flags);
> + break;
> + case 1:
> + set_bit(BTRFS_INODE_BTREE_LOG2_ERR, &btree_ino->runtime_flags);
> + break;
> + default:
> + ASSERT(0); /* unexpected, logic error */
I think we can afford a BUG() here, preceded by a message. The logic is
pretty strict about the possible values so if we get here, something is
really bad and we don't want to make it silent.
This could happen if the memory modules are faulty and tripping over
random BUG_ONs is usually a sign of problems. I've seen that in the
past with certain CPU types during stresstests and it definetely was
worth knowing. (The BUG_ONs were in memory management, it's not a crime
to use them, only in place of proper error hanling.)
> --- a/fs/btrfs/extent_io.h
> +++ b/fs/btrfs/extent_io.h
> @@ -141,7 +142,9 @@ struct extent_buffer {
> atomic_t blocking_readers;
> atomic_t spinning_readers;
> atomic_t spinning_writers;
> - int lock_nested;
> + unsigned int lock_nested:1;
Please do not use bitfields next to atomic_t or spin_lock (or kref_t),
this can lead to all sorts of funny problems on architectures that are
not able to do atomic bit operations and have to do read-modify-write
cycle. This leads to problems when it's on the same 8-byte word with an
atomic/... and can corrupt it if the timing is right.
next prev parent reply other threads:[~2014-09-25 16:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-22 16:41 [PATCH 1/2] Btrfs: add missing end_page_writeback on submit_extent_page failure Filipe Manana
2014-09-22 16:41 ` [PATCH 2/2] Btrfs: be aware of btree inode write errors to avoid fs corruption Filipe Manana
2014-09-23 14:05 ` Liu Bo
2014-09-23 14:27 ` Filipe David Manana
2014-09-24 0:20 ` [PATCH 2/2 v2] " Filipe Manana
2014-09-24 0:43 ` [PATCH 2/2 v3] " Filipe Manana
2014-09-24 4:49 ` [PATCH 2/2 v4] " Filipe Manana
2014-09-24 10:28 ` [PATCH 2/2 v5] " Filipe Manana
2014-09-24 11:16 ` Miao Xie
2014-09-24 12:59 ` Filipe David Manana
2014-09-24 17:19 ` [PATCH 2/2 v6] " Filipe Manana
2014-09-24 22:20 ` [PATCH 2/2 v7] " Filipe Manana
2014-09-25 11:12 ` [PATCH 2/2 v8] " Filipe Manana
2014-09-25 16:33 ` [PATCH 2/2 v9] " Filipe Manana
2014-09-25 16:51 ` [PATCH 2/2 v10] " Filipe Manana
2014-09-25 16:30 ` David Sterba [this message]
2014-09-25 18:01 ` [PATCH 2/2 v11] " Filipe Manana
2014-09-26 11:25 ` [PATCH 2/2 v12] " Filipe Manana
2014-09-23 10:14 ` [PATCH 1/2] Btrfs: add missing end_page_writeback on submit_extent_page failure Liu Bo
2014-09-23 13:03 ` Filipe David Manana
2014-09-23 13:39 ` Liu Bo
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=20140925163049.GE9715@twin.jikos.cz \
--to=dsterba@suse.cz \
--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).