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>
Kent Overstreet [Mon, 22 Jul 2019 17:37:02 +0000 (13:37 -0400)]
bcachefs: Improved bch2_fcollapse()
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>
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>
Kent Overstreet [Sat, 7 Sep 2019 20:13:20 +0000 (16:13 -0400)]
bcachefs: data move path should not be trying to move reflink_p keys
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>
Kent Overstreet [Thu, 29 Aug 2019 17:29:31 +0000 (13:29 -0400)]
bcachefs: Fix BTREE_INSERT_NOMARK_OVERWRITES
bch2_mark_update() was correct, but bch2_trans_mark_update() wasn't
respecting BTREE_INSERT_NOMARK_OVERWRITES - key marking/triggers really
need to be cleaned up.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Thu, 29 Aug 2019 15:34:01 +0000 (11:34 -0400)]
bcachefs: Improve pointer marking checks and error messages
Importantly, we don't want to use bch2_fs_inconsistent_on() for errors
that fsck can repair, becuase that will just put us in RO mode and
prevent fsck from actually fixing stuff. Probably want to get rid of it
in the future.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Wed, 28 Aug 2019 16:41:45 +0000 (12:41 -0400)]
bcachefs: Fix fiemap (again)
when iterating over reflink pointers, we use the key we just emitted to
set the iterator position - which means we have to be setting the key's
inode field as well
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Thu, 22 Aug 2019 17:20:38 +0000 (13:20 -0400)]
bcachefs: Fixes for replicas tracking
The continue statement in bch2_trans_mark_extent() was wrong - by
bailing out early, we'd be constructing the wrong replicas list to
update. Also, the assertion in update_replicas() was wrong - due to
rounding with compressed extents, it is possible for sectors to be 0
sometimes.
Also, change extent_to_replicas() in replicas.c to match the replicas
list we construct in buckets.c.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Tue, 27 Aug 2019 21:45:42 +0000 (17:45 -0400)]
bcachefs: Refactor bch2_alloc_write()
Major simplification - gets rid of the need for marking buckets as
dirty, instead we write buckets if the in memory mark is different from
what's in the btree.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Tue, 27 Aug 2019 21:34:03 +0000 (17:34 -0400)]
bcachefs: Trust in memory bucket mark
This fixes a bug in the journal replay -> extent_replay_key ->
split_compressed path, when we do an update that changes alloc info but
the alloc info in the btree isn't up to date yet.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Wed, 21 Aug 2019 22:55:07 +0000 (18:55 -0400)]
bcachefs: Fix bch2_bkey_narrow_crcs()
We have to reinitialize ptrs whenever we do something that changes them.
Regression from when the code was converted to be generic across all
keys with pointers.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Wed, 21 Aug 2019 22:35:15 +0000 (18:35 -0400)]
bcachefs: Fix bch2_sort_repack_merge()
bch2_bkey_normalize() modifies the value, and we were modifying the
original value in the src btree node - but, we're called without a write
lock held on the src node. Oops...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Tue, 20 Aug 2019 21:43:47 +0000 (17:43 -0400)]
bcachefs: Fix bch2_btree_node_iter_fix()
bch2_btree_node_iter_prev_all() depends on an invariant that wasn't
being maintained for extent leaf nodes - specifically, the node iterator
may not have advanced past any keys that compare after the key the node
iterator points to.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Mon, 19 Aug 2019 17:43:01 +0000 (13:43 -0400)]
bcachefs: Fix bch2_btree_node_iter_prev_filter()
bch2_btree_node_iter_prev_filter() tried to be smart about iterating
backwards when skipping over whiteouts/discards - but unfortunately,
doing so can leave the node iterator in an inconsistent state; the sane
solution is to just always iterate backwards one key at a time.
But we compact btree nodes when more than a quarter of the keys are
whiteouts/discards, so the optimization wasn't buying us that much
anyways.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Wed, 7 Aug 2019 16:07:13 +0000 (12:07 -0400)]
bcachefs: trans_get_key() now works correctly for extents
More prep work for reflink: for extents, we're not looking for an exact
mach on pos, rather that the pos is within the range of the key the
iterator points to.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Tue, 9 Jul 2019 16:56:43 +0000 (12:56 -0400)]
bcachefs: Add offset_into_extent param to bch2_read_extent()
With reflink, we'll no longer be able to calculate the offset of the
data we want into the extent we're reading from from the extent pos and
the iter pos - we'll have to pass it in separately.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Fri, 12 Jul 2019 21:08:32 +0000 (17:08 -0400)]
bcachefs: Fix ec_stripes_read()
Change it to not mark keys that will be overwritten by keys in the
journal - this fixes a bug where we pop an assertion in
bucket_set_stripe() because of a stale pointer - because the stripe that
has the stale pointer has been deleted.
This code could be factored out and used elsewhere, at some point.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Wed, 10 Jul 2019 20:04:58 +0000 (16:04 -0400)]
bcachefs: Don't try to delete stripes when RO
We weren't checking for errors when trying to delet stripes, which meant
ec_stripe_delete_work() would spin trying to delete the same stripe over
and over.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Kent Overstreet [Tue, 9 Jul 2019 15:16:33 +0000 (11:16 -0400)]
bcachefs: Fix moving compressed data
bio_uncompress_inplace() used to potentially need to extend the bio to
be big enough for the uncompressed data, which has become problematic
with multipage bvecs - but, the move extent path actually already
allocated the bios to be big enough for the uncompressed data.
The promote path needed to be fixed, though.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>