summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
2023-10-22bcachefs: Fix bch2_extent_ptr_durability()Kent Overstreet
We were looking up the wrong entry in the stripes radix tree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix bch2_mark_extent()Kent Overstreet
If an extent only contained cached or erasure coded pointers, there won't be any devices in the normal dirty replicas list or an entry to update. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Initialize journal pad data in bch_replica_entry objects.Justin Husted
Running the filesystem under valgrind exposed some garbage data being written to disk in bch2_journal_super_entries_add_common(), in the portion which encodes bch_replica_entry objects. Signed-off-by: Justin Husted <sigstop@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix uninitialized data in bch2_gc_btree()Justin Husted
Running the filesystem under valgrind exposed a path where the max_stale variable in bch2_gc_btree() might not be initialized before use in a rare case when there are no btree nodes in a transaction. Signed-off-by: Justin Husted <sigstop@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix incorrect use of bch2_extent_atomic_end()Kent Overstreet
bch2_extent_atomic_end counts the number of iterators requried for marking overwrites - but journal replay never marks overwrites, so that part was incorrect. And counting iterators for the key being inserted should be unnecessary because we did that prior to the key being inserted before it was first journalled. This should fix an iterator overflow bug - the iterators for walking overwrites were totally unneeded. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Can't be holding read locks while taking write locksKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Don't allocate memory under mark_lockKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: bch2_extent_atomic_end() now traverses iterKent Overstreet
This fixes a bug in io.c bch2_write_index_default() - it was missing the traverse call, but bch2_extent_atomic_end returns an error now and can just call it itself. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Factor out fs-common.cKent Overstreet
This refactoring makes the code easier to understand by separating the bcachefs btree transactional code from the linux VFS code - but more importantly, it's also to share code with the fuse port. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Don't use sha256 for siphash str hash keyKent Overstreet
With the refactoring that's coming to add fuse support, we want bch2_hash_info_init() to be cheaper so we don't have to rely on anything cached besides the inode in the btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Only look up inode io opts in extents btreeKent Overstreet
We currently don't have a way to propagate inode io opts to indirect extents. This is a problem... Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix deref of error pointerKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: bch2_inode_peek()/bch2_inode_write()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix undefined behaviourKent Overstreet
roundup_pow_of_two(0) is undefined Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix an error pathKent Overstreet
It's possible to get -EIO in __btree_iter_traverse_all() after looping, with orig_iter NULL. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix __bch2_buffered_write() returning -ENOMEMKent Overstreet
When grab_cache_page_write_begin() fails but we did pin some pages, we shouldn't return -ENOMEM, we should do a partial write. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Trust inode in btree over bch_inode_infoKent Overstreet
This is the start of some refactoring work to make less code depend on the linux VFS - here the inode cache - to make e.g. the fuse port easier. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix counting iterators for reflink pointersKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Rework btree iterator lifetimesKent Overstreet
The btree_trans struct needs to memoize/cache btree iterators, so that on transaction restart we don't have to completely redo btree lookups, and so that we can do them all at once in the correct order when the transaction had to restart to avoid a deadlock. This switches the btree iterator lookups to work based on iterator position, instead of trying to match them up based on the stack trace. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Kill deferred btree updatesKent Overstreet
Will be replaced by cached btree iterators Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix for partial buffered writesKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: BTREE_ITER_SLOTS isn't a type of btree iterKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Improve error handling for for_each_btree_key_continue()Kent Overstreet
Change it to match for_each_btree_key() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Cleanup i_nlink handlingKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Trivial cleanupKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Convert a BUG_ON() to a warningKent Overstreet
We shouldn't ever be writing past i_size - but, apparently there's still a bug to track down. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Count iterators for reflink_p overwrites correctlyKent Overstreet
In order to avoid trying to allocate too many btree iterators, bch2_extent_atomic_end() needs to count how many iterators are going to be needed for insertions and overwrites - but we weren't counting the iterators for deleting a reflink_v when the refcount goes to 0. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Drop unnecessary rcu_read_lock()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Update path microoptimizationsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Handle bio_iov_iter_get_pages() returning unaligned bioKent Overstreet
If the user buffer isn't aligned to the filesystem block size, on a large enough IO - where it won't fit into a single bio - bio_iov_iter_get_pages() won't necessarily return a bio with the proper alignment. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Drop unused arg to bch2_open_buckets_stop_dev()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix validation of replicas entriesKent Overstreet
When an extent is erasure coded, we need to record a replicas entry to indicate that data is present on the devices that extent has pointers to - but nr_required should be 0, because it's erasure coded. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Add support for FALLOC_FL_INSERT_RANGEKent Overstreet
Somewhat tricky and ugly, because iterating over extents backwards is a pain. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: bch2_btree_iter_peek_prev()Kent Overstreet
Last of the basic operations for iterating forwards and backwards over the btree: we now have - peek(), returns key >= iter->pos - next(), returns key > iter->pos - peek_prev(), returns key <= iter->pos - prev(), returns key < iter->pos Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Don't write past eofKent Overstreet
When converting from PAGE_SIZE to block_size, the .mkwrite path was missed Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Check for extents past eof correctlyKent Overstreet
bcachefs used to work mostly in terms of PAGE_SIZE, not block size at the vfs level - but that has since been fixed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Debug assertion improvementsKent Overstreet
Call bch2_btree_iter_verify from bch2_btree_node_iter_fix(); also verify in btree_iter_peek_uptodate() that iter->k matches what's in the btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Add missing bch2_btree_node_iter_fix() callKent Overstreet
Any time we're modifying what's in the btree, iterators potentially have to be updated - this one was exposed by the reflink code. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Avoid deadlocking on the allocatorKent Overstreet
The allocator needs to make sure there's buckets available on the RESERVE_NONE freelist if at all possible - otherwise foreground IO will get stuck. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: More btree iter improvementsKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Improve btree_iter_pos_in_node()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Debug code improvementsKent Overstreet
.key_debugcheck no longer needs to take a pointer to the btree node Also, try to make sure wherever we're inserting or modifying keys in the btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Add missing bch2_btree_node_iter_fix() callsKent Overstreet
With multiple iterators, if another iterator points to the key being modified, we need to call bch2_btree_node_iter_fix() to re-unpack the key into the iter->k Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Optimize calls to bch2_btree_iter_traverse()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Fix a typoKent Overstreet
_iter, not iter Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Improved bch2_fcollapse()Kent Overstreet
Move extents instead of copying them - this way, we can iterate over only live extents, not the entire keyspace. Also, this means we can mostly skip running triggers. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: __bch2_btree_node_iter_fix() improvementsKent Overstreet
Being more rigorous about noting when the key the iterator currently poins to has changed - which should also give us a nice performance improvement due to not having to check if we have to skip other bsets backwards as much. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Do updates in order they were queued up inKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: Drop trans arg to bch2_extent_atomic_end()Kent Overstreet
Just for consistency Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-10-22bcachefs: data move path should not be trying to move reflink_p keysKent Overstreet
This was spotted when the move_extent() path tried to allocate a bio for a reflink_p extent, but adding pages to the bio failed because we overflowed bi_max_vecs. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>