mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove "rescue=usebackuproot" from "rescue=all" shortcut
@ 2026-11-17  3:03 Hengyu Liang
  2026-11-17  4:23 ` Qu Wenruo
  0 siblings, 1 reply; 2+ messages in thread
From: Hengyu Liang @ 2026-11-17  3:03 UTC (permalink / raw)
  To: linux-btrfs
  Cc: Qu Wenruo, Boris Burkov, David Sterba, Chris Mason, linux-kernel

[BUG]
Since commit c73eb6f72741 ("btrfs: always use the second newest slot for
rescue=usebackuproot"), "mount -o ro,rescue=all" mounts the second
newest backup root even when the newest roots are fine. As of now, the
changes of the last transaction are not visible with "rescue=all".

The issue can be reproduced with a healthy filesystem:

    mkfs.btrfs -q -f /dev/vda
    mount /dev/vda /mnt
    echo old > /mnt/A
    echo old > /mnt/C
    sync
    echo new > /mnt/A
    echo new > /mnt/B
    rm /mnt/C
    umount /mnt
    mount -o ro,rescue=all /dev/vda /mnt
    ls /mnt
    cat /mnt/A

Before that commit, the result is "A B" and "new". After that commit,
the result is "A C" and "old".

[CAUSE]
Commit 2fd3f6a2711b ("btrfs: add "rescue=usebackuproot" into
"rescue=all" shortcut") added USEBACKUPROOT to "rescue=all". At that
time the option only fell back to a backup root when the newest roots
failed to load. Now btrfs_parse_param() sets USEBACKUPROOT and
use_backup_slot = 1 for "rescue=all", and init_tree_roots() calls
read_backup_root(fs_info, 1) before it loads the tree root.

[FIX]
"rescue=usebackuproot" now selects a root instead of tolerating an
error, so remove it from "rescue=all". With this change "rescue=all"
never uses a backup root by itself. When the newest roots are damaged,
"rescue=usebackuproot" has to be given in addition.

Fixes: c73eb6f72741 ("btrfs: always use the second newest slot for rescue=usebackuproot")
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
---
This is new in 7.4-rc (v7.3 mounts the newest roots with "rescue=all"),
so it can be judged before the release.

On a copy of a disk taken while the next transaction was running,
"rescue=all" on v7.4-rc2 showed 30 of 60 files with the data of other
files and no read error, as the space freed by the newest transaction
was reused and data checksums are ignored.

If "rescue=all" should keep every rescue option, as btrfs-progs
documents it, using slot 0 for it also shows the newest state, and I
can send that instead.

Tested on btrfs for-next (26eb4d70f96d) with clean mkfs.btrfs images:
healthy, a damaged data block, a damaged extent, csum, fs or tree root
block, and the disk copy above.

 fs/btrfs/super.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b424cc836bd4..d67d678451f6 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -624,8 +624,6 @@ 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);
-			ctx->use_backup_slot = 1;
 			break;
 		default:
 			btrfs_info(NULL, "unrecognized rescue option '%s'",

base-commit: 26eb4d70f96d9bf99e87c2565d6234eb652f9c26
-- 
2.53.0


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

end of thread, other threads:[~2026-11-17  4:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  3:03 [PATCH] btrfs: remove "rescue=usebackuproot" from "rescue=all" shortcut Hengyu Liang
2026-11-17  4:23 ` Qu Wenruo

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

all inboxes | Powered by JetHome®