Kent Overstreet
eb6863598a
bcachefs: bch2_btree_trans_peek_updates
...
refactoring the BTREE_ITER_WITH_UPDATES code, prep for removing the flag
and making it always-on
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
0c99e17d3b
bcachefs: growable btree_paths
...
XXX: we're allocating memory with btree locks held - bad
We need to plumb through an error path so we can do
allocate_dropping_locks() - but we're merging this now because it fixes
a transaction path overflow caused by indirect extent fragmentation, and
the resize path is rare.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
ff70ad2c8d
bcachefs: Fix interior update path btree_path uses
...
Since the btree_paths array is now about to become growable, we have to
be careful not to refer to paths by pointer across contexts where they
may be reallocated.
This fixes the remaining btree_interior_update() paths - split and
merge.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
2c3b0fc3bd
bcachefs: trans->nr_paths
...
Start to plumb through dynamically growable btree_paths; this patch
replaces most BTREE_ITER_MAX references with trans->nr_paths.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
5cc6daf749
bcachefs: trans->updates will also be resizable
...
the reflink triggers are also bumping up against the maximum number of
paths in a transaction - and generating proportional numbers of updates.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
31403dca5b
bcachefs: optimize __bch2_trans_get(), kill DEBUG_TRANSACTIONS
...
- Some tweaks to greatly reduce locking overhead for the list of btree
transactions, so that it can always be enabled: leave btree_trans
objects on the list when they're on the percpu single item freelist,
and only check for duplicates in the same process when
CONFIG_BCACHEFS_DEBUG is enabled
- don't zero out the full btree_trans() unless we allocated it from
the mempool
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
fea153a845
bcachefs: rcu protect trans->paths
...
Upcoming patches are going to be changing trans->paths to a
reallocatable buffer. We need to guard against use after free when it's
used by other threads; this introduces RCU protection to those paths and
changes them to check for trans->paths == NULL
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
6474b70610
bcachefs: Clean up btree_trans
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
398c98347d
bcachefs: kill btree_path.idx
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
d7e14035a4
bcachefs: get_unlocked_mut_path() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
542e639674
bcachefs: bch2_btree_iter_peek_prev() no longer uses path->idx
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
566eabd36f
bcachefs: bch2_path_get() no longer uses path->idx
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:44 -05:00
Kent Overstreet
b0b6737822
bcachefs: trans_for_each_path_with_node() no longer uses path->idx
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
ccb7b08fbb
bcachefs: trans_for_each_path() no longer uses path->idx
...
path->idx is now a code smell: we should be using path_idx_t, since it's
stable across btree path reallocation.
This is also a bit faster, using the same loop counter vs. fetching
path->idx from each path we iterate over.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
4c5289e632
bcachefs: kill trans_for_each_path_from()
...
dead code
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
311e446a41
bcachefs: bch2_btree_path_to_text() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
1f75ba4e65
bcachefs: struct trans_for_each_path_inorder_iter
...
reducing our usage of path->idx
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
7f9821a7c1
bcachefs: btree_insert_entry -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
07f383c71f
bcachefs: btree_iter -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
788cc25d15
bcachefs: btree_path_alloc() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
96ed47d130
bcachefs: bch2_btree_path_traverse() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
f6363acaa6
bcachefs: bch2_btree_path_make_mut() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
4617d94617
bcachefs: bch2_btree_path_set_pos() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
74e600c19a
bcachefs; bch2_path_put() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
255ebbbf75
bcachefs: bch2_path_get() -> btree_path_idx_t
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
5ce8b92da0
bcachefs: minor bch2_btree_path_set_pos() optimization
...
bpos_eq() is cheaper than bpos_cmp()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
4753bdeb26
bcachefs: Kill GFP_NOFAIL usage in readahead path
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
806ebf2aa0
bcachefs: Convert split_devs() to darray
...
Bit of cleanup & modernization: also moving this code to util.c, it'll
be used by userspace as well.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
0c0ba8e9c5
bcachefs: skip journal more often in key cache reclaim
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
1a2a9f9f53
bcachefs: for_each_keylist_key() declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
0beebd9245
bcachefs: bkey_for_each_ptr() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
0bc64d7e26
bcachefs: kill __bch2_btree_iter_peek_upto_and_restart()
...
dead code
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
4eb3877eae
bcachefs: fsck -> bch2_trans_run()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:43 -05:00
Kent Overstreet
cea07a7b6a
bcachefs: vstruct_for_each() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
41b84fb489
bcachefs: for_each_member_device_rcu() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
9fea2274f7
bcachefs: for_each_member_device() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
80eab7a7c2
bcachefs: for_each_btree_key() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
c47e8bfbb7
bcachefs: kill for_each_btree_key_norestart()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
44ddd8ad1e
bcachefs: kill for_each_btree_key_old_upto()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
3a860b5ad5
bcachefs: for_each_btree_key_upto() -> for_each_btree_key_old_upto()
...
And for_each_btree_key2_upto -> for_each_btree_key_upto
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
c8ef2dc2fc
bcachefs: bch2_dirent_lookup() -> lockrestart_do()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
79904fa2bb
bcachefs: bch2_trans_srcu_lock() should be static
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
6d5c606c1c
bcachefs: use track_event_change() for allocator blocked stats
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
ef23397c30
bcachefs: fix warning about uninitialized time_stats
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
e34ec13a56
bcachefs: add more verbose logging
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
53b67d8dcf
bcachefs: better error message in btree_node_write_work()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
037a2d9f48
bcachefs: simplify bch_devs_list
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
defd9e39b5
bcachefs: darray_for_each() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
559e6c2336
bcachefs: trans_for_each_update() now declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00
Kent Overstreet
cee0a8ea6d
bcachefs: Improve the nopromote tracepoint
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-01-01 11:47:42 -05:00