Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3124551rwb; Mon, 15 Aug 2022 18:44:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5166uElHjjQjhy6PgWzMBL+I5thGE0kfR8NkId9cy/J9U+6efnlx5dzYhifek1ZcFSNHUb X-Received: by 2002:a17:906:93fa:b0:731:a80:2444 with SMTP id yl26-20020a17090693fa00b007310a802444mr12238761ejb.121.1660614262468; Mon, 15 Aug 2022 18:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660614262; cv=none; d=google.com; s=arc-20160816; b=FE6nn1ScfjkJkLeWJEd9emiyNUpTUPWiPNnzsj7EA4jQK0CJqS78qbuVfAiCr0gFq7 W+eLPBUlhPbFvkpvElTCPksUid9BpyAq3itTd/qjPsbTC30tNA+hVIQHIzmTi+13F6Lf zxAsRrf9t0R/DXT1PVXGeP2TMmVHhMr0zhkDb65DfEgwaxtd/Rl5hcIJWuIpOVQD/Ag9 bAap9h6uIQ6ECbJbF8r80kzuf0UInFTf2141cFyYl96K694c5qcB0rcvJKfNY0ZX2CZO WPFqJR2y+Mgo516JE3LWoVgoO+mOY3fvpt3+Ivy0AOx0NgF9WtEKnpWQebaLMa3WMuZ0 0oew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cosUd6SQ7tz4Mr1RnZ+YgiNEfOakQfTiM/9PSsk+CzY=; b=qnYYwAo7FbQRLrREENcOnF6R7e7UhfRSq3A3z9fZ1g8+JTUPnMa+PDVRswEVy3Mt5h v3omv0n5v1E/SWGD3ASI/fQUs2z70klsT/8UEWbGYObLdFDwwmnVIQNOK9yl5dpyoDKH LAtEezzSeDmqRrkZh9Lw5XbJyfLkudWqYL/wZmykOaE1xoDMbkRfxtBZYfJpV14Utez6 ImzB/IqQzTpdXiL8dKrlWdIUuZahcREYtUqL7NnwVMrTDna+BzKL1Ror8yc+kGc8cSRc z15zx1FJzCnFk4HHHr3WJ1Wd3xtt7CFGaNbmDcWE+E4NTFVS3HSIin1wezKPh2KNsQGY MoWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TsuWStw0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a056402280400b0043d100bcf3bsi10623486ede.538.2022.08.15.18.43.56; Mon, 15 Aug 2022 18:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TsuWStw0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346837AbiHPBC5 (ORCPT + 99 others); Mon, 15 Aug 2022 21:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347465AbiHPA5R (ORCPT ); Mon, 15 Aug 2022 20:57:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A851DB046; Mon, 15 Aug 2022 13:48:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E5F1AB811A1; Mon, 15 Aug 2022 20:48:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58142C43148; Mon, 15 Aug 2022 20:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596534; bh=eGIk33ETJU0N/9AykTe9YPBR4KmXAPQ+uEq+UtVzrQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TsuWStw0IXSbI8bSdVrwpdXEux/0mDrNNZTiqjMWpk1Ruas3Rrn/3t0NTnKL1yMav STPEh0CQFs+9dicV4DJhL4ZosRP/0LTT+H1ocFGEyScEwuVIT9HYCfeTwQUNY+OwIr 3IW46Y2VxL23kNHisiLL/vbqcRM4CbbogQ2I0jK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 5.19 1083/1157] btrfs: properly flag filesystem with BTRFS_FEATURE_INCOMPAT_BIG_METADATA Date: Mon, 15 Aug 2022 20:07:19 +0200 Message-Id: <20220815180523.492938427@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikolay Borisov [ Upstream commit e26b04c4c91925dba57324db177a24e18e2d0013 ] Commit 6f93e834fa7c seemingly inadvertently moved the code responsible for flagging the filesystem as having BIG_METADATA to a place where setting the flag was essentially lost. This means that filesystems created with kernels containing this bug (starting with 5.15) can potentially be mounted by older (pre-3.4) kernels. In reality chances for this happening are low because there are other incompat flags introduced in the mean time. Still the correct behavior is to set INCOMPAT_BIG_METADATA flag and persist this in the superblock. Fixes: 6f93e834fa7c ("btrfs: fix upper limit for max_inline for page size 64K") CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Qu Wenruo Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/disk-io.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8daa5bb93a4c..e33f2fa50b0f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3593,16 +3593,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device */ fs_info->compress_type = BTRFS_COMPRESS_ZLIB; - /* - * Flag our filesystem as having big metadata blocks if they are bigger - * than the page size. - */ - if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { - if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) - btrfs_info(fs_info, - "flagging fs with big metadata feature"); - features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; - } /* Set up fs_info before parsing mount options */ nodesize = btrfs_super_nodesize(disk_super); @@ -3643,6 +3633,17 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) btrfs_info(fs_info, "has skinny extents"); + /* + * Flag our filesystem as having big metadata blocks if they are bigger + * than the page size. + */ + if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { + if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) + btrfs_info(fs_info, + "flagging fs with big metadata feature"); + features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; + } + /* * mixed block groups end up with duplicate but slightly offset * extent buffers for the same range. It leads to corruptions -- 2.35.1