Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option
@ 2026-07-03  9:46 Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 1/3] btrfs: add "rescue=usebackuproot" into forced read-only options Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Qu Wenruo @ 2026-07-03  9:46 UTC (permalink / raw)
  To: linux-btrfs

[CHANGELOG]
v3:
- Add "rescue=usebackuproot" into full RO mount options
- Minor grammar updates

v2:
- Also include "rescue=usebackuproot" into "rescue=all" shortcut

"rescue=usebackuproot" mount option is not requiring a read-only mount,
which is different from all the other options in the "rescue=" group.
Address that in the first patch.

Then also include "rescue=usebackuproot" into "rescue=all" group, done
in the second patch.

Standalone "usebackuproot" mount option is already marked deprecated
since v5.9, I see no practical reason to keep supporting it in 2026.
Just remove it in the last patch.

Qu Wenruo (3):
  btrfs: add "rescue=usebackuproot" into forced read-only options
  btrfs: add "rescue=usebackuproot" into "rescue=all" shortcut
  btrfs: remove "usebackuproot" mount option

 fs/btrfs/fs.h    |  3 ++-
 fs/btrfs/super.c | 16 +++-------------
 2 files changed, 5 insertions(+), 14 deletions(-)

-- 
2.54.0


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

* [PATCH v3 1/3] btrfs: add "rescue=usebackuproot" into forced read-only options
  2026-07-03  9:46 [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option Qu Wenruo
@ 2026-07-03  9:46 ` Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 2/3] btrfs: add "rescue=usebackuproot" into "rescue=all" shortcut Qu Wenruo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Qu Wenruo @ 2026-07-03  9:46 UTC (permalink / raw)
  To: linux-btrfs

According to btrfs(5) man page, all rescue options should require a
read-only mount.

But that read-only check is only introduced for newer rescue options,
not for the pre-existing "usebackuproot" one.

Furthermore, a filesystem that requires "rescue=" mount option already
means it's corrupted, even if "rescue=usebackuproot" allowed the fs to
be mounted RW, one should not trust such fs anymore until a
comprehensive btrfs-check run and proper evaluation.

Change the behavior to match the document, and since
"rescue=usebackuproot" is now a full RO mount option, it is no longer a
one-shot option, therefore remove it from btrfs_clear_oneshot_options().

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/fs.h    | 3 ++-
 fs/btrfs/super.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index ab5ed7b4f639..cffb9197a1ab 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -289,7 +289,8 @@ enum {
 	 BTRFS_MOUNT_IGNOREBADROOTS |		\
 	 BTRFS_MOUNT_IGNOREDATACSUMS |		\
 	 BTRFS_MOUNT_IGNOREMETACSUMS |		\
-	 BTRFS_MOUNT_IGNORESUPERFLAGS)
+	 BTRFS_MOUNT_IGNORESUPERFLAGS |		\
+	 BTRFS_MOUNT_USEBACKUPROOT)
 
 /*
  * Compat flags that we support.  If any incompat flags are set other than the
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 0a6ce6c19d8c..e561c8811d6d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -668,7 +668,6 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
  */
 static void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
 {
-	btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT);
 	btrfs_clear_opt(fs_info->mount_opt, CLEAR_CACHE);
 	btrfs_clear_opt(fs_info->mount_opt, NOSPACECACHE);
 }
@@ -692,7 +691,8 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
 	bool ret = true;
 
 	if (!(flags & SB_RDONLY) &&
-	    (check_ro_option(info, *mount_opt, BTRFS_MOUNT_NOLOGREPLAY, "nologreplay") ||
+	    (check_ro_option(info, *mount_opt, BTRFS_MOUNT_USEBACKUPROOT, "usebackuproot") ||
+	     check_ro_option(info, *mount_opt, BTRFS_MOUNT_NOLOGREPLAY, "nologreplay") ||
 	     check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNOREBADROOTS, "ignorebadroots") ||
 	     check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNOREDATACSUMS, "ignoredatacsums") ||
 	     check_ro_option(info, *mount_opt, BTRFS_MOUNT_IGNOREMETACSUMS, "ignoremetacsums") ||
-- 
2.54.0


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

* [PATCH v3 2/3] btrfs: add "rescue=usebackuproot" into "rescue=all" shortcut
  2026-07-03  9:46 [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 1/3] btrfs: add "rescue=usebackuproot" into forced read-only options Qu Wenruo
@ 2026-07-03  9:46 ` Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option Qu Wenruo
  2026-07-03 10:27 ` [PATCH v3 0/3] btrfs: small changes to " Johannes Thumshirn
  3 siblings, 0 replies; 6+ messages in thread
From: Qu Wenruo @ 2026-07-03  9:46 UTC (permalink / raw)
  To: linux-btrfs

The mount option "rescue=all" should be a shortcut to include all
"rescue=" mount options. But unfortunately "rescue=usebackuproot" is not
included.

Include that option so "rescue=all" has a better chance to mount a
corrupted fs.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index e561c8811d6d..e52e80fd9e1f 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -620,6 +620,7 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 			btrfs_set_opt(ctx->mount_opt, IGNORESUPERFLAGS);
 			btrfs_set_opt(ctx->mount_opt, IGNOREBADROOTS);
 			btrfs_set_opt(ctx->mount_opt, NOLOGREPLAY);
+			btrfs_set_opt(ctx->mount_opt, USEBACKUPROOT);
 			break;
 		default:
 			btrfs_info(NULL, "unrecognized rescue option '%s'",
-- 
2.54.0


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

* [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option
  2026-07-03  9:46 [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 1/3] btrfs: add "rescue=usebackuproot" into forced read-only options Qu Wenruo
  2026-07-03  9:46 ` [PATCH v3 2/3] btrfs: add "rescue=usebackuproot" into "rescue=all" shortcut Qu Wenruo
@ 2026-07-03  9:46 ` Qu Wenruo
  2026-07-03 10:27   ` Johannes Thumshirn
  2026-07-03 10:27 ` [PATCH v3 0/3] btrfs: small changes to " Johannes Thumshirn
  3 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2026-07-03  9:46 UTC (permalink / raw)
  To: linux-btrfs

This mount option is marked deprecated since the introduction of
"rescue=" mount option group, in v5.9.

That's already a long time ago, and it should be safe to completely
remove the old "usebackuproot" mount option now.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/super.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index e52e80fd9e1f..a8c55f7571d0 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -128,7 +128,6 @@ enum {
 
 	/* Rescue options */
 	Opt_rescue,
-	Opt_usebackuproot,
 
 	/* Debugging options */
 	Opt_enospc_debug,
@@ -248,8 +247,6 @@ static const struct fs_parameter_spec btrfs_fs_parameters[] = {
 
 	/* Rescue options. */
 	fsparam_enum("rescue", Opt_rescue, btrfs_parameter_rescue),
-	/* Deprecated, with alias rescue=usebackuproot */
-	__fsparam(NULL, "usebackuproot", Opt_usebackuproot, fs_param_deprecated, NULL),
 	/* For compatibility only, alias for "rescue=nologreplay". */
 	fsparam_flag("norecovery", Opt_norecovery),
 
@@ -560,14 +557,6 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		else
 			btrfs_set_opt(ctx->mount_opt, AUTO_DEFRAG);
 		break;
-	case Opt_usebackuproot:
-		btrfs_warn(NULL,
-			   "'usebackuproot' is deprecated, use 'rescue=usebackuproot' instead");
-		btrfs_set_opt(ctx->mount_opt, USEBACKUPROOT);
-
-		/* If we're loading the backup roots we can't trust the space cache. */
-		btrfs_set_opt(ctx->mount_opt, CLEAR_CACHE);
-		break;
 	case Opt_skip_balance:
 		btrfs_set_opt(ctx->mount_opt, SKIP_BALANCE);
 		break;
-- 
2.54.0


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

* Re: [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option
  2026-07-03  9:46 ` [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option Qu Wenruo
@ 2026-07-03 10:27   ` Johannes Thumshirn
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2026-07-03 10:27 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs

On 7/3/26 11:46 AM, Qu Wenruo wrote:
> This mount option is marked deprecated since the introduction of
> "rescue=" mount option group, in v5.9.
>
> That's already a long time ago, and it should be safe to completely
> remove the old "usebackuproot" mount option now.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Note, this has to be removed from the man page as well.

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

* Re: [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option
  2026-07-03  9:46 [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option Qu Wenruo
                   ` (2 preceding siblings ...)
  2026-07-03  9:46 ` [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option Qu Wenruo
@ 2026-07-03 10:27 ` Johannes Thumshirn
  3 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2026-07-03 10:27 UTC (permalink / raw)
  To: Qu Wenruo, linux-btrfs

Looks good,

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>


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

end of thread, other threads:[~2026-07-03 10:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03  9:46 [PATCH v3 0/3] btrfs: small changes to "usebackuproot" mount option Qu Wenruo
2026-07-03  9:46 ` [PATCH v3 1/3] btrfs: add "rescue=usebackuproot" into forced read-only options Qu Wenruo
2026-07-03  9:46 ` [PATCH v3 2/3] btrfs: add "rescue=usebackuproot" into "rescue=all" shortcut Qu Wenruo
2026-07-03  9:46 ` [PATCH v3 3/3] btrfs: remove "usebackuproot" mount option Qu Wenruo
2026-07-03 10:27   ` Johannes Thumshirn
2026-07-03 10:27 ` [PATCH v3 0/3] btrfs: small changes to " Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox