Received: by 10.213.65.68 with SMTP id h4csp1765318imn; Mon, 19 Mar 2018 12:38:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELsk1fgD3/4QksSluQWZIXct4+HqmYg+GX0ftWL7jslasfHtmXGGX6np2SJ5KKCYuj13YvF+ X-Received: by 2002:a17:902:9a42:: with SMTP id x2-v6mr1060786plv.201.1521488297641; Mon, 19 Mar 2018 12:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488297; cv=none; d=google.com; s=arc-20160816; b=GmBMzWvXaQMsZVbnkQMa72RGPdW9q8o8YSx3vGKkZMJQGFK/pZnJx+MG3EHtrNeTBi P1YTjjczSD2qOdzd1qntmS/9cbqTfK1y6m6SJKTohsHfpZ+nJY/8jy82sqFpGXz5cbMF xBnly8x98IShrDlrVd7ZS7Ek+1ByDRt1ZCtwR21YDgOOfcwLq63AiEoTJu3jXJmV8lFD V+kNEy07SxIjJLycSnR5BgrUrQJ1VJtAN/01qW3hJaxf/zHVVKGS9OKqp/9dBUTD7fqM s0OQRdN8F+xrtxJZFeWlPlTzbKqQ1ESdy4QGcopgp27WcDeTFezaxmn5C/q5p3Y4JjFH ET+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=T2TyVwYlgs9/SHJ/GahqsbKRMHmqCsDwfgM5SxLyVVc=; b=hg+Skk7EcaIL9DZ2ix7ddHE/mF7LBqp57XZqyDJx0jHedG34QtfRcaR5ypnu4pm41c sHzpukmuvX/i2A1ao4LeLT0rkceaVCCuZ3lRLNzM1rQC0KXCrBlFsmpcWSOaDvic0B8+ DZgL4JdZ9dCih4fZvIQ3HJgigEIVn62ZwkPq76JdqQUuHJisG0SnYldPCrcb2Vi+olLv XPocHdfrxoj7fzFLoblQvZNybAFMyRnu2nas052sVL6Espq6QyqHcjxiylFBY1iPT4MY ax1f8bpCsGNitHyXGtaD6XSmW/Q0GGwQVATbYXdGLPJRIEVNtwEQcTSdzY9V0vb95wPJ mbZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si434902pfh.84.2018.03.19.12.38.02; Mon, 19 Mar 2018 12:38:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967540AbeCSTfL (ORCPT + 99 others); Mon, 19 Mar 2018 15:35:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:37069 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936089AbeCSTer (ORCPT ); Mon, 19 Mar 2018 15:34:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C52FAAF3E; Mon, 19 Mar 2018 19:34:45 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 63450DA8BB; Mon, 19 Mar 2018 20:32:21 +0100 (CET) Date: Mon, 19 Mar 2018 20:32:21 +0100 From: David Sterba To: Christoph Biedl Cc: Greg Kroah-Hartman , Anand Jain , Liu Bo , 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 Message-ID: <20180319193221.GP6955@suse.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Christoph Biedl , Greg Kroah-Hartman , Anand Jain , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20180307191039.748351103@linuxfoundation.org> <20180307191042.810088712@linuxfoundation.org> <1521139304@msgid.manchmal.in-ulm.de> <20180316123049.GC25079@kroah.com> <1521305582@msgid.manchmal.in-ulm.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1521305582@msgid.manchmal.in-ulm.de> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.