Re: [PATCH] btrfs: remove "rescue=usebackuproot" from "rescue=all" shortcut

From: Hengyu Liang

Date: Wed Nov 25 2026 - 12:18:00 EST


Hi Qu,

I found this while comparing the behaviour of different kernel versions.
I used an LLM to analyse the problem and to draft the patch and this
message, and I analyzed the result myself.

On 2026/11/17 14:53, Qu Wenruo wrote:
> 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.

I agree that slot 1 helps when the newest tree root is damaged. But
"rescue=all" is also what people use to copy data off after an unclean
shutdown, and there slot 1 can be worse than the newest roots:

1. The data extents freed by the last committed transaction can already
hold data of the transaction that did not commit, while slot 1 still
points to them, and ignoredatacsums reads them without an error. In
my test, user A deleted 30 of 60 files in the last transaction, then
user B wrote and fsynced 60 private (0600) files before a power cut
(I used a copy of the disk taken at that point). With
"ro,rescue=all", A's deleted files are back, and 30 of A's files,
owned by A, contain B's data. Copying the data off with the owners
kept hands B's data to A. With the newest roots (v7.3, or
"rescue=all,rescue=usebackuproot_0" now), A sees only the 30 current
files with A's own data.

2. On the same disk, "ro,rescue=usebackuproot" fails with "chunk ...
has missing dev extent" (-EUCLEAN), while the newest roots mount
without errors. I also have a syzkaller image that mounts with
ignorebadroots and usebackuproot (plus some unrelated options) on
the parent of c73eb6f72741 and fails with -EIO on that commit: slot 1
has a bad checksum, the newest roots load. So slot 1 does not always
give a better chance to mount.

I have two suggestions, but in the end it is your call:

a) "rescue=all" tries the newest roots first and falls back to slot 1
only when the mount fails with them (similar to the retry Boris
suggested in his review of your series).

b) Keep slot 1 for "rescue=all", and document in btrfs-progs that an
older slot can point to reused data blocks, which ignoredatacsums
then reads without errors.

Thanks,
Hengyu