Kent Overstreet
ff929515cc
bcachefs: Trust btree alloc info at runtime
...
This lets us avoid a cache miss in the write path.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:30 -04:00
Kent Overstreet
05240ba6b8
bcachefs: Fix creation of lost+found
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:29 -04:00
Kent Overstreet
a40d97a771
bcachefs: Fix incorrect use of bch2_extent_atomic_end()
...
bch2_extent_atomic_end counts the number of iterators requried for
marking overwrites - but journal replay never marks overwrites, so that
part was incorrect. And counting iterators for the key being inserted
should be unnecessary because we did that prior to the key being
inserted before it was first journalled.
This should fix an iterator overflow bug - the iterators for walking
overwrites were totally unneeded.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:28 -04:00
Kent Overstreet
137b0ed907
bcachefs: bch2_extent_atomic_end() now traverses iter
...
This fixes a bug in io.c bch2_write_index_default() - it was missing the
traverse call, but bch2_extent_atomic_end returns an error now and can
just call it itself.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:28 -04:00
Kent Overstreet
9638574229
bcachefs: Factor out fs-common.c
...
This refactoring makes the code easier to understand by separating the
bcachefs btree transactional code from the linux VFS code - but more
importantly, it's also to share code with the fuse port.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:28 -04:00
Kent Overstreet
a7199432c3
bcachefs: Kill deferred btree updates
...
Will be replaced by cached btree iterators
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:28 -04:00
Kent Overstreet
f9c5519336
bcachefs: Drop trans arg to bch2_extent_atomic_end()
...
Just for consistency
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:26 -04:00
Kent Overstreet
89b0511826
bcachefs: Flush fsck errors when looping in btree gc
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:26 -04:00
Kent Overstreet
ad7e137ebc
bcachefs: Switch reconstruct_alloc to a mount option
...
Right now this is the only way of repairing bucket gens in the future
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:26 -04:00
Kent Overstreet
06f6c3ec0b
bcachefs: Reflink pointers also have to be remarked if split in journal replay
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:26 -04:00
Kent Overstreet
76426098e4
bcachefs: Reflink
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:25 -04:00
Kent Overstreet
3c7f3b7aeb
bcachefs: Refactor bch2_extent_trim_atomic() for reflink
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:25 -04:00
Kent Overstreet
2cbe5cfe27
bcachefs: Rework calling convention for marking overwrites
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:25 -04:00
Kent Overstreet
e222d206f2
bcachefs: Fix ec_stripes_read()
...
Change it to not mark keys that will be overwritten by keys in the
journal - this fixes a bug where we pop an assertion in
bucket_set_stripe() because of a stale pointer - because the stripe that
has the stale pointer has been deleted.
This code could be factored out and used elsewhere, at some point.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:24 -04:00
Kent Overstreet
2ded276b7e
bcachefs: Fix array overrun with unknown btree roots
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:23 -04:00
Kent Overstreet
f707e3d8f4
bcachefs: fix kasan splat
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:23 -04:00
Kent Overstreet
6e738539cd
bcachefs: Improve key marking interface
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:22 -04:00
Kent Overstreet
3838be7841
bcachefs: Don't use a fixed size buffer for fs_usage_deltas
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:22 -04:00
Kent Overstreet
20bceecb31
bcachefs: More work to avoid transaction restarts
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:22 -04:00
Kent Overstreet
619f5bee86
bcachefs: some improvements to startup messages and options
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:21 -04:00
Kent Overstreet
932aa83745
bcachefs: bch2_trans_mark_update()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:21 -04:00
Kent Overstreet
5e82a9a1f4
bcachefs: Write out fs usage consistently
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:21 -04:00
Kent Overstreet
c6dd04f8f5
bcachefs: Mark overwrites from journal replay in initial gc
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
d07343561e
bcachefs: Deduplicate keys in the journal before replay
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
644d180b05
bcachefs: Journal replay refactoring
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
478259b749
bcachefs: delete duplicated code
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
1dd7f9d98d
bcachefs: Rewrite journal_seq_blacklist machinery
...
Now, we store blacklisted journal sequence numbers in the superblock,
not the journal: this helps to greatly simplify the code, and more
importantly it's now implemented in a way that doesn't require all btree
nodes to be visited before starting the journal - instead, we
unconditionally blacklist the next 4 journal sequence numbers after an
unclean shutdown.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
a1d58243f9
bcachefs: add ability to run gc on metadata only
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:20 -04:00
Kent Overstreet
7b512638e0
bcachefs: Refactor bch2_fs_recovery()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:19 -04:00
Kent Overstreet
0bc166ff56
bcachefs: Track whether filesystem has errors in superblock
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:19 -04:00
Kent Overstreet
03e183cb5d
bcachefs: Verify fs hasn't been modified before going rw
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:18 -04:00
Kent Overstreet
134915f3d3
bcachefs: Go rw lazily
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:18 -04:00
Kent Overstreet
6122ab639c
bcachefs: More debug params for testing of recovery paths
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:18 -04:00
Kent Overstreet
05235e9928
bcachefs: Run gc if failed to read alloc btree
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:18 -04:00
Kent Overstreet
082f0801e0
bcachefs: Fix error handling in bch2_fs_recovery()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:18 -04:00
Kent Overstreet
1633e492ce
bcachefs: improved flush_held_btree_writes()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:16 -04:00
Kent Overstreet
768ac63924
bcachefs: Add a mechanism for blocking the journal
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:16 -04:00
Kent Overstreet
f7e76361c4
bcachefs: no need to run gc when initializing new fs
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
1df42b5715
bcachefs: don't do initial gc if have alloc info feature
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
3577df5f7f
bcachefs: serialize persistent_reserved
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
3e0745e283
bcachefs: initialize fs usage summary in recovery
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
42b72e0ba2
bcachefs: journal_replay_early()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
2c5af169f7
bcachefs: reserve space in journal for fs usage entries
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
94cd106f8d
bcachefs: delete a debug printk
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
61c8d7c8eb
bcachefs: Persist stripe blocks_used
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:15 -04:00
Kent Overstreet
73e6ab9564
bcachefs: Switch replicas to mark_lock
...
Prep work for upcoming disk accounting changes
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:13 -04:00
Kent Overstreet
f0cfb963ec
bcachefs: Track nr_inodes with the key marking machinery
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:12 -04:00
Kent Overstreet
26609b619f
bcachefs: Make bkey types globally unique
...
this lets us get rid of a lot of extra switch statements - in a lot of
places we dispatch on the btree node type, and then the key type, so
this is a nice cleanup across a lot of code.
Also improve the on disk format versioning stuff.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:12 -04:00
Kent Overstreet
dfe9bfb32e
bcachefs: Stripes now properly subject to gc
...
gc now verifies the contents of the stripes radix tree, important for
persistent alloc info
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:12 -04:00
Kent Overstreet
4e65431c85
Revert "bcachefs: start erasure coding after journal replay"
...
This reverts commit 36f389604294dfc953e6f5624ceb683818d32f28.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22 17:08:12 -04:00