summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
2022-10-03bcachefs: Add a persistent counter for bucket invalidationKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Call bch2_do_invalidates() when going read writeKent Overstreet
Like bch2_do_discards(), we should check if this needs to be done when going rw. Also, add some sysfs code for debugging bucket invalidation. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Improved human readable integer parsingKent Overstreet
Printbufs recently switched to using string_get_size() for printing integers in human readable units. This updates __bch2_strtoh() to parse numbers printed by string_get_size() - we now have to handle floating point numbers, and new unit suffixes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix freespace initializationKent Overstreet
bch2_dev_freespace_init() was using __bch2_trans_do() incorrectly, and calling bch2_bucket_do_index() with a stale alloc key. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: shrinker.to_text() methodsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Convert to lib/printbuf.cKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03d_path: prt_path()Kent Overstreet
This implements a new printbuf version of d_path()/mangle_path(), which will replace the seq_buf version. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix btree node read error pathKent Overstreet
We were forgetting to clear the read_in_flight flag - oops. This also fixes it to not call bch2_fatal_error() before topology repair has had a chance to do its thing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix btree_and_journal_iterKent Overstreet
We had a bug where btree_and_journal_iter would return the same key twice - after deleting it (perhaps because it was present in both the btree and the journal?) This reworks btree_and_journal_iter to track the current position, much like btree_paths, which makes the logic considerably simpler and more robust. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix for cmd_list_journalKent Overstreet
cmd_list_journal wasn't correctly listing the most recent journal entries as blacklisted - because in the recovery path when just reading the journal, we were failing to add those to the blacklist table. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Also log overwrites in journalKent Overstreet
Lately we've been doing a lot of debugging by looking at the journal to see what was changed, and by what code path. This patch adds a new journal entry type for recording overwrites, so that we don't have to search backwards through the journal to see what was being overwritten in order to work out what the triggers were supposed to be doing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Refactor journal entry addingKent Overstreet
This takes copying the payload out of bch2_journal_add_entry(), which means we can use it for journal_transaction_name() - also prep work for journalling overwrites. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Btree key cache coherencyKent Overstreet
This is the last piece for btree key cache coherency: We already have: - btree iterator code checks the key cache when iterating over a cached btree - update path ensures that updates go to the key cache when updating a cached btree But for iterating over a cached btree to work, we need to ensure that if a key exists in the key cache, it also exists in the btree - otherwise the iterator code will skip past it and not check the key cache. This patch implements that last piece: on a key cache update, if creating a new key, we now also update the underlying btree. This fixes a device removal bug, where deleting alloc info wasn't correctly deleting all keys associated with a given device. It also means we should be able to re-enable the key cache for inodes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Add some missing error messagesKent Overstreet
bch2_opt_parse() was failing to generate error messages in error path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix memory corruption in encryption pathKent Overstreet
When do_encrypt() was passed a vmalloc address and the buffer spanned more than a single page, we were encrypting/decrypting completely different pages than the ones intended. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: bch2_trans_reset_updates()Kent Overstreet
Factor out a new helper. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix error checking in bch2_fs_alloc()Kent Overstreet
One of the init calls had a ; instead of a ?:, and errors after that got dropped - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Print message on btree node read retry successKent Overstreet
Right now, we print an error message on btree node read error, and we print that we're retrying, but we don't explicitly say if the retry succeeded - this makes things a little clearer. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: journal_transaction_name is now always onKent Overstreet
We want this option always enabled - it costs practically nothing and it's an essential debugging tool. It's enabled by default, but old filesystems are still out there that need debugging, so let's just force it on and kill the option. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix journal_keys_search() overheadKent Overstreet
Previously, on every btree_iter_peek() operation we were searching the journal keys, doing a full binary search - which was slow. This patch fixes that by saving our position in the journal keys, so that we only do a full binary search when moving our position backwards or a large jump forwards. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Always print when doing journal replay in fsckKent Overstreet
This logging improvement helps see when the previous fsck pass has completed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Rename group to label for remaining strings.Daniel Hill
Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-10-03bcachefs: Fix encryption path on armKent Overstreet
flush_dcache_page() is not a noop on arm, but we were using virt_to_page() instead of vmalloc_to_page() for an address on the kernel stack - vmalloc memory, leading to an oops in flush_dcache_page(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Switch to key_type_user, not logonKent Overstreet
The only difference key_type_logon and key_type_user is that key_type_logon keys can't be read by userspace. However, userspace has actually been adding keys to both the logon and user keychains, because userspace fsck requires the keychain interface - so we might as well just use user and drop the logon keychain. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: LRU repair tweaksKent Overstreet
- Drop old unneeded parameter for whether we're in initial GC - which was from when btree updates had to be done differently before we went RW. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Delete bch_writepageKent Overstreet
Per Dave Chinner and the xfs folks, .writepage is no longer needed, and it's better not to define it if .writepages is the intended path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Make bch_option compatible with Rust ffiBrett Holman
Rust FFI lacks support for unnamed structs and unions. The space saved in bch_option is not enough to be significant. Signed-off-by: Brett Holman <bholman.devel@gmail.com>
2022-10-03bcachefs: Put btree_trans_verify_sorted() behind debug_check_iteratorsKent Overstreet
This is pretty expensive, and we've tested sufficiently with it now that it doesn't need to be on by default. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix extent mergingKent Overstreet
When merging extents, we have to check that we won't overflow size fields in any CRC entries - but the check for this was wrong, because in the loop it was in we weren't keeping a pointer to the (packed, encoded) CRC field. Fix this by moving it to its own loop. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Improve invalid bkey error messageKent Overstreet
Bkeys have gotten a lot bigger since this code was written and now are often formatted across multiple lines - while the reason a bkey is invalid will still be short and fit on a single line. This patch prints the error bfore the bkey, making it a bit more readable. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix journal_iters_fix()Kent Overstreet
journal_iters_fix() was incorrectly rewinding iterators past keys they had already returned, leading to those keys being double counted in the bch2_gc() path - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Go RW before bch2_check_lrus()Kent Overstreet
btree updates before going RW are expensive if they're in random order, since they use the list of keys for journal replay to insert, which is just a gap buffer. This patch improves the bucket invalidate path so that if bch2_check_lrus() hasn't finished it only prints warnings instead of doing an emergency shutdown, which means we can now set BCH_FS_MAY_GO_RW before bch2_check_lrus(). Also, the filesystem state bits are reorganized a bit. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Add persistent countersDaniel Hill
This adds a new superblock field for persisting counters and adds a sysfs interface in counters/ exposing these counters. The superblock field is ignored by older versions letting us avoid an on disk version bump. Each sysfs file outputs a counter that tracks since filesystem creation and a counter for the current mount session. Signed-off-by: Daniel Hill <daniel@gluo.nz>
2022-10-03bcachefs: Tracepoint improvementsKent Overstreet
Delete some obsolete tracepoints, organize alloc tracepoints better, make a few tracepoints more consistent. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Don't kick journal reclaim unless low on spaceKent Overstreet
We shouldn't kick journal reclaim unnecessarily, it's got its own timer for that. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Lock ordering fixKent Overstreet
Can't take btree node locks while holding btree_reserve_cache_lock - it would be nice if we could check this with lockdep. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Shutdown path improvementsKent Overstreet
We're seeing occasional firings of the assertion in the key cache shutdown code that nr_dirty == 0, which means we must sometimes be doing transaction commits after we've gone read only. Cleanups & changes: - BCH_FS_ALLOC_CLEAN renamed to BCH_FS_CLEAN_SHUTDOWN - new helper bch2_btree_interior_updates_flush(), which returns true if it had to wait - bch2_btree_flush_writes() now also returns true if there were btree writes in flight - __bch2_fs_read_only now checks if btree writes were in flight in the shutdown loop: btree write completion does a transaction update, to update the pointer in the parent node - assert that !BCH_FS_CLEAN_SHUTDOWN in __bch2_trans_commit Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Fix hash_check_key()Kent Overstreet
hash_check_key() was incorrectly handling transaction restarts - switch it to for_each_btree_key_norestart(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Allocate some extra room in btree_key_cache_fill()Kent Overstreet
If we allocate a buffer that's a bit bigger than necessary the transaction commit path will be much less likely to have to reallocate - which requires a transaction restart. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: bch2_btree_iter_peek_all_levels()Kent Overstreet
This adds bch2_btree_iter_peek_all_levels(), which returns keys from every level of the btree - interior nodes included - in monotonically increasing order, soon to be used by the backpointers check & repair code. - BTREE_ITER_ALL_LEVELS can now be passed to for_each_btree_key() to iterate thusly, much like BTREE_ITER_SLOTS - The existing algorithm in bch2_btree_iter_advance() doesn't work with peek_all_levels(): we have to defer the actual advancing until the next time we call peek, where we have the btree path traversed and uptodate. So, we add an advanced bit to btree_iter; when BTREE_ITER_ALL_LEVELS is set bch2_btree_iter_advanced() just marks the iterator as advanced. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: btree_path_set_level_(up|down)Kent Overstreet
This adds two new helpers to btree_iter.c for changing the level of a path up or down - to be used by the new bch2_btree_iter_peek_all_levels(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: bch2_btree_iter_peek_slot() now works on interior nodesKent Overstreet
The new backpointers code will be using bch2_btree_iter_peek_slot() on interior nodes - this patch updates peek_slot() to make that work. - Pass the correct level to bch2_journal_keys_peek_slot() - We should only set BTREE_ITER_CACHED or BTREE_ITER_WITH_KEY_CACHE when using bch2_trans_iter_init(), not bch2_trans_node_iter_init() - Update assertions Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: btree_update_interior.c prep for backpointersKent Overstreet
Previously, btree_update_interior.c passed keys to bch2_trans_mark_* that hadn't been fully initialized - they didn't have the key field filled out, just the value. With backpointers, we need to make sure keys are fully initialized before marking them - because the backpointer points back to the original key. This patch tweaks the interior update paths to fix this. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Plumb btree_id & level to trans_markKent Overstreet
For backpointers, we'll need the full key location - that means btree_id and btree level. This patch plumbs it through. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Improve some fsck error messagesKent Overstreet
We have string names for d_type; use it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Go emergency RO when i_blocks underflowsKent Overstreet
This improves some of our warnings and assertions - they imply possible filesystem inconsistencies, so they should be calling bch2_fs_inconsistent(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Ensure sysfs show fns print a newlineKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Improve try_alloc_bucket()Kent Overstreet
This patch primarily improves the error reporting in try_alloc_bucket(): we now print out the actual freespace extent we were allocating from, which makes it easier to grep through the logs when something goes wrong. Also: - switch to for_each_btree_key_norestart(); bch2_bucket_alloc() already handles transaction restarts, and in general transaction restarts should only be handled in one place - switch to < instead of != when looping over buckets represented by a freespace extent Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: Kill old rebuild_replicas optionKent Overstreet
This option was useful when the replicas mechism was new and still being debugged, but hasn't been used in ages - let's delete it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-10-03bcachefs: In fsck, pass BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE when deleting ↵Kent Overstreet
dirents A user reported an error where we hit an assertion due to deleting a key in an internal snapshot node, when deleting a dirent that points to a nonexisting inode. We try to avoid doing updates to keys for internal snapshot nodes, but upon inspection of the places where we remove dirents in fsck it appears BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE is correct for all of them: either the target dirent doesn't exist, or it's a directory with multiple dirents pointing to it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>