* [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
* Re: [PATCH] btrfs: remove "rescue=usebackuproot" from "rescue=all" shortcut
2026-11-17 3:03 [PATCH] btrfs: remove "rescue=usebackuproot" from "rescue=all" shortcut Hengyu Liang
@ 2026-11-17 4:23 ` Qu Wenruo
0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2026-11-17 4:23 UTC (permalink / raw)
To: Hengyu Liang, linux-btrfs
Cc: Qu Wenruo, Boris Burkov, David Sterba, Chris Mason, linux-kernel
在 2026/11/17 13:33, Hengyu Liang 写道:
> [BUG]
Don't use [BUG][CAUSE][FIX] sections for a very simple behavior change.
You should not use this detailed method for such a simple behavior.
> 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".
Furthermore, one can even argue that this behavior gives a higher chance
to mount the fs.
Thus counting this as a bug is very weak argument, thus the whole point
of your patch may not even stand.
>
> 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.
Remove ChatGPT garbage next time.
Or use your human brain cells to determine whether this makes any sense,
and check all the patches from known developers for the styles to
follow, other than blindly accept whatever chatGPT generated.
No one cares how your stupid agent tested the patch.
If you explained the patch well enough, no one need to waste his/her
time on this BS testing steps.
If not explained well, then the testing part is totally BS.
Furthermore, you should not just change this without a doc update.
>
> 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
^ 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®