summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-02-05lockless write bufferbackpointersKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05fixup bcachefs: Btree write bufferKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05simplify backpointers codeKent Overstreet
2023-02-05only use btree for backpointersKent Overstreet
2023-02-05bcachefs: Use btree write buffer for backpointersKent Overstreet
When average write size is small backpointers won't fit in alloc keys and we'll have to spill over to the backpointers btree - which can suffer from lock contention on multithreaded workloads, since unlock the alloc btree it doesn't use the key cache. This switches to using the write buffer for the backpointers btree, which solves the lock contention problems and helps performance even on non multithreaded workloads by aggregating the backpointers btree updates and doing them in sorted order. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Start copygc when first going read-writeKent Overstreet
In the distant past, it wasn't possible to start copygc until after journal replay had finished. Now, the btree iterator code overlays keys from the journal, so there's no reason not to start it earlier - and it solves a rare deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Don't use key cache during fsckKent Overstreet
The btree key cache mainly helps with lock contention, at the cost of additional memory overhead. During some fsck passes the memory overhead really matters, but fsck is single threaded so lock contention is an issue - so skipping the key cache during fsck will help with performance. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Run check_extents_to_backpointers() in multiple passesKent Overstreet
Similer to the previous patch for check_backpointers_to_extents(), if the alloc + backpointers btrees do not fit in ram we need to run into multiple passes. The counting of btree nodes that fit in memory is different here, because we have to walk the alloc and backpointers btrees at the same time, since a backpointer could reside in either of them and we don't know which without checking both. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Run bch2_check_backpointers_to_extents() in multiple passes if ↵Kent Overstreet
necessary When the extents + reflink btrees don't fit into memory this fsck pass becomes _much_ slower, since we're doing random lookups. This patch changes this pass to check how much of the relevant btrees will fit into memory, and run in multiple passes if needed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Don't stop copygc while removing devicesKent Overstreet
With the new backpointer based copygc we don't need an explicit copygc reserve, we're always evacuating buckets one at a time - so this is no longer needed, and in fact removing it fixes a deadlock in bch2_dev_allocator_remove(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Delete in memory ec backpointersKent Overstreet
Post btree backpointers, these aren't needed anymore. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Erasure coding now uses backpointersKent Overstreet
This is only a start to updating erasure coding for backpointers - it's still not working yet. The subsequent patch will delete our old in memory backpointers for copygc, and this fixes a spurious EPERM bug/error message. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Copygc now uses backpointersKent Overstreet
Previously, copygc needed to walk the entire extents & reflink btrees to find extents that needed to be moved. Now that we have backpointers, this patch implements bch2_evacuate_bucket() in the move code, which copygc now uses for evacuating mostly empty buckets. Also, thanks to the new backpointers code, copygc can now move btree nodes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: New on disk format: BackpointersKent Overstreet
This patch adds backpointers: we now have a reverse index from device and offset on that device (specifically, offset within a bucket) back to btree nodes and (non cached) data extents. The first 40 backpointers within a bucket are stored in the alloc key; after that backpointers spill over to the next backpointers btree. This is to help avoid performance regressions from additional btree updates on large streaming workloads. This patch adds all the code for creating, checking and repairing backpointers. The next patch in the series is going to use backpointers for copygc - finally getting rid of the need to scan all extents to do copygc. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Btree write bufferKent Overstreet
This adds a new method of doing btree updates - a straight write buffer, implemented as a flat fixed size array. This is only useful when we don't need to read from the btree in order to do the update, and when reading is infrequent - perfect for the LRU btree. This will make LRU btree updates fast enough that we'll be able to use it for persistently indexing buckets by fragmentation, which will be a massive boost to copygc performance. Changes: - A new btree_insert_type enum, for btree_insert_entries. Specifies btree, btree key cache, or btree write buffer. - bch2_trans_update_buffered(): updates via the btree write buffer don't need a btree path, so we need a new update path. - Transaction commit path changes: The update to the btree write buffer both mutates global, and can fail if there isn't currently room. Therefore we do all write buffer updates in the transaction all at once, and also if it fails we have to revert filesystem usage counter changes. If there isn't room we flush the write buffer in the transaction commit error path and retry. - A new persistent option, for specifying the number of entries in the write buffer. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05journal res assertKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Fix bch2_trans_reset_updates()Kent Overstreet
This should have been resetting trans->fs_usage_deltas as well. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Inline bch2_btree_path_traverse() fastpathKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05six locks: Lock contended tracepointsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05six locks: Improved optimistic spinningKent Overstreet
This adds a threshold for the maximum spin time, similar to the rwsem code, and a flag to the lock itself indicating when we've spun too long so other threads also refrain from spinning. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05bcachefs: Use six_lock_ip()Kent Overstreet
This uses the new _ip() interface to six locks and hooks it up to btree_path->ip_allocated, when available. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05six locks: Expose tracepoint IPKent Overstreet
This adds _ip variations of the various lock functions that allow an IP to be passed in, which is used by lockstat. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-05fixup! bcachefs: Convert bch2_do_discards_work() to for_each_btree_key2()Kent Overstreet
2023-02-05fixup! bcachefs: Rename lock_held_stats -> btree_transaction_statsKent Overstreet
2023-02-05fix btree path leakKent Overstreet
2023-02-05bcachefs: Fix bch2_trans_update_max_paths()Kent Overstreet
We have to call it before marking the new path as allocated, since otherwise we'll be calling path_to_text() on a path that isn't yet initialized. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_inode_opts_get()Kent Overstreet
This improves io_opts() and makes it a non-inline function - it's big enough that it probably shouldn't be. Also, bch_io_opts no longer needs fields for whether options are defined, so we can slim it down a bit. We'd like to stop passing around the full bch_io_opts, but that'll be tricky because of bch2_rebalance_add_key(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix bch_alloc_to_text()Kent Overstreet
We weren't guarding against the alloc key having an invalid data type. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Better inlining in core write pathKent Overstreet
Provide inline versions of some allocation functions - bch2_alloc_sectors_done_inlined() - bch2_alloc_sectors_append_ptrs_inlined() and use them in the core IO path. Also, inline bch2_extent_update_i_size_sectors() and bch2_bkey_append_ptr(). In the core write path, function call overhead matters - every function call is a jump to a new location and a potential cache miss. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Better inlining for bch2_alloc_to_v4_mutKent Overstreet
This separates out the slowpath into a separate function, and inlines bch2_alloc_v4_mut into bch2_trans_start_alloc_update(), the main place it's called. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve btree_reserve_get_fail tracepointKent Overstreet
Now we include the return code. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix bch2_bucket_alloc_early()Kent Overstreet
We were incorrectly retrying after a transaction restart. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Check for lru entries with time=0Kent Overstreet
These are invalid. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix rereplicate when we already have a cached pointerKent Overstreet
When we need to add more replicas to an extent, it might be the case that we already have a replica on every device, but some of them are cached. This patch fixes a bug where we'd spin on that extent because the write path fails to find a device we can allocate from: we allow allocating from devices that already have cached replicas on them, and change bch2_data_update_index_update() to drop the cached replica if needed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix repair path in bch2_mark_reflink_p()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Dump transaction updates before panicingKent Overstreet
When errors=panic, we need to dump transaction updates before calling bch2_inconsistent_error(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Kill fs_usage_apply_warn()Kent Overstreet
We now have bch2_trans_inconsistent() which generically does the same thing - dumps pending btree transaction updates. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: debug: Fix some locking bugsKent Overstreet
This fixes a few error paths in debug code that lead to locks failing to be dropped. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Convert EAGAIN errors to private error codesKent Overstreet
More error code cleanup, for better error messages and debugability. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Convert EROFS errors to private error codesKent Overstreet
More error code improvements - this gets us more useful error messages. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix compat path for old inode formatsKent Overstreet
Old inode formats don't have all the fields of the current inode format: when unpacking inodes in the current format we can thus skip zeroing out the destination buffer, but that doesn't work on for the old formats. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: bch2_trans_relock_notrace()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: btree_iter->ip_allocatedKent Overstreet
In debug mode, we now track where btree iterators and paths are initialized/allocated - helpful in tracking down btree path overflows. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: key cache: Don't hold btree locks while using GFP_RECLAIMKent Overstreet
This is something we need to do more widely: instead of bothering with GFP_NOIO/GFP_NOFS, if we need to allocate memory while holding locks: - first attempt the allocation with GFP_NOWAIT - if that fails, drop btree locks with bch2_trans_unlock(), then retry with GFP_KERNEL. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Improve bkey_cached_lock_for_evict()Kent Overstreet
We don't need a write lock to check if a key is dirty. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Fix bch2_btree_path_traverse_all()Kent Overstreet
We need to take a ref on a path while we're traversing it: this fixes a bug with paths getting reused while being traversed, in the key cache fill code. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Delete a faulty assertionKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Kill bch2_extent_trim_atomic() usageKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Plumb saw_error through to btree_err()Kent Overstreet
The btree node read path has the ability to kick off an asynchronous btree node rewrite if we saw and corrected an error. Previously this was only used for errors that caused one of the replicas to be unusable - this patch plumbs it through to all error paths, so that normal fsck errors can be corrected. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-02-03bcachefs: Convert btree_err() to a functionKent Overstreet
This makes the code more readable, and reduces text size by 8 kb. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>