Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3091540rwb; Mon, 15 Aug 2022 17:55:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ebrQGYcQeRqbpCIisroAn2aOcTgosxUIVyiSNpagufrHHY+LiqEAI/Dzz/R419mwjC97n X-Received: by 2002:a05:6402:3304:b0:43e:8623:c402 with SMTP id e4-20020a056402330400b0043e8623c402mr16733486eda.200.1660611197002; Mon, 15 Aug 2022 17:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611196; cv=none; d=google.com; s=arc-20160816; b=X8eRnH6nKGpZHWzMgbFLnA32GzJa+c55nmkmEPmEiHDkv5mXFYTt/Tt57LEKXtHGvd IaEHvRUWAjLsa7DiGViYN3JN097cN2EOtletg6/8wEnf1arUvw94+ZhltjN4BiZuQ4zW 6+Ic7pEfAuExKZlFS01iUeI5IwM2m99l7s7p9NPbC8axBoSlTZhpRMdNMhv+sliPAegX seEuzaWNWvJ25uDQMK7APWwwDhJkHgy0i5yJzbbr/WxlWDnMB4L4hGlKcoDFQXfzS9lP 6z0zaunZbYocuOAjgvxqJVuSFoJFsvr1lkOOVS/zGrIT4nFgzvnSNEcb7tDY8KBbk4dE FDCA== 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=2l6XiAc5x+ZS+GyG0htGcmqEvRgTGOgo+qJNLw+eo2U=; b=dPxaBLWYQW8guEMcAhAM5PJ97iHJfPJwmRZBCSALfha3AKzPr1BI3VilHSk/tCFZbu 8R0bxuYOSHEc1gTaOs/JxTeoOlYmAzRMABzKZLGlblM6+g2s1BR1UguNChrQMSkEDNVD SKDL6Cs9/lC/Vvb5gmE0iaVD+JRX2yjab/8RYC1//oCx28Q5c8gKnktDjizGi/jzbSIe LSNtP8A5zghPjJ4r1mbICoUTlm+ChZk24iiTDThxMwuovn3KERiY64Nqw3emyVg8akeM 3QfwPR9W/CcRe3whoFYB3IYuFkuGX2/R80lr3QztNRT8J9Rpd3/WGgEitU4WKAxKxj/c BX9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PpQ2WRJp; 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 b14-20020aa7c90e000000b0043cbacc60e0si7714207edt.388.2022.08.15.17.52.51; Mon, 15 Aug 2022 17:53:16 -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=PpQ2WRJp; 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 S245066AbiHOXYm (ORCPT + 99 others); Mon, 15 Aug 2022 19:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343624AbiHOXUl (ORCPT ); Mon, 15 Aug 2022 19:20:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED9FB4E80; Mon, 15 Aug 2022 13:04:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 99CAD61226; Mon, 15 Aug 2022 20:04:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84EEBC433B5; Mon, 15 Aug 2022 20:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593853; bh=jB0ttoGjb7G3INqAt6pTRAlPqBFKPCcILx++1gjZ16o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpQ2WRJpdP2bFVxiNAmoMhsHZJWO6X4+7ndhW0RXuIvzRDra6KQM0bvMWXuKphdU6 FyncAfc+76mJYLX2GtXdToioYRQZiGwHYgiW4rKvRb5OJksrS7f7Rg27GBXrtjimEi b2cAMq6qW8pd63gsu9oqAMMM282ooDUEuwBceR+k= 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.18 1016/1095] btrfs: properly flag filesystem with BTRFS_FEATURE_INCOMPAT_BIG_METADATA Date: Mon, 15 Aug 2022 20:06:55 +0200 Message-Id: <20220815180511.125864340@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 f45470798022..34cd57d799e4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3577,16 +3577,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); @@ -3627,6 +3617,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