From mboxrd@z Thu Jan 1 00:00:00 1970 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 4A2E6C433FE for ; Sun, 16 Oct 2022 12:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiJPMYO (ORCPT ); Sun, 16 Oct 2022 08:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbiJPMYN (ORCPT ); Sun, 16 Oct 2022 08:24:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C49732EF0 for ; Sun, 16 Oct 2022 05:24:12 -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 E92EE60B55 for ; Sun, 16 Oct 2022 12:24:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02A68C433D6; Sun, 16 Oct 2022 12:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665923051; bh=GrysRSydjmxqMBaneg1GatTLSNyeTRXI8vbyWzTIW9I=; h=Subject:To:Cc:From:Date:From; b=rj42HKQDqqg7+JQ8s5VUvK9YLK7U1GzGNiUKiZricLuepqgRYBTkElOggzSkDcyP9 N9jiTQiS+i5gfUUwiqBYm99AbyMX3neGAScyiXiLvMVDi0X28P5iPmlCVM3ipq9Aj3 isvdkxIT81+wGC1Xn4u44Gg17LYslEvJwI5uLxIc= Subject: FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.15-stable tree To: wqu@suse.com, dsterba@suse.com, nborisov@suse.com Cc: From: Date: Sun, 16 Oct 2022 14:24:57 +0200 Message-ID: <166592309723244@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Possible dependencies: 81d5d61454c3 ("btrfs: enhance unsupported compat RO flags handling") dfe8aec4520b ("btrfs: add a btrfs_block_group_root() helper") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 81d5d61454c365718655cfc87d8200c84e25d596 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 9 Aug 2022 13:02:16 +0800 Subject: [PATCH] btrfs: enhance unsupported compat RO flags handling Currently there are two corner cases not handling compat RO flags correctly: - Remount We can still mount the fs RO with compat RO flags, then remount it RW. We should not allow any write into a fs with unsupported RO flags. - Still try to search block group items In fact, behavior/on-disk format change to extent tree should not need a full incompat flag. And since we can ensure fs with unsupported RO flags never got any writes (with above case fixed), then we can even skip block group items search at mount time. This patch will enhance the unsupported RO compat flags by: - Reject read-write remount if there are unsupported RO compat flags - Go dummy block group items directly for unsupported RO compat flags In fact, only changes to chunk/subvolume/root/csum trees should go incompat flags. The latter part should allow future change to extent tree to be compat RO flags. Thus this patch also needs to be backported to all stable trees. CC: stable@vger.kernel.org # 4.9+ Reviewed-by: Nikolay Borisov Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 53c44c52cb79..e7b5a54c8258 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2164,7 +2164,16 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) int need_clear = 0; u64 cache_gen; - if (!root) + /* + * Either no extent root (with ibadroots rescue option) or we have + * unsupported RO options. The fs can never be mounted read-write, so no + * need to waste time searching block group items. + * + * This also allows new extent tree related changes to be RO compat, + * no need for a full incompat flag. + */ + if (!root || (btrfs_super_compat_ro_flags(info->super_copy) & + ~BTRFS_FEATURE_COMPAT_RO_SUPP)) return fill_dummy_bgs(info); key.objectid = 0; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 7291e9d67e92..eb0ae7e396ef 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2117,6 +2117,15 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) ret = -EINVAL; goto restore; } + if (btrfs_super_compat_ro_flags(fs_info->super_copy) & + ~BTRFS_FEATURE_COMPAT_RO_SUPP) { + btrfs_err(fs_info, + "can not remount read-write due to unsupported optional flags 0x%llx", + btrfs_super_compat_ro_flags(fs_info->super_copy) & + ~BTRFS_FEATURE_COMPAT_RO_SUPP); + ret = -EINVAL; + goto restore; + } if (fs_info->fs_devices->rw_devices == 0) { ret = -EACCES; goto restore;