summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-04-02bcachefs: Fixes for 5.15bcachefs-v5.15Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2022-04-02Merge with 40a2993bf6 bcachefs: Discard path fixes/improvementsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Kill bch2_ec_mem_alloc()Kent Overstreet
bch2_ec_mem_alloc() was only used by GC, and there's no real need to preallocate the stripes radix tree since we can cope fine with memory allocation failure when we use the radix tree. This deletes a fair bit of code, and it's also needed for the upcoming patch because bch2_btree_iter_peek_prev() won't be working before journal replay completes (and using it was incorrect previously, as well). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Fix allocator + journal interactionKent Overstreet
The allocator needs to wait until the last update touching a bucket has been commited before writing to it again. However, the code was checking against the last dirty journal sequence number, not the last flushed journal sequence number. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: New in-memory array for bucket gensKent Overstreet
The main in-memory bucket array is going away, but we'll still need to keep bucket generations in memory, at least for now - ptr_stale() needs to be an efficient operation. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Separate out gc_bucket()Kent Overstreet
Since the main in memory bucket array is going away, we don't want to be calling bucket() or __bucket() when what we want is the GC in-memory bucket. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Put open_buckets in a hashtableKent Overstreet
This is so that the copygc code doesn't have to refer to bucket_mark.owned_by_allocator - assisting in getting rid of the in memory bucket array. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Refactor open_bucket codeKent Overstreet
Prep work for adding a hash table of open buckets - instead of embedding a bch_extent_ptr, we need to refer to the bucket directly so that we're not calling sector_to_bucket() in the hash table lookup code, which has an expensive divide. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Use bch2_alloc_sectors_append_ptrs()Kent Overstreet
This code was duplicated in init_append_extent(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Delete some obsolete journal_seq_blacklist codeKent Overstreet
Since metadata version bcachefs_metadata_version_btree_ptr_sectors_written, we haven't needed the journal seq blacklist mechanism for ignoring blacklisted btree node writes - we now only need it for ignoring journal entries that were written after the newest flush journal entry, and then we only need to keep those blacklist entries around until journal replay is finished. That means we can delete the code for scanning btree nodes to GC journal_seq_blacklist entries. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Journal initialization fixesKent Overstreet
This fixes a rare bug when mounting & unmounting RO - flushing a clean filesystem that never went RO should be a no op. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Use BTREE_ITER_NOPRESERVE in bch2_btree_iter_verify_ret()Kent Overstreet
This fixes a transaction path overflow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Fix bch2_journal_meta()Kent Overstreet
This patch ensures that the journal entry written gets written as flush entry, which is important for the shutdown path - the last entry written needs to be a flush entry. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: bch2_journal_key_insert() no longer transfers ownershipKent Overstreet
bch2_journal_key_insert() used to assume that the key passed to it was allocated with kmalloc(), and on success took ownership. This patch deletes that behaviour, making it more similar to bch2_trans_update()/bch2_trans_commit(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Kill ptr_bucket_mark()Kent Overstreet
Only used in one place, we can just delete it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Kill allocator short-circuit invalidateKent Overstreet
The allocator thread invalidates buckets (increments their generation number) prior to discarding them and putting them on freelists. We've had a short circuit path for some time to only update the in-memory bucket mark when doing the invalidate if we're not invalidating cached data, but that short-circuit path hasn't really been needed for quite some time (likely since the btree key cache code was added). We're deleting it now as part of deleting/converting code that uses the in memory bucket array. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: bch2_bucket_alloc_new_fs() no longer depends on bucket marksKent Overstreet
Now that bch2_bucket_alloc_new_fs() isn't looking at bucket marks to decide what buckets are eligible to allocate, we can clean up the filesystem initialization and device add paths. Previously, we had to use ancient code to mark superblock/journal buckets in the in memory bucket marks as we allocated them, and then zero that out and re-do that marking using the newer transational bucket mark paths. Now, we can simply delete the in-memory bucket marking. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-26bcachefs: Rewrite bch2_bucket_alloc_new_fs()Kent Overstreet
This changes bch2_bucket_alloc_new_fs() to a simple bump allocator that doesn't need to use the in memory bucket array, part of a larger patch series to entirely get rid of the in memory bucket array, except for gc/fsck. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Kill non-lru cache replacement policiesKent Overstreet
Prep work for persistent LRUs and getting rid of the in memory bucket array. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix a null ptr deref in bch2_inode_delete_keys()Kent Overstreet
Similarly to bch2_btree_delete_range_trans(), bch2_inode_delete_keys() may sometimes split compressed extents, and needs to pass in a disk reservation. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Turn encoded_extent_max into a regular optionKent Overstreet
It'll now be handled at format time and in sysfs like other options - it still can only be set at format time, though. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Option improvementsKent Overstreet
This adds flags for options that must be a power of two (block size and btree node size), and options that are stored in the superblock as a power of two (encoded extent max). Also: options are now stored in memory in the same units they're displayed in (bytes): we now convert when getting and setting from the superblock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix debugfs -bfloat-failedKent Overstreet
It wasn't updated for snapshots - it's iterating across keys in all snapshots, so needs to be specifying BTREE_ITER_ALL_SNAPSHOTS. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: BTREE_ITER_NOPRESERVEKent Overstreet
This adds a flag to not mark the initial btree_path as preserve, for paths that we expect to be cheap to reconstitute if necessary - this solves a btree_path overflow caused by need_whiteout_for_snapshot(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix some shutdown path bugsKent Overstreet
This fixes some bugs when we hit an error very early in the filesystem startup path, before most things have been initialized. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Optimize memory accesses in bch2_btree_node_get()Kent Overstreet
This puts a load behind some branches before where it's used, so that it can execute in parallel with other loads. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Make sure bch2_bucket_alloc_new_fs() obeys buckets_nouseKent Overstreet
This fixes the filesystem migrate tool. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Kill some obsolete sysfs codeKent Overstreet
fs internal/alloc_debug doesn't show anything bcachefs fs usage shows. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Don't call bch2_bkey_transform() unnecessarilyKent Overstreet
If the packed format isn't changing, there's no need to call bch2_bkey_transform(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Kill bch2_sort_repack_merge()Kent Overstreet
The main function of bch2_sort_repack_merge() was to call .key_normalize on every key, which drops stale (cached) pointers - it hasn't actually merged extents in quite some time. But bch2_gc_gens() now works on individual keys - we used to gc old gens by rewriting entire btree nodes. With that gone, there's no need for internal btree code to be calling .key_normalize anymore. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Sysfs internal/btree_transactions is now always enabledKent Overstreet
This highly-useful debugging feature helps with debugging deadlocks, and it doesn't cost much, so let's have it always enabled. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix an assertion in bch2_truncate()Kent Overstreet
We recently added an assertion that when we truncate a file to 0, i_blocks should also go to 0 - but that's not necessarily true if we're doing an emergency shutdown, lots of invariants no longer hold true in that case. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix debug build in userspaceKent Overstreet
This fixes some compiler warnings that only trigger in userspace - dead code, a maybe uninitialed variable, a maybe null ptr passed to printk. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Add missing bch2_trans_iter_exit() callKent Overstreet
This fixes a bug where the filesystem goes read only when reading from debugfs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Improve alloc_mem_to_key()Kent Overstreet
This moves some common code into alloc_mem_to_key(), which translates from the in-memory format for a bucket to the btree key format. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: bch2_alloc_write()Kent Overstreet
This adds a new helper that much like the one we have for inode updates, that allocates the packed alloc key, packs it and calls bch2_trans_update. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Add more time_statsKent Overstreet
This adds more latency/event measurements and breaks some apart into more events. Journal writes are broken apart into flush writes and noflush writes, btree compactions are broken out from btree splits, btree mergers are added, as well as btree_interior_updates - foreground and total. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Print out OPT_SECTORS options in bytesKent Overstreet
This matches the conversion the parsing code does. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix null ptr deref in fsck_inode_rm()Kent Overstreet
bch2_btree_delete_range() can split compressed extents, thus needs to pass in a disk reservation when we're operating on extents btrees. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Don't erasure code cached ptrsKent Overstreet
It doesn't make much sense to be erasure coding cached pointers, we should be erasure coding one of the dirty pointers in an extent. This patch makes sure we're passing BCH_WRITE_CACHED when we expect the new pointer to be a cached pointer, and tweaks the write path to not allocate from a stripe when BCH_WRITE_CACHED is set - and fixes an assertion we were hitting in the ec path where when adding the stripe to an extent and deleting the other pointers the pointer to the stripe didn't exist (because dropping all dirty pointers from an extent turns it into a KEY_TYPE_error key). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Split out struct gc_stripe from struct stripeKent Overstreet
We have two radix trees of stripes - one that mirrors some information from the stripes btree in normal operation, and another that GC uses to recalculate block usage counts. The normal one is now only used for finding partially empty stripes in order to reuse them - the normal stripes radix tree and the GC stripes radix tree are used significantly differently, so this patch splits them into separate types. In an upcoming patch we'll be replacing c->stripes with a btree that indexes stripes by the order we want to reuse them. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Convert a BUG_ON() to a warningKent Overstreet
A user reported hitting this assertion, and we can't reproduce it yet, but it shouldn't be fatal - so convert it to a warning. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: bch2_trans_update() is now __must_checkKent Overstreet
With snapshots, bch2_trans_update() has to check if we need a whitout, which can cause a transaction restart, so this is important now. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Make __bch2_journal_debug_to_text() more readableKent Overstreet
Switch to one line of output per pr_buf() call - longer lines but quite a bit more readable. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Specify filesystem optionsKent Overstreet
We've got three types of options now - filesystem, device and inode, and a given option may belong to more than one of those types. This patch changes the options to specify explicitly when they're a filesystem option - in the future we'll probably be adding more device options. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix copygc sectors_to_move calculationKent Overstreet
With erasure coding, copygc's count of sectors to move was off, which matters for the debug statement it prints out when it's not able to move all the data it tried to. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Convert journal sysfs params to regular optionsKent Overstreet
This converts journal_write_delay, journal_flush_disabled, and journal_reclaim_delay to normal filesystems options, and also adds them to the superblock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Fix btree_path leaks in bch2_trans_update()Kent Overstreet
bch2_trans_update() had some dodgy gets() and puts() - this fixes a few leaks. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Erasure coding fixesKent Overstreet
When we added the stripe and stripe_redundancy fields to alloc keys, we neglected to add them to the functions that convert back and forth with the in-memory types. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2021-12-25bcachefs: Handle replica marking fsck errors locallyKent Overstreet
This simplifies the code quite a bit and eliminates an inconsistency - a given bkey doesn't necessarily translate to a single replicas entry for disk space accounting. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>