All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree
@ 2022-10-16 12:24 gregkh
  2022-10-24  7:08 ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2022-10-16 12:24 UTC (permalink / raw)
  To: wqu, dsterba, nborisov; +Cc: stable


The patch below does not apply to the 5.10-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 <stable@vger.kernel.org>.

Possible dependencies:

81d5d61454c3 ("btrfs: enhance unsupported compat RO flags handling")
dfe8aec4520b ("btrfs: add a btrfs_block_group_root() helper")
b6e9f16c5fda ("btrfs: replace open coded while loop with proper construct")
42437a6386ff ("btrfs: introduce mount option rescue=ignorebadroots")
68319c18cb21 ("btrfs: show rescue=usebackuproot in /proc/mounts")
ab0b4a3ebf14 ("btrfs: add a helper to print out rescue= options")
ceafe3cc3992 ("btrfs: sysfs: export supported rescue= mount options")
334c16d82cfe ("btrfs: push the NODATASUM check into btrfs_lookup_bio_sums")
d70bf7484f72 ("btrfs: unify the ro checking for mount options")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 81d5d61454c365718655cfc87d8200c84e25d596 Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
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 <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

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;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree
  2022-10-16 12:24 FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree gregkh
@ 2022-10-24  7:08 ` Qu Wenruo
  2022-10-24  7:46   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Qu Wenruo @ 2022-10-24  7:08 UTC (permalink / raw)
  To: gregkh, dsterba, nborisov; +Cc: stable



On 2022/10/16 20:24, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.10-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 <stable@vger.kernel.org>.
> 
> Possible dependencies:
> 
> 81d5d61454c3 ("btrfs: enhance unsupported compat RO flags handling")
> dfe8aec4520b ("btrfs: add a btrfs_block_group_root() helper")
> b6e9f16c5fda ("btrfs: replace open coded while loop with proper construct")
> 42437a6386ff ("btrfs: introduce mount option rescue=ignorebadroots")

Hi Greg and btrfs guys,

I'm not confident enough to continue backporting this patch (and its 
dependency) for older branches.

This patch itself relies on the new function fill_dummy_bgs() to skip 
the full block group items search.

That function is the core functionality to allow us to mount fses 
read-only with unsupported compat_ro flags.

But if we backport 42437a6386ff ("btrfs: introduce mount option 
rescue=ignorebadroots"), we need the "rescue=" mount option series, 
which can be super large, especially for older and older branches.

The other solution is to still implement that fill_dummy_bgs(), but not 
introducing the "rescue=" mount option.
This means, we will have some moderate changes to 42437a6386ff ("btrfs: 
introduce mount option rescue=ignorebadroots"), but at least no full 
dependency on the "rescue=" mount options.

I'm wondering which solution would be more acceptable from the POV of 
stable kernels?

Thanks,
Qu

> 68319c18cb21 ("btrfs: show rescue=usebackuproot in /proc/mounts")
> ab0b4a3ebf14 ("btrfs: add a helper to print out rescue= options")
> ceafe3cc3992 ("btrfs: sysfs: export supported rescue= mount options")
> 334c16d82cfe ("btrfs: push the NODATASUM check into btrfs_lookup_bio_sums")
> d70bf7484f72 ("btrfs: unify the ro checking for mount options")
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
>  From 81d5d61454c365718655cfc87d8200c84e25d596 Mon Sep 17 00:00:00 2001
> From: Qu Wenruo <wqu@suse.com>
> 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 <nborisov@suse.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Reviewed-by: David Sterba <dsterba@suse.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> 
> 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;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree
  2022-10-24  7:08 ` Qu Wenruo
@ 2022-10-24  7:46   ` Greg KH
  2022-10-24  8:03     ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2022-10-24  7:46 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: dsterba, nborisov, stable

On Mon, Oct 24, 2022 at 03:08:21PM +0800, Qu Wenruo wrote:
> 
> 
> On 2022/10/16 20:24, gregkh@linuxfoundation.org wrote:
> > 
> > The patch below does not apply to the 5.10-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 <stable@vger.kernel.org>.
> > 
> > Possible dependencies:
> > 
> > 81d5d61454c3 ("btrfs: enhance unsupported compat RO flags handling")
> > dfe8aec4520b ("btrfs: add a btrfs_block_group_root() helper")
> > b6e9f16c5fda ("btrfs: replace open coded while loop with proper construct")
> > 42437a6386ff ("btrfs: introduce mount option rescue=ignorebadroots")
> 
> Hi Greg and btrfs guys,
> 
> I'm not confident enough to continue backporting this patch (and its
> dependency) for older branches.
> 
> This patch itself relies on the new function fill_dummy_bgs() to skip the
> full block group items search.
> 
> That function is the core functionality to allow us to mount fses read-only
> with unsupported compat_ro flags.
> 
> But if we backport 42437a6386ff ("btrfs: introduce mount option
> rescue=ignorebadroots"), we need the "rescue=" mount option series, which
> can be super large, especially for older and older branches.
> 
> The other solution is to still implement that fill_dummy_bgs(), but not
> introducing the "rescue=" mount option.
> This means, we will have some moderate changes to 42437a6386ff ("btrfs:
> introduce mount option rescue=ignorebadroots"), but at least no full
> dependency on the "rescue=" mount options.
> 
> I'm wondering which solution would be more acceptable from the POV of stable
> kernels?

First off, is this really needed in older kernels?  It was marked as
such, but that's up to you all to decide if it's true or not.

So I'll defer to you and the btrfs maintainers on what to do, just let
us know.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree
  2022-10-24  7:46   ` Greg KH
@ 2022-10-24  8:03     ` Qu Wenruo
  0 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2022-10-24  8:03 UTC (permalink / raw)
  To: Greg KH; +Cc: dsterba, nborisov, stable



On 2022/10/24 15:46, Greg KH wrote:
> On Mon, Oct 24, 2022 at 03:08:21PM +0800, Qu Wenruo wrote:
>>
>>
>> On 2022/10/16 20:24, gregkh@linuxfoundation.org wrote:
>>>
>>> The patch below does not apply to the 5.10-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 <stable@vger.kernel.org>.
>>>
>>> Possible dependencies:
>>>
>>> 81d5d61454c3 ("btrfs: enhance unsupported compat RO flags handling")
>>> dfe8aec4520b ("btrfs: add a btrfs_block_group_root() helper")
>>> b6e9f16c5fda ("btrfs: replace open coded while loop with proper construct")
>>> 42437a6386ff ("btrfs: introduce mount option rescue=ignorebadroots")
>>
>> Hi Greg and btrfs guys,
>>
>> I'm not confident enough to continue backporting this patch (and its
>> dependency) for older branches.
>>
>> This patch itself relies on the new function fill_dummy_bgs() to skip the
>> full block group items search.
>>
>> That function is the core functionality to allow us to mount fses read-only
>> with unsupported compat_ro flags.
>>
>> But if we backport 42437a6386ff ("btrfs: introduce mount option
>> rescue=ignorebadroots"), we need the "rescue=" mount option series, which
>> can be super large, especially for older and older branches.
>>
>> The other solution is to still implement that fill_dummy_bgs(), but not
>> introducing the "rescue=" mount option.
>> This means, we will have some moderate changes to 42437a6386ff ("btrfs:
>> introduce mount option rescue=ignorebadroots"), but at least no full
>> dependency on the "rescue=" mount options.
>>
>> I'm wondering which solution would be more acceptable from the POV of stable
>> kernels?
> 
> First off, is this really needed in older kernels?  It was marked as
> such, but that's up to you all to decide if it's true or not.

This is mostly related to a corner case that, certain compat_ro flags 
should be allowed to be mounted RO for older kernels.

There is already one such feature, called block-group-tree, and with 
that patch, we should be able to mount a fs with such feature read-only.
(RW mount is still not supported until v6.1 kernel).


The root cause is from our uncertain understanding on which features 
should be counted as compat_ro.
Until recently we don't really bothered incompat/compat_ro flags, and 
tends to caused quite some incompatible features which should be compat_ro.

Thus I want to mark this patch for all stable kernels, and push for the 
more accurate incompat/compat_ro flags splitting.

Without this patch, the new block-group-tree feature will just be 
rejected (no matter RO or not) due to older kernel can not skip the 
unnecessary block group items search.

Maybe it's not that important and time can solve it?

Thanks,
Qu

> 
> So I'll defer to you and the btrfs maintainers on what to do, just let
> us know.
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-24  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 12:24 FAILED: patch "[PATCH] btrfs: enhance unsupported compat RO flags handling" failed to apply to 5.10-stable tree gregkh
2022-10-24  7:08 ` Qu Wenruo
2022-10-24  7:46   ` Greg KH
2022-10-24  8:03     ` Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.