From nobody Sun Dec 14 06:17:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 416DAC00140 for ; Mon, 15 Aug 2022 19:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbiHOT6D (ORCPT ); Mon, 15 Aug 2022 15:58:03 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 6= 4K") 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 =3D BTRFS_COMPRESS_ZLIB; =20 - /* - * 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 |=3D BTRFS_FEATURE_INCOMPAT_BIG_METADATA; - } =20 /* Set up fs_info before parsing mount options */ nodesize =3D 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"); =20 + /* + * 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 |=3D 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 --=20 2.35.1