summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-06-28Initial bcache/bcachefs integrationbcache2Kent Overstreet
2020-06-28bcache: Header refactoringKent Overstreet
For the bcache + bcachefs layer, we're going to need to reorganize the headers so we can have code that interfaces to bcachefs and parts of bcache.
2020-06-28bcache: make writeback_keys a ptrKent Overstreet
This is so the bcache2 code can use struct cached_dev without having to pull in the bcache1 struct bkey.
2020-06-28bcache: move bch_ratelimit to include/linuxKent Overstreet
2020-06-28bcachefs: Add support for passing through reads to block deviceKent Overstreet
2020-06-28bcachefs: todoKent Overstreet
2020-06-28bcachefs: exports for bcacheKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-28bcachefs: Rename some constants to avoid conflicts with bcacheKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-28fooKent Overstreet
2020-06-28bcachefs: Fix bch2_extent_can_insert() not being calledKent Overstreet
It's supposed to check whether we're splitting a compressed extent and if so get a bigger disk reservation - hence this fixes a "disk usage increased by x without a reservaiton" bug. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-26bcachefs: Fix a null ptr deref in bch2_btree_iter_traverse_one()Kent Overstreet
We use sentinal values that aren't NULL to indicate there's a btree node at a higher level; occasionally, this may result in btree_iter_up_until_good_node() stopping at one of those sentinal values. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-18bcachefs: Track sectors of erasure coded dataKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-18bcachefs: Use btree reserve when appropriateKent Overstreet
Whenever we're doing an update that has pointers, that generally means we need to do the update in order to release open bucket references - so we should be using the btree open bucket reserve. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-17bcachefs: Add a kthread_should_stop() check to allocator threadKent Overstreet
Turns out it's possible during shutdown for the allocator to get stuck spinning on bch2_invalidate_buckets() without hitting any of the other checks. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-17bcachefs: Change bch2_dump_bset() to also print key valuesKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-17bcachefs: Fix a deadlock in the RO pathKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15fixup! bcachefs: Implement a new gc that only recalcs oldest genKent Overstreet
2020-06-15bcachefs: Fix incorrect gfp checkKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Fix lock ordering with new btree cache codeKent Overstreet
The code that checks lock ordering was recently changed to go off of the pos of the btree node, rather than the iterator, but the btree cache code didn't update to handle iterators that point to cached bkeys. Oops Also, update various debug code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: delete a slightly faulty assertionKent Overstreet
state lock isn't held at startup Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Increase size of btree node reserveKent Overstreet
Also tweak the allocator to be more aggressive about keeping it full. The recent changes to make updates to interior nodes transactional (and thus generate updates to the alloc btree) all put more stress on the btree node reserves. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Give bkey_cached_key same attributes as bposKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Use cached iterators for alloc btreeKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Btree key cacheKent Overstreet
This introduces a new kind of btree iterator, cached iterators, which point to keys cached in a hash table. The cache also acts as a write cache - in the update path, we journal the update but defer updating the btree until the cached entry is flushed by journal reclaim. Cache coherency is for now up to the users to handle, which isn't ideal but should be good enough for now. These new iterators will be used for updating inodes and alloc info (the alloc and stripes btrees). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: btree_bkey_cached_commonKent Overstreet
This is prep work for the btree key cache: btree iterators will point to either struct btree, or a new struct bkey_cached. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Implement a new gc that only recalcs oldest genKent Overstreet
Full mark and sweep gc doesn't (yet?) work with the new btree key cache code, but it also blocks updates to interior btree nodes for the duration and isn't really necessary in practice; we aren't currently attempting to repair errors in allocation info at runtime. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-15bcachefs: Turn c->state_lock into an rwsemKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-13fixup! bcachefs: Fix a deadlockKent Overstreet
2020-06-13fixup! fixup! bcachefs: Hacky io-in-flight throttlingKent Overstreet
2020-06-13bcachefs: Add an internal option for reading entire journalKent Overstreet
To be used the debug tool that dumps the contents of the journal. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-13bcachefs: Don't deadlock when btree node reuse changes lock orderingKent Overstreet
Btree node lock ordering is based on the logical key. However, 'struct btree' may be reused for a different btree node under memory pressure. This patch uses the new six lock callback to check if a btree node is no longer the node we wanted to lock before blocking. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-12six locks: Add a callback to six_lock_type()Kent Overstreet
This allows for functionality like mutex_lock_killable(), but in a generic manner: to be used for deadlock avoidance in bcachefs. Also add a function for waking up all waiters on a lock, causing them to recheck if they should bail out. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-12bcachefs: Fix a deadlockKent Overstreet
__bch2_btree_node_lock() was incorrectly using iter->pos as a proxy for btree node lock ordering, this caused an off by one error that was triggered by bch2_btree_node_get_sibling() getting the previous node. This refactors the code to compare against btree node keys directly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-12fixup! bcachefs: Hacky io-in-flight throttlingKent Overstreet
2020-06-09bcachefs: Hacky io-in-flight throttlingKent Overstreet
We've been seeing btree updates get stuck, due to some sort of bug; when this happens, buffered writeback will keep queueing up writes that lead to the system running out of memory. Not sure if this kind of throttling is something we'll want to keep and improve, or get rid of when the bug with btree updates getting stuck is fixed. For now it should make debugging easier. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Refactor btree insert pathKent Overstreet
This splits out the journalling code from the btree update code; prep work for the btree key cache. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Always give out journal pre-res if we already have oneKent Overstreet
This is better than skipping the journal pre-reservation if we already have one - we should still acount for the journal reservation we're going to have to get. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: More open bucketsKent Overstreet
We need a larger open bucket reserve now that the btree interior update path holds onto open bucket references; filesystems with many high through devices may need more open buckets now. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Don't allocate memory under the btree cache lockKent Overstreet
The btree cache lock is needed for reclaiming from the btree node cache, and memory allocation can potentially spin and sleep (for 100 ms at a time), so.. don't do that. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Fix a linked list bugKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Make open bucket reserves more conservativeKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: btree_update_nodes_written() requires alloc reserveKent Overstreet
Also, in the btree_update_start() path, if we already have a journal pre-reservation we don't want to take another - that's a deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Check gfp_flags correctly in bch2_btree_cache_scan()Kent Overstreet
bch2_btree_node_mem_alloc() uses memalloc_nofs_save()/GFP_NOFS, but GFP_NOFS does include __GFP_IO - oops. We used to use GFP_NOIO, but as we're a filesystem now GFP_NOFS makes more sense now and is looser. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Call bch2_btree_iter_traverse() if necessary in commit pathKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: bch2_trans_downgrade()Kent Overstreet
bch2_btree_iter_downgrade() was looping over all iterators in a transaction; bch2_trans_downgrade() should be doing that. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Improve warning for copygc failing to move dataKent Overstreet
This will help narrow down which code is at fault when this happens. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Always increment bucket gen on bucket reuseKent Overstreet
Not doing so confuses copygc Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Kill old allocator startup codeKent Overstreet
It's not needed anymore since we can now write to buckets before updating the alloc btree. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Improve assorted error messagesKent Overstreet
This also consolidates the various checks in bch2_mark_pointer() and bch2_trans_mark_pointer(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-06-09bcachefs: Fix a deadlock in bch2_btree_node_get_sibling()Kent Overstreet
There was a bad interaction with bch2_btree_iter_set_pos_same_leaf(), which can leave a btree node locked that is just outside iter->pos, breaking the lock ordering checks in __bch2_btree_node_lock(). Ideally we should get rid of this corner case, but for now fix it locally with verbose comments. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>