diff options
| author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-12-30 14:37:25 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:36 -0400 |
| commit | e3e464ac6d09269b19cea3dc32b626db44d0e6ba (patch) | |
| tree | 7aafd377933161ed88573a5e3dab7ee3d8e0e06a /fs/bcachefs/btree_io.c | |
| parent | bcachefs: btree_iter_peek_with_updates() (diff) | |
| download | linux-e3e464ac6d09269b19cea3dc32b626db44d0e6ba.tar.gz linux-e3e464ac6d09269b19cea3dc32b626db44d0e6ba.zip | |
bcachefs: Move extent overwrite handling out of core btree code
Ever since the btree code was first written, handling of overwriting
existing extents - including partially overwriting and splittin existing
extents - was handled as part of the core btree insert path. The modern
transaction and iterator infrastructure didn't exist then, so that was
the only way for it to be done.
This patch moves that outside of the core btree code to a pass that runs
at transaction commit time.
This is a significant simplification to the btree code and overall
reduction in code size, but more importantly it gets us much closer to
the core btree code being completely independent of extents and is
important prep work for snapshots.
This introduces a new feature bit; the old and new extent update models
are incompatible when the filesystem needs journal replay.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_io.c')
| -rw-r--r-- | fs/bcachefs/btree_io.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index a4732bf13a11..d0b761417903 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -708,9 +708,7 @@ static int validate_bset(struct bch_fs *c, struct btree *b, unsigned *whiteout_u64s, int write, bool have_retry) { - struct bkey_packed *k; - struct bkey prev = KEY(0, 0, 0); - struct bpos prev_data = POS_MIN; + struct bkey_packed *k, *prev = NULL; bool seen_non_whiteout = false; unsigned version; const char *err; @@ -852,15 +850,15 @@ static int validate_bset(struct bch_fs *c, struct btree *b, if (!seen_non_whiteout && (!bkey_whiteout(k) || - (bkey_cmp(prev.p, bkey_start_pos(u.k)) > 0))) { + (prev && bkey_iter_cmp(b, prev, k) > 0))) { *whiteout_u64s = k->_data - i->_data; seen_non_whiteout = true; - } else if (bkey_cmp(prev_data, bkey_start_pos(u.k)) > 0 || - bkey_cmp(prev.p, u.k->p) > 0) { + } else if (prev && bkey_iter_cmp(b, prev, k) > 0) { char buf1[80]; char buf2[80]; + struct bkey up = bkey_unpack_key(b, prev); - bch2_bkey_to_text(&PBUF(buf1), &prev); + bch2_bkey_to_text(&PBUF(buf1), &up); bch2_bkey_to_text(&PBUF(buf2), u.k); bch2_dump_bset(b, i, 0); @@ -870,10 +868,7 @@ static int validate_bset(struct bch_fs *c, struct btree *b, /* XXX: repair this */ } - if (!bkey_deleted(u.k)) - prev_data = u.k->p; - prev = *u.k; - + prev = k; k = bkey_next_skip_noops(k, vstruct_last(i)); } |
