Skip to content

btrfs: allow more fine control to rescue=usebackuproot

Qu Wenruo linux-btrfs 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 4 repliesIn review
  2. v12 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Fix a missing use_backup_slot update for rescue=all mount option Which can trigger the ASSERT() on use_backup_slot.

- Add proper output for btrfs_show_options()

- Slightly update the commit message of the 2nd patch
To address a false alert from Sashiko, where it thinks it's a bug not to load any backup root for the newest slot.
For the newest slot, it matches the current generation in the super block, thus every root should be the same as the super block, and no need to load the bytenr from backup.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: always use the second newest slot for rescue=usebackuprootfs/btrfs/disk-io.c+42 -601 reply
2/2btrfs: introduce more accurate usebackuproot optionsfs/btrfs/disk-io.c fs/btrfs/fs.h fs/btrfs/super.c+36 -52 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchBoris Burkov
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] btrfs: allow more fine control to rescue=usebackuproot

[CHANGELOG]
v2:
- Fix a missing use_backup_slot update for rescue=all mount option Which can trigger the ASSERT() on use_backup_slot.

- Add proper output for btrfs_show_options()

- Slightly update the commit message of the 2nd patch
To address a false alert from Sashiko, where it thinks it's a bug not to load any backup root for the newest slot.
For the newest slot, it matches the current generation in the super block, thus every root should be the same as the super block, and no need to load the bytenr from backup.

There is a bug report that for a specific corrupted btrfs, the "rescue=usebackuproot" still chose the newest slot (aka, the same tree root as the one in the super block) to mount the fs, and resulted transid mismatch.

Meanwhile the reporter used btrfs-mod-sb to modify the fs to use a specific backup slot, then the fs can pass btrfs-check.

This shows the limit of the current automatic backup root detection, that as long as all tree root nodes can be loaded, btrfs will consider it as a valid backup slot, without trying any other slot.

And end user has no way to tell btrfs to use a specific slot.

This patchest address the problem by:

- Make "rescue=usebackuproot" to always use the second newest slot Which has the highest chance to still get every tree block right without transid error.

- Introduce new "rescue=usebackuproot_*" mount option
Where "*" can be 0/1/2/3.
0 means the newest slot (aka, the one matching the super block generation), 1/2/3 means the second/third/fourth(oldest) newest slot.

Now "rescue=usebackuproot" is just the same as
"rescue=usebackuproot_1".

Although those "rescue=usebackuproot*" mount options still requires full RO.
For proper recovery, we still need to use "btrfs check", and a new option for btrfs-check will be introduced soon to make the backuproot usage simpler for progs.

Qu Wenruo (2):
btrfs: always use the second newest slot for rescue=usebackuproot
btrfs: introduce more accurate usebackuproot options

 fs/btrfs/disk-io.c | 106 ++++++++++++++++++++-------------------------
 fs/btrfs/fs.h      |   1 +
 fs/btrfs/super.c   |  28 +++++++++++-
 3 files changed, 74 insertions(+), 61 deletions(-)
Signature · 1 line
2.55.0