[GIT PULL] bcachefs repair code for rc3

From: Kent Overstreet
Date: Wed Apr 03 2024 - 15:23:14 EST


Hi Linus, another bcachefs pull for you - this one is the new repair
code.

Cheers,
Kent

The following changes since commit b3c7fd35c03c17a950737fb56a06b730a7962d28:

bcachefs: On emergency shutdown, print out current journal sequence number (2024-04-01 01:07:24 -0400)

are available in the Git repository at:

https://evilpiepirate.org/git/bcachefs.git tags/bcachefs-2024-04-03

for you to fetch changes up to 09d4c2acbf4c864fef0f520bbcba256c9a19102e:

bcachefs: reconstruct_inode() (2024-04-03 14:46:51 -0400)

----------------------------------------------------------------
bcachefs repair code for 6.9-rc3

A couple more small fixes, and new repair code.

We can now automatically recover from arbitrary corrupted interior btree
nodes by scanning, and we can reconstruct metadata as needed to bring a
filesystem back into a working, consistent, read-write state and
preserve access to whatevver wasn't corrupted.

Meaning - you can blow away all metadata except for extents and dirents
leaf nodes, and repair will reconstruct everything else and give you
your data, and under the correct paths. If inodes are missing i_size
will be slightly off and permissions/ownership/timestamps will be gone,
and we do still need the snapshots btree if snapshots were in use - in
the future we'll be able to guess the snapshot tree structure in some
situations.

IOW - aside from shaking out remaining bugs (fuzz testing is still
coming), repair code should be complete and if repair ever doesn't work
that's the highest priority bug that I want to know about immediately.

This patchset was kindly tested by a user from India who accidentally
wiped one drive out of a three drive filesystem with no replication on
the family computer - it took a couple weeks but we got everything
important back.

----------------------------------------------------------------
Guenter Roeck (1):
mean_and_variance: Drop always failing tests

Kent Overstreet (18):
bcachefs: Fix btree node reserve
bcachefs: BCH_WATERMARK_interior_updates
bcachefs: fix nocow lock deadlock
bcachefs: Improve bch2_btree_update_to_text()
bcachefs: Check for bad needs_discard before doing discard
bcachefs: ratelimit informational fsck errors
bcachefs: Clear recovery_passes_required as they complete without errors
bcachefs: bch2_shoot_down_journal_keys()
bcachefs: Etyzinger cleanups
bcachefs: bch2_btree_root_alloc() -> bch2_btree_root_alloc_fake()
bcachefs: Don't skip fake btree roots in fsck
bcachefs: Repair pass for scanning for btree nodes
bcachefs: Topology repair now uses nodes found by scanning to fill holes
bcachefs: Flag btrees with missing data
bcachefs: Reconstruct missing snapshot nodes
bcachefs: Check for extents that point to same space
bcachefs: Subvolume reconstruction
bcachefs: reconstruct_inode()

fs/bcachefs/Makefile | 2 +
fs/bcachefs/alloc_background.c | 47 ++--
fs/bcachefs/alloc_foreground.c | 4 +-
fs/bcachefs/alloc_types.h | 3 +-
fs/bcachefs/backpointers.c | 173 +++++++++++-
fs/bcachefs/bcachefs.h | 5 +
fs/bcachefs/bcachefs_format.h | 1 +
fs/bcachefs/btree_gc.c | 306 ++++++++++++++--------
fs/bcachefs/btree_io.c | 15 +-
fs/bcachefs/btree_journal_iter.c | 19 ++
fs/bcachefs/btree_journal_iter.h | 4 +
fs/bcachefs/btree_node_scan.c | 495 +++++++++++++++++++++++++++++++++++
fs/bcachefs/btree_node_scan.h | 11 +
fs/bcachefs/btree_node_scan_types.h | 30 +++
fs/bcachefs/btree_trans_commit.c | 3 +-
fs/bcachefs/btree_update_interior.c | 57 ++--
fs/bcachefs/btree_update_interior.h | 26 +-
fs/bcachefs/buckets.h | 1 +
fs/bcachefs/data_update.c | 3 +-
fs/bcachefs/extents.c | 52 ++--
fs/bcachefs/extents.h | 1 +
fs/bcachefs/eytzinger.c | 234 +++++++++++++++++
fs/bcachefs/eytzinger.h | 63 +++--
fs/bcachefs/fsck.c | 227 ++++++++++++++--
fs/bcachefs/journal_seq_blacklist.c | 3 +-
fs/bcachefs/mean_and_variance_test.c | 28 +-
fs/bcachefs/opts.h | 4 +-
fs/bcachefs/recovery.c | 108 +++++---
fs/bcachefs/recovery.h | 2 +
fs/bcachefs/recovery_passes.c | 42 ++-
fs/bcachefs/recovery_passes_types.h | 2 +
fs/bcachefs/replicas.c | 19 +-
fs/bcachefs/sb-errors_types.h | 5 +-
fs/bcachefs/snapshot.c | 173 +++++++++++-
fs/bcachefs/snapshot.h | 26 +-
fs/bcachefs/super-io.c | 9 +-
fs/bcachefs/super.c | 3 +
fs/bcachefs/util.c | 143 ----------
fs/bcachefs/util.h | 14 +-
39 files changed, 1869 insertions(+), 494 deletions(-)
create mode 100644 fs/bcachefs/btree_node_scan.c
create mode 100644 fs/bcachefs/btree_node_scan.h
create mode 100644 fs/bcachefs/btree_node_scan_types.h
create mode 100644 fs/bcachefs/eytzinger.c