From: David Sterba <dsterba@suse.cz>
To: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Anand Jain <anand.jain@oracle.com>, Liu Bo <bo.li.liu@oracle.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 4.14 024/110] btrfs: use proper endianness accessors for super_copy
Date: Mon, 19 Mar 2018 20:32:21 +0100 [thread overview]
Message-ID: <20180319193221.GP6955@suse.cz> (raw)
In-Reply-To: <1521305582@msgid.manchmal.in-ulm.de>
On Sat, Mar 17, 2018 at 06:27:15PM +0100, Christoph Biedl wrote:
> Greg Kroah-Hartman wrote...
>
> > On Thu, Mar 15, 2018 at 07:55:42PM +0100, Christoph Biedl wrote:
>
> > > > commit 3c181c12c431fe33b669410d663beb9cceefcd1b upstream.
>
> > > On big-endian systems, this change intruduces severe corruption,
> > > resulting in complete loss of the data on the used block device.
>
> > That sucks. Can you test Linus's tree to verify the problem is there?
> > I'll gladly revert this if Linus's tree also gets the revert, I don't
> > want you to hit this when you upgrade to a newer kernel.
>
> Confirmed: The problem is, err ... was in Linus' tree as well. The
> rather recent commit 8f5fd927c3a7 reverted the change, after that
> everything is as expected again.
Thanks for checking.
> Looking at the original commit, I don't have a clue why things go wrong
> so horribly
It's a half endianness conversion. The plain in-memory structures are in
LE and has to be accessed via the helpers, super block copy and the
root item. The commit adds only one half of the conversion, that
naturally does not exhibit on LE, because the macros are no-op.
Originally, the items were stored from the on-disk type to on-disk type,
regardless of the CPU:
super->chunk_root = root_item->bytenr;
The patch should have added conversion of both values, like
btrfs_set_super_chunk_root(super, btrfs_root_bytenr(root_item));
and not
btrfs_set_super_chunk_root(super, root_item->bytenr);
It's not very obvious from the context though, typically there's one
structure that needs the accessors and is set from a value that's in CPU
byteorder. I think that the exception to this pattern confused all
involved developers.
The root_item members are annotated as __le64 that should be caught by
sparse/smatch checker in the buggy case, but we don't run the checkers
every the time.
> - otherwise don't be afraid of my data. I took this as a
> chance to verify my data recovery procedure, with success.
Should that not be the case, the damaged items in superblock can be
byteswapped back. That's 6 x u64 at most, I have a tool for that now.
Thanks again for the report and sorry for the trouble.
next prev parent reply other threads:[~2018-03-19 19:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180307191039.748351103@linuxfoundation.org>
[not found] ` <20180307191042.810088712@linuxfoundation.org>
[not found] ` <1521139304@msgid.manchmal.in-ulm.de>
2018-03-16 12:30 ` [PATCH 4.14 024/110] btrfs: use proper endianness accessors for super_copy Greg Kroah-Hartman
2018-03-16 13:22 ` David Sterba
2018-03-16 14:02 ` Greg Kroah-Hartman
2018-03-16 16:21 ` Anand Jain
2018-03-17 17:27 ` Christoph Biedl
2018-03-19 19:32 ` David Sterba [this message]
2018-03-20 9:32 ` Anand Jain
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=20180319193221.GP6955@suse.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=bo.li.liu@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel.bfrz@manchmal.in-ulm.de \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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).