summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-12-07switch inodes to rhashtableinode_workKent Overstreet
2020-12-07rhashtable: Drop assertions about obj_hashfnKent Overstreet
No idea why these existed Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07fs: Delete duplicated code in fs/inode.cKent Overstreet
There are many functions related to the inode hash table which have had more general versions added that duplicate the code in earlier simpler versions. - iget_locked() -> iget5_locked() - ilookup() -> ilookup5 - insert_inode_locked() -> insert_inode_locked4() - find_inode_by_ino_rcu() -> find_inode_rcu() Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07fs: kill I_CREATINGKent Overstreet
I_CREATING has only two uses - it determines whether inode_insert5 adds the inode to the superblock list, and this behaviour is different from every other function that adds inodes to the inode hash table - and it causes find_inode() to return -ESTALE, which seems to _never_ be what we want; if an inode in the hash table is not yet initialized callers want to wait for it to be initialized with wait_on_inode. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07fs: move inode init from new_inode_pseudo to inode_init_alwaysKent Overstreet
- there's no reason to be taking i_lock to set i_state here, the inode isn't visible to anything else yet - we need i_sb_list to be always initialized for the next patch that kills I_CREATING. And, while we're at it, delete new_inode_pseudo then rename alloc_inode to new_inode_pseudo. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07fs: kill find_inode_nowait()Kent Overstreet
There's no good reason to be exporting an interface with such razor sharp edges. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07f2fs: don't use find_inode_nowait()Kent Overstreet
This code should probably be using page->mapping instead of looking up the inode in the inode hash table, but there's no good reason for it ot be using such a special purpose interface - which is going to be deleted anyways. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Use get_random_bytes_arch() for hash seedKent Overstreet
These random bytes aren't used for keying, just seeds for hash tables, and the RNG used by get_random_bytes() unfortunately isn't percpu so on certain workloads we see a fair amount of lock contention. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix rand_delete() testbcachefs-v5.9Kent Overstreet
When we didn't find a key to delete we were getting a null ptr deref. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Try to print full btree error messageKent Overstreet
Metadata corruption bugs are hard to debug if we can't see exactly what went wrong - try to allocate a bigger buffer so we can print out everything we have. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Prevent journal reclaim from spinningKent Overstreet
Without checking if we actually flushed anything, journal reclaim could still go into an infinite loop while trying ot shut down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix btree key cache dirty checksKent Overstreet
Had a type that meant we were triggering journal reclaim _much_ more aggressively than needed. Also, fix a potential integer overflow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Be more conservation about journal pre-reservationsKent Overstreet
- Try to always keep 1/8th of the journal free, on top of pre-reservations - Move the check for whether the journal is stuck to bch2_journal_space_available, and make it only fire when there aren't any journal writes in flight (that might free up space by updating last_seq) Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Don't require flush/fua on every journal writeKent Overstreet
This patch adds a flag to journal entries which, if set, indicates that they weren't done as flush/fua writes. - non flush/fua journal writes don't update last_seq (i.e. they don't free up space in the journal), thus the journal free space calculations now check whether nonflush journal writes are currently allowed (i.e. are we low on free space, or would doing a flush write free up a lot of space in the journal) - write_delay_ms, the user configurable option for when open journal entries are automatically written, is now interpreted as the max delay between flush journal writes (default 1 second). - bch2_journal_flush_seq_async is changed to ensure a flush write >= the requested sequence number has happened - journal read/replay must now ignore, and blacklist, any journal entries newer than the most recent flush entry in the journal. Also, the way the read_entire_journal option is handled has been improved; struct journal_replay now has an entry, 'ignore', for entries that were read but should not be used. - assorted refactoring and improvements related to journal read in journal_io.c and recovery.c Previously, we'd have to issue a flush/fua write every time we accumulated a full journal entry - typically the bucket size. Now we need to issue them much less frequently: when an fsync is requested, or it's been more than write_delay_ms since the last flush, or when we need to free up space in the journal. This is a significant performance improvement on many write heavy workloads. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Improve journal free space calculationsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Increase journal pipeliningKent Overstreet
This patch increases the maximum journal buffers in flight from 2 to 4 - this will be particularly helpful when in the future we stop requiring flush+fua for every journal write. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Don't issue btree writes that weren't journalledKent Overstreet
If we have an error in the btree interior update path that prevents us from journalling the update, we can't issue the corresponding btree node write - we didn't get a journal sequence number that would cause it to be ignored in recovery. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Check for errors in bch2_journal_reclaim()Kent Overstreet
If the journal is halted, journal reclaim won't necessarily be able to make any forward progress, and won't accomplish anything anyways - we should bail out so that we don't get stuck looping in reclaim when the caches are too dirty and we should be shutting down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Flag inodes that had btree update errorsKent Overstreet
On write error, the vfs inode's i_size may be inconsistent with the btree inode's i_size - flag this so we don't have spurious assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Avoid write lock on mark_lockKent Overstreet
mark_lock is a frequently taken lock, and there's also potential for deadlocks since currently bch2_clear_page_bits which is called from memory reclaim has to take it to drop disk reservations. The disk reservation get path takes it when it recalculates the number of sectors known to be available, but it's not really needed for consistency. We just want to make sure we only have one thread updating the sectors_available count, which we can do with a dedicated mutex. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Improve some IO error messagesKent Overstreet
it's useful to know whether an error was for a read or a write - this also standardizes error messages a bit more. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Refactor filesystem usage accountingKent Overstreet
Various filesystem usage counters are kept in percpu counters, with one set per in flight journal buffer. Right now all the code that deals with it assumes that there's only two buffers/sets of counters, but the number of journal bufs is getting increased to 4 in the next patch - so refactor that code to not assume a constant. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix spurious alloc errors on forced shutdownKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix some spurious gcc warningsKent Overstreet
These only come up when building in userspace, for some reason. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix journal_flush_seq()Kent Overstreet
The error check was inverted - leading fsyncs to get stuck and hang, oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: bch2_trans_get_iter() no longer returns errorsKent Overstreet
Since we now always preallocate the maximum number of iterators when we initialize a btree transaction, getting an iterator never fails - we can delete a fair amount of error path code. This patch also simplifies the iterator allocation code a bit. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Add error handling to unit & perf testsKent Overstreet
This way, these tests can be used with tests that inject IO errors and shut down the filesystem. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Journal pin refactoringKent Overstreet
This deletes some duplicated code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix for fsck spuriously finding duplicate extentsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Use BTREE_ITER_PREFETCH in journal+btree iterKent Overstreet
Introducing the journal+btree iter introduced a regression where we stopped using BTREE_ITER_PREFETCH - this is a performance regression on rotating disks. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Ensure we always have a journal pin in interior update pathKent Overstreet
For the new nodes an interior btree update makes reachable, updates to those nodes may be journalled after the btree update starts but before the transactional part - where we make those nodes reachable. Those updates need to be kept in the journal until after the btree update completes, hence we should always get a journal pin at the start of the interior update. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Change a BUG_ON() to a fatal errorKent Overstreet
In the btree key cache code, failing to flush a dirty key is a serious error, but it doesn't need to be a BUG_ON(), we can stop the filesystem instead. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix error in filesystem initializationKent Overstreet
The rhashtable code doesn't like when we destroy an rhashtable that was never initialized Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix journal reclaim spinning in recoveryKent Overstreet
We can't run journal reclaim until we've finished replaying updates to interior btree nodes - the check for this was in the wrong place though, leading to journal reclaim spinning before it was allowed to proceed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix for __readahead_batch getting partial batchKent Overstreet
We were incorrectly ignoring the return value of __readahead_batch, leading to a null ptr deref in __bch2_page_state_create(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Optimize bch2_journal_flush_seq_async()Kent Overstreet
Avoid taking the journal lock if we don't have to. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Delete dead codeKent Overstreet
The interior btree node update path has changed, this is no longer needed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: bch2_btree_delete_range_trans()Kent Overstreet
This helps reduce stack usage by avoiding multiple btree_trans on the stack. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Don't use bkey cache for inode update in fsckKent Overstreet
fsck doesn't know about the btree key cache, and non-cached iterators aren't cache coherent (yet?) Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Fix an rcu splatKent Overstreet
bch2_bucket_alloc() requires rcu_read_lock() to be held. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Move journal reclaim to a kthreadKent Overstreet
This is to make tracing easier. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Throttle updates when btree key cache is too dirtyKent Overstreet
This is needed to ensure we don't deadlock because journal reclaim and thus memory reclaim isn't making forward progress. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Journal reclaim requires memalloc_noreclaim_save()Kent Overstreet
Memory reclaim requires journal reclaim to make forward progress - it's what cleans our caches - thus, while we're in journal reclaim or holding the journal reclaim lock we can't recurse into memory reclaim. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Simplify transaction commit error pathKent Overstreet
The transaction restart path traverses all iterators, we don't need to do it here. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Ensure journal reclaim runs when btree key cache is too dirtyKent Overstreet
Ensuring the key cache isn't too dirty is critical for ensuring that the shrinker can reclaim memory. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Improve btree key cache shrinkerKent Overstreet
The shrinker should start scanning for entries that can be freed oldest to newest - this way, we can avoid scanning a lot of entries that are too new to be freed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: More debug code improvementsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Add a kmem_cache for btree_key_cache objectsKent Overstreet
We allocate a lot of these, and we're seeing sporading OOMs - this will help with tracking those down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Be more precise with journal error reportingKent Overstreet
We were incorrectly detecting a journal deadlock - the journal filling up - when only the journal pin fifo had filled up; if the journal pin fifo is full that just means we need to wait on reclaim. This plumbs through better error reporting so we can better discriminate in the journal_res_get path what's going on. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2020-12-07bcachefs: Add btree cache stats to sysfsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>