summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-02-03bcachefs: Quota fixesKent Overstreet
- We now correctly allow soft limits to be exceeded, instead of always returning -EDQUOT - Disk quota grate times/warnings can now be set, not just the systemwide defaults Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Switch to local_clock() for fastpath time sourceKent Overstreet
local_clock() isn't always completely accurate - e.g. on machines with TSC drift - but ktime_get_ns() overhead is too high, unfortunately. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Btree key cache improvementsKent Overstreet
- In userspace, we don't have real percpu variables; this patch disables the percpu freelists in userspace - add some error messages for the asserts in bch2_fs_btree_key_cache_exit(); we've been hitting this (only in userspace, oddly), perhaps this will help us track down the error. - bkey_cached_reuse() should likely be taking the key cache lock, and it's a slowpath so it doesn't hurt to Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix btree node prefetchigKent Overstreet
We were forgetting to count down the number of nodes to prefetch, firing off _way_ more than intended - whoops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_btree_key_cache_scan() doesn't need trylockKent Overstreet
We don't actually allocate memory under the btree key cache lock - so there's no recursion concerns, and the shrinker can just use mutex_lock(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Defer full journal entry validationKent Overstreet
On journal read, previously we would do full journal entry validation immediately after reading a journal entry. However, this would lead to errors for journal entries we weren't actually going to use, either because they were too old or too new (newer than the most recent flush). We've observed write tearing on journal entries newer than the newest flush - which makes sense, prior to a flush there's no guarantees about write persistence. This patch defers full journal entry validation until the end of the journal read path, when we know which journal entries we'll want to use. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve journal_entry_add()Kent Overstreet
Prep work for the next patch, to defer journal entry validation: we now track for each replica whether we had a good checksum. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix for not dropping privs in fallocateKent Overstreet
When modifying a file, we may be required to drop the suid/sgid bits - we were missing a file_modified() call to do this. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix bch2_write_begin()Kent Overstreet
An error case was jumping to the wrong label, creating an infinite loop - oops. This fixes fstests generic/648. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03fixup bcachefs: Deadlock cycle detectorKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix lock_graph_remove_non_waiters()Kent Overstreet
We were removing 1 more entry than we were supposed to - oops. Also some other simplifications and cleanups, and bring back the abort preference code in a better fashion. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Support FS_XFLAG_PROJINHERITKent Overstreet
We already have support for the flag's semantics: inode options are inherited by children if they were explicitly set on the parent. This patch just maps the FS_XFLAG_PROJINHERIT flag to the "this option was epxlicitly set" bit. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Don't allow hardlinks when inherited attrs would changeKent Overstreet
This is the right thing to do, and conforms with our own behaviour on rename and xfs's behaviour on hardlink. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Initialize sb_quota with default 1 week timerKent Overstreet
For compliance with other quota implementations, we should be initializing quota information with a default 1 week timelimit: this fixes fstests generic/235. Also, this adds to_text() functions for some quota structs - useful debugging aids. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Call bch2_btree_update_add_new_node() before dropping write lockKent Overstreet
btree nodes can be written by other threads (shrinker, journal reclaim) with only a read lock, but brand new nodes should only be written by the thread doing the split/interior update. bch2_btree_update_add_new_node() sets btree node flags to indicate that this is a new node and should not be written out by other threads, thus we need to call it before dropping our write lock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Reflink now respects quotasKent Overstreet
This adds a new helper, quota_reserve_range(), which takes a quota reservation for unallocated blocks in a given file range, and uses it in bch2_remap_file_range(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix a rare path in bch2_btree_path_peek_slot()Kent Overstreet
In the drop_alloc tests, we may end up calling bch2_btree_iter_peek_slot() on an interior level that doesn't exist. Previously, this would hit the path->uptodate assertion in bch2_btree_path_peek_slot(); this path first checks a NULL btree node, which is how we know we're at the end of the btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_path_put_nokeep()Kent Overstreet
The btree iterator code may allocate extra btree paths, temporarily, that do not refer to keys being returned: we don't need to wait until transaction restart to drop these, when they're not referenced they should be deleted right away. This fixes a transaction path overflow bug. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix cached data accountingKent Overstreet
Negating without casting to a signed integer means the value wasn't getting sign extended properly - oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Btree splits now only take the locks they needKent Overstreet
Previously, bch2_btree_update_start() would always take all intent locks, all the way up to the root. We've finally got data from users where this became a scalability issue - so, this patch fixes bch2_btree_update_start() to only take the locks we need. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_btree_iter_peek() now works with interior nodesKent Overstreet
Needed by the next patch, which will be iterating over keys in nodes at level 1. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_btree_insert_node() no longer uses lock_write_nofailKent Overstreet
Now that we have an error path plumbed through, there's no need to be using bch2_btree_node_lock_write_nofail(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Add error path to btree_split()Kent Overstreet
The next patch in the series is (finally!) going to change btree splits (and interior updates in general) to not take intent locks all the way up to the root - instead only locking the nodes they'll need to modify. However, this will be introducing a race since if we're not holding a write lock on a btree node it can be written out by another thread, and then we might not have enough space for a new bset entry. We can handle this by retrying - we just need to introduce a new error path. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Write new btree nodes after parent updateKent Overstreet
In order to avoid locking all btree nodes up to the root for btree node splits, we're going to have to introduce a new error path into bch2_btree_insert_node(); this mean we can't have done any writes or modified global state before that point. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Simplify break_cycle()Kent Overstreet
We'd like to prioritize aborting transactions that have done less work - however, it appears breaking cycles by telling other threads to abort may still be buggy, so disable that for now. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Print cycle on unrecoverable deadlockKent Overstreet
Some lock operations can't fail; a cycle of nofail locks is impossible to recover from. So we want to get rid of these nofail locking operations, but as this is tricky it'll be done incrementally. If such a cycle happens, this patch prints out which codepaths are involved so we know what to work on next. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Handle dropping pointers in data_update pathKent Overstreet
Cached pointers are generally dropped, not moved: this led to an assertion firing in the data update path when there were no new replicas being written. This path adds a data_options field for pointers to be dropped, and tweaks move_extent() to check if we're only dropping pointers, not writing new ones, before kicking off a data update operation. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Ratelimit ec error messageKent Overstreet
We should fix this, but for now this makes this more usable. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Use btree_type_has_ptrs() more consistentlyKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix "multiple types of data in same bucket" with ecKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Ensure fsck error is printed before panicKent Overstreet
When errors=panic, we want to make sure we print the error before calling bch2_inconsistent_error(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix a deadlock in btree_update_nodes_written()Kent Overstreet
btree_node_lock_nopath() is something we'd like to get rid of, it's always prone to deadlocks if we accidentally are holding other locks, because it doesn't mark the lock it's taking in a path: we'll want to get rid of it in the future, but for now this patch works it by calling bch2_trans_unlock(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_trans_locked()Kent Overstreet
Useful debugging function. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve btree_deadlock debugfs outputKent Overstreet
This changes bch2_check_for_deadlock() to print the longest chains it finds - when we have a deadlock because the cycle detector isn't finding something, this will let us see what it's missing. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Don't quash error in bch2_bucket_alloc_set_trans()Kent Overstreet
We were incorrectly returning -BCH_ERR_insufficient_devices when we'd received a different error from bch2_bucket_alloc_trans(), which (erronously) turns into -EROFS further up the call chain. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix a trans path overflow in bch2_btree_delete_range_trans()Kent Overstreet
bch2_btree_delete_range_trans() was using btree_trans_too_many_iters() to avoid path overflow, but this was buggy here (and also btree_trans_too_many_iters() is suspect in general). btree_trans_too_many_iters() only returns true when we're close to the maximum number of paths - within 8 - but extent insert/delete assumes that it can use more paths than that. Instead, we need to call bch2_trans_begin() on every loop iteration. Since we don't want to call bch2_trans_begin() (restarting the outer transaction) if the call was a no-op - if we had no work to do - we have to structure things a bit oddly. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bucket_alloc_stateKent Overstreet
This refactoring puts our various allocation path counters into a dedicated struct - the upcoming nocow patch is going to add another counter. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix bch2_btree_path_up_until_good_node()Kent Overstreet
There was a rare bug when path->locks_want was nonzero, but not BTREE_MAX_DEPTH, where we'd return on a valid node that wasn't locked - oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Factor out bch2_write_drop_io_error_ptrs()Kent Overstreet
Move slowpath code to a separate, non-inline function. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Break out bch2_btree_path_traverse_cached_slowpath()Kent Overstreet
Prep work for further refactoring. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Kill io_in_flight semaphoreKent Overstreet
This used to be needed more for buffered IO, but now the block layer has writeback throttling - we can delete this now. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve bucket_alloc tracepointKent Overstreet
It now includes more info - whether the bucket was for metadata or data - and also call it in the same place as the bucket_alloc_fail tracepoint. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs; Mark __bch2_trans_iter_init as inlineKent Overstreet
This function is fairly small and only used in two places: one very hot, the other cold, so it should definitely be inlined. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Inline fast path of check_pos_snapshot_overwritten()Kent Overstreet
This moves the slowpath of check_pos_snapshot_overwritten() to a separate function, and inlines the fast path - helping performance on btrees that don't use snapshot and for users that aren't using snapshots. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve jset_validate()Kent Overstreet
Previously, jset_validate() was formatting the initial part of an error string for every entry it validating - expensive. This moves that code to journal_entry_err_msg(), which is now only called if there's an actual error. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Optimize btree_path_alloc()Kent Overstreet
- move slowpath code to a separate function, btree_path_overflow() - no need to use hweight64 - copy nr_max_paths from btree_transaction_stats to btree_trans, avoiding a data dependency in the fast path Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Inline bch2_trans_kmalloc() fast pathKent Overstreet
Small performance optimization. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Run bch2_fs_counters_init() earlierKent Overstreet
We need counters to be initialized before initializing shrinkers - the shrinker callbacks will update those counters. This fixes a segfault in userspace. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: btree_err() now uses bch2_print_string_as_lines()Kent Overstreet
We've seen long error messages get truncated here, so convert to the new bch2_print_string_as_lines(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve bch2_fsck_err()Kent Overstreet
- factor out fsck_err_get() - if the "bcachefs (%s):" prefix has already been applied, don't duplicate it - convert to printbufs instead of static char arrays - tidy up control flow a bit - use bch2_print_string_as_lines(), to avoid messages getting truncated Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>