Skip to contentSkip to conversation

btrfs-progs: rescue: introduce clear-uuid-tree

PATCH In review Qu Wenruo 2 participants 2 messages Nov 11, 2021 – Nov 15, 2021

Subsystems (2)
lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH v2 1/1 btrfs-progs: rescue: introduce clear-uuid-tree

[BUG]
There is a bug report that a corrupted key type (expected UUID_KEY_SUBVOL, has EXTENT_ITEM) causing newer kernel to reject a mount.

Although the root cause is not determined yet, with roll out of v5.11 kernel to various distros, such problem should be prevented by tree-checker, no matter if it's hardware problem or not.

And older kernel with "-o uuid_rescan" mount option won't help, as uuid_rescan will only delete items with UUID_KEY_SUBVOL/UUID_KEY_RECEIVED_SUBVOL key types, not deleting such corrupted key.

[FIX]
To fix such problem we have to rely on offline tool, thus there we introduce a new rescue tool, clear-uuid-tree, to empty and then remove uuid tree.

Kernel will re-generate the correct uuid tree at next mount.

---
Changelog:
v2:
- Add proper man page entry

---
 Documentation/btrfs-rescue.asciidoc |   7 ++
 Documentation/btrfs-rescue.rst      |   9 +++
 cmds/rescue.c                       | 104 ++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+)
Documentation/btrfs-rescue.asciidoc +7 -0
index af5443722b5e..d38797c97fbb 100644
@@ -50,6 +50,13 @@ The mismatch may also exhibit as a kernel warning:
 WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]
 ----
 
+*clear-uuid-tree* <device>::
+Clear uuid tree, so that kernel can re-generate it at next read-write mount.
++
+Since kernel v4.16, btrfs has more and more sanity check, and sometimes
+non-critical trees like uuid tree can cause problem and reject the mount.
+In such case, clearing uuid tree may make the filesystem to be mountable again.
+
 *super-recover* [options] <device>::
 Recover bad superblocks from good copies.
 +
Documentation/btrfs-rescue.rst +9 -0
index f3e73f199dd8..787136aab51a 100644
@@ -50,6 +50,15 @@ fix-device-size <device>
 
                 WARNING: CPU: 3 PID: 439 at fs/btrfs/ctree.h:1559 btrfs_update_device+0x1c5/0x1d0 [btrfs]
 
+clear-uuid-tree <device>
+        Clear uuid tree, so that kernel can re-generate it at next read-write
+        mount.
+
+        Since kernel v4.16, btrfs has more and more sanity check, and sometimes
+        non-critical trees like uuid tree can cause problem and reject the mount.
+        In such case, clearing uuid tree may make the filesystem to be mountable
+        again.
+
 super-recover [options] <device>
         Recover bad superblocks from good copies.
 
cmds/rescue.c +104 -0

116 lines not on this page · raw message

Signature · 1 line
2.33.1
#1 lore raw
Quoted 19 lines · Qu Wenruo

[BUG]
There is a bug report that a corrupted key type (expected UUID_KEY_SUBVOL, has EXTENT_ITEM) causing newer kernel to reject a mount.

Although the root cause is not determined yet, with roll out of v5.11 kernel to various distros, such problem should be prevented by tree-checker, no matter if it's hardware problem or not.

And older kernel with "-o uuid_rescan" mount option won't help, as uuid_rescan will only delete items with UUID_KEY_SUBVOL/UUID_KEY_RECEIVED_SUBVOL key types, not deleting such corrupted key.

[FIX]
To fix such problem we have to rely on offline tool, thus there we introduce a new rescue tool, clear-uuid-tree, to empty and then remove uuid tree.

Quoted 4 lines

Kernel will re-generate the correct uuid tree at next mount.

Added to devel, thanks. I'm not happy that we have to add such fixups but it's still better than not allowing the mount when the workaround is simple and safe.