summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-09-03fixup! lib: add mean and variance module.mean_and_variance_fixupsKent Overstreet
2022-09-02bcachefs: time stats now uses the mean_and_variance module.Daniel Hill
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-09-02lib: add mean and variance module.Daniel Hill
This module provides a fast 64bit implementation of basic statistics functions, including mean, variance and standard deviation in both weighted and unweighted variants, the unweighted variant has a 32bit limitation per sample to prevent overflow when squaring. Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-09-02bcachefs: misc debug crapDaniel Hill
2022-08-18arch um: Increase NixOS compatibilityDaniel Hill
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-08-18bcachefs: time stats now shows standard deviation.Daniel Hill
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-08-18bcachefs: now show lock hold times for btreesDaniel Hill
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-08-17bcachefs: Fix bch2_btree_iter_peek_slot() error pathKent Overstreet
iter->k needs to be consistent with iter->pos - required for bch2_btree_iter_(rewind|advance) to work correctly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Another should_be_locked fixupKent Overstreet
When returning a key from the key cache, in BTREE_ITER_WITH_KEY_CACHE mode, we don't want to set should_be_locked on iter->path; we're not returning a key from that path, so we donn't need to, and also since we traversed the key cache iterator before setting should_be_locked on that path it might be unlocked (if we unlocked, bch2_trans_relock() won't have relocked it). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: bch2_bkey_packed_to_binary_text()Kent Overstreet
For debugging the eytzinger search tree code, and low level bkey packing code, it can be helpful to see things in binary: this patch improves our helpers for doing so. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Don't drop locks unnecessarily in bch2_btree_update_start()Kent Overstreet
This is to fix a livelock in the btree split path described by the previous patch. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Pass btree_trans through allocation pathKent Overstreet
This is prep work for fixing a livelock involving the btree split path. Currently, bch2_btree_update_start() unconditionally drops btree locks before allocating btree nodes, then calls bch2_trans_relock() - which may fail and cause a transaction restart. It appears multiple threads are attempting to split at the same time, and then when we call bch2_trans_relock() another thread is holding an intent lock on the root node, preparing to split, causing us to restart... then it drops locks, allocates, and relocks, but then we're holding the root lock... oops This patch does not fix the bug, but it plumbs btree_trans all the way through the allocator path so that we can use the same transaction context and don't have to drop locks. The next patch will be reworking bch2_btree_update_start. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Add assertions for unexpected transaction restartsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: btree_path_down() optimizationKent Overstreet
We should be calling btree_node_mem_ptr_set() before path_level_init(), since we already touched the key that btree_node_mem_ptr_set() will modify and path_level_init() will be doing the lookup in the child btree node we're recursing to. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Fix spurious "backpointer doesn't match" error in fsckKent Overstreet
New btree nodes dont't have allocation information written until the node has been written, which means there's a race where the backpointer for the old node points to a node that no longer exists. bch2_backpointer_get_node() checks for this, but fsck uses bch2_backpointer_get_key(); this patch updates bch2_backpointer_get_key() to call get_node() on not found to Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-17bcachefs: Always rebuild aux search trees when node boundaries changeKent Overstreet
Topology repair may change btree node min/max keys: when it does so, we need to always rebuild eytzinger search trees because nodes directly depend on those values. This fixes a bug found by the 'kill_btree_node' test, where we'd pop an assertion in bch2_bset_search_linear(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-15bcachefs: Ratelimit backpointer_not_found error messageKent Overstreet
This is a no brainer, and makes the output of some of our tests easier to manage. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-15bcachefs: Add an overflow check in set_bkey_val_u64s()Kent Overstreet
For now this is just a BUG_ON() - we may want to change this to return an error in the future. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-15bcachefs: remove dead whiteout_u64s argument.Olexa Bilaniuk
Signed-off-by: Olexa Bilaniuk <obilaniu@gmail.com>
2022-08-15bcachefs: Debugfs cleanupKent Overstreet
This improves flush_buf() so that it always returns nonzero when we're done reading and ready to return to userspace, and so that it returns the value we want to return to userspace (number of bytes read, if there wasn't an error). In the future we'll be better abstracting this mechanism and pulling it out of bcachefs, and using it to replace seq_file. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-15lib/printbuf: Tabstop improvementsKent Overstreet
- Add a flag, has_indent_or_tabstops, that is set if indent level or tabstops are set. - Tabstops can no longer be set by modifying the tabstop array directly: instead, the new functions are provided: printbuf_tabstop_push() - add a new tabstop, n spaces after previous tabstop printbuf_tabtstop_pop() - remove previous tabstop printbuf_tabstops_reset() - remove all tabstops Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-15fixup! lib/printbuf: prt_str_indented()Kent Overstreet
2022-08-15bcachefs: Fix bch2_fs_check_snapshots()Kent Overstreet
We were iterating starting at BCACHEFS_ROOT_INO, but snapshots start at POS_MIN - meaning this code was never getting run. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Reported-by: Olexa Bilaniuk <obilaniu@gmail.com>
2022-08-14fixup! vsprintf: prt_u64_minwidth(), prt_u64()Kent Overstreet
2022-08-12bcachefs: Increment restart count in bch2_trans_begin()Kent Overstreet
Instead of counting transaction restarts, count when the transaction is restarted: if bch2_trans_begin() was called when the transaction wasn't restarted we need to ensure restart_count is still incremented. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Fix assertion in bch2_btree_key_cache_drop()Kent Overstreet
Turns out this assertion was something we could legitimately hit - add a comment describing what's going on, and handle it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Print last line in debugfs/btree_transaction_statsKent Overstreet
We need to turn the flush_buf() thing into a proper API, to replace seq_file. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Track the maximum btree_paths ever allocated by each transactionKent Overstreet
We need a way to check if the machinery for handling btree_paths with in a transaction is behaving reasonably, as it often has not been - we've had bugs with transaction path overflows caused by duplicate paths and plenty of other things. This patch tracks, per transaction fn, the most btree paths ever allocated by that transaction and makes it available in debugfs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11lib/printbuf: prt_str_indented()Kent Overstreet
This adds a new helper, prt_str_indented(), which handles embedded control characters by calling prt_newline(), prt_tab(), and prt_tab_rjust() as needed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Rename lock_held_stats -> btree_transaction_statsKent Overstreet
Going to be adding more things to this in the next patch. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11fixup! bcachefs: btree_trans_too_many_iters() is now a transaction restartKent Overstreet
2022-08-11bcachefs: Switch bch2_btree_delete_range() to bch2_trans_run()Kent Overstreet
This fixes an assertion about unexpected transaction restarts - bch2_delete_range_trans() handles transaction restarts. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Fix btree_path->uptodate inconsistencyKent Overstreet
This fixes an assertion in bch2_btree_path_peek_slot(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Fix duplicate paths left by bch2_path_put()Kent Overstreet
bch2_path_put() is supposed to drop paths that aren't needed on transaction restart, or to hold locks that we're supposed to keep until transaction commit: but it was failing to free paths in some cases that it should have, leading to transaction path overflows with lots of duplicate paths. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Kill BTREE_ITER_CACHED_(NOFILL|NOCREATE)Kent Overstreet
These were used more prior to getting rid of the in-memory bucket arrays - they don't serve much purpose anymore, and deleting them lets us write better assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Tracepoint improvementsKent Overstreet
Our types are exported to the tracepoint code, so it's not necessary to break things out individually when passing them to tracepoints - we can also call other functions from TP_fast_assign(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: "Snapshot deletion did not run correctly" should be a fsck errKent Overstreet
This was noticed when a test hit this error and didn't fail, because fsck wasn't returning that it fixed errors. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: six_lock_counts() is now in six.cKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11fixup! locking: SIX locks (shared/intent/exclusive)Kent Overstreet
2022-08-11bcachefs: BTREE_ITER_NO_NODE -> BCH_ERR codesKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-11bcachefs: Don't set should_be_locked on paths that aren't lockedKent Overstreet
It doesn't make any sense to set should_be_locked on btree_paths that aren't locked, and is often a bug - this patch adds assertions and fixes some of those bugs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-09bcachefs: Fix missing error handling in bch2_subvolume_delete()Kent Overstreet
This fixes an assertion when the transaction has been unexpectedly restarted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Improve an error messageKent Overstreet
Update an error message to use bch2_err_str(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Tracepoint improvementsKent Overstreet
- use strlcpy(), not strncpy() - add tracepoints for btree_path alloc and free - give the tracepoint for key cache upgrade fail a proper name - add a tracepoint for btree_node_upgrade_fail Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Fix incorrectly freeing btree_path in alloc pathKent Overstreet
Clearing path->preserve means the path will be dropping in bch2_trans_begin() - but on transaction restart, we're likely to need that path again. This fixes a livelock in the allocation path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Fix bch2_btree_trans_to_text()Kent Overstreet
bch2_btree_trans_to_text() is used to print btree_transactions owned by other threads; thus, it needs to be particularly careful. This fixes a null ptr deref caused by racing with the owning thread changing path->l[].b. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Add distinct error code for key_cache_upgradeKent Overstreet
This aids in debugging. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Fix not punting to worqueue when promotingKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: fsck: Fix nested transaction handlingKent Overstreet
This uses the new trans->restart count to make sure we always correctly return -BCH_ERR_transaction_restart_nested when we restart a nested transaction - eliminating some other hacks and preparing for new assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-08-07bcachefs: Add an O_DIRECT option (for userspace)Kent Overstreet
Sometimes we see IO errors due to O_DIRECT alignment issues - having an option to use buffered IO will be helpful. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>