Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2886638rwb; Mon, 15 Aug 2022 13:19:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Oe1J4nwapklXpB5mvFeIou9ctIFOe03H+DfLv85Aw4JbuOcuAG7b7RMkdekmTzh8Ux5Xe X-Received: by 2002:a17:90b:17c9:b0:1f3:3a7c:a3a7 with SMTP id me9-20020a17090b17c900b001f33a7ca3a7mr30610850pjb.76.1660594761973; Mon, 15 Aug 2022 13:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594761; cv=none; d=google.com; s=arc-20160816; b=X5swDw0p0HQI2Be8pZuFM3bKjCI8rG4so3kC6bZEDUlWBwbC89Uem43lkfdsh0j3mN RUHUt3/S0HAUsBXPFXFEbdC/6zcfk6UgXze8ngvIRm4pXrsNWCtZRkhshijFl7/GDNyw cD2nvcQA8SRustVVuTVZKx1ep7+SD5jj9fRMyBqIqBR7qn7q8XiNwM8Sh5yTyHcT2pjN lNcR/kmewQtHmi4luzK+U8Chypfh1vkpY4SrmQnE4SjnTfK2mtFBb8atW/BKhZcX3XZL joqmBZ8jnEaT0rk0llKWHyoPecB8RSe5nGNptUGEVDyBE31gfS4vVyAUx1pf/fJHO8H2 wJuQ== 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=+1wt10/UbAVGKcn3ukjKTZJLBn2fBq7MdGkoR2HnoLQ=; b=RMUw9d+xlHyTAcmpCdHD31zpbBs4F5SQRGxJd3+ribit2XynSUE7ZqvD//JD2u+/py q3XpOz6jkYh5p2AicL+Hx9fEc+LE/GM2Q5mVOjPVz45Rv9qtWItBeeoa87mnduu3s8IV 37tHCb9oCB7kuPpKea/wJucntiUWycKk3UXHbv8rhEzZr9SQTTGCJRj1LLt4cHrtguUh TtTLz2kFrnhQp6P0hQVfYctMs+gEZWU03YVwHu0EITV2ATyW/Cl4VAvhEofYBI6YW41r dy+f52CMhCtxch6OHYWhbEdfiTuF1AlB5W8qmxfLKlgEPHtxBKVKh0l8+oNJrQwsRUdv s2+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n55nGjSP; 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 a20-20020a17090ad81400b001efa8c6d942si8224285pjv.189.2022.08.15.13.19.10; Mon, 15 Aug 2022 13:19:21 -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=n55nGjSP; 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 S1345530AbiHOT57 (ORCPT + 99 others); Mon, 15 Aug 2022 15:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345593AbiHOTyq (ORCPT ); Mon, 15 Aug 2022 15:54:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FAB5474D0; Mon, 15 Aug 2022 11:52:10 -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 3316C6122A; Mon, 15 Aug 2022 18:52:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40180C433C1; Mon, 15 Aug 2022 18:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589528; bh=vRllzNOW7z4C9KZEF8OVgn21/Jd/wEYuUh01kNRgf3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n55nGjSPQrB5eYpvE+A/vhwhm0nI2bsa3T86fCCq6seoaUtNhN0bLAjkX9Gb4mzpS 2QmqLymPy7egZZNMq9XiHvvV8J9rquzeTGHDPKzsE9Gfjw3/XuV+CQes0wWzTvwlXd 8On3lP9V+WBQBic3jtBS+I7dI9FThL2AZTHgY1+E= 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.15 729/779] btrfs: properly flag filesystem with BTRFS_FEATURE_INCOMPAT_BIG_METADATA Date: Mon, 15 Aug 2022 20:06:13 +0200 Message-Id: <20220815180408.608022252@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 383e9c861306..e65c3039caf1 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3337,16 +3337,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); @@ -3387,6 +3377,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