mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
bcachefs: Be careful about btree node splits during journal replay
Don't pick a pivot that's going to be deleted. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
048f47e83f
commit
40cb26233a
@ -261,6 +261,22 @@ int bch2_journal_key_delete(struct bch_fs *c, enum btree_id id,
|
||||
return bch2_journal_key_insert(c, id, level, &whiteout);
|
||||
}
|
||||
|
||||
bool bch2_key_deleted_in_journal(struct btree_trans *trans, enum btree_id btree,
|
||||
unsigned level, struct bpos pos)
|
||||
{
|
||||
struct journal_keys *keys = &trans->c->journal_keys;
|
||||
size_t idx = bch2_journal_key_search(keys, btree, level, pos);
|
||||
|
||||
if (!trans->journal_replay_not_finished)
|
||||
return false;
|
||||
|
||||
return (idx < keys->size &&
|
||||
keys->data[idx].btree_id == btree &&
|
||||
keys->data[idx].level == level &&
|
||||
bpos_eq(keys->data[idx].k->k.p, pos) &&
|
||||
bkey_deleted(&keys->data[idx].k->k));
|
||||
}
|
||||
|
||||
void bch2_journal_key_overwritten(struct bch_fs *c, enum btree_id btree,
|
||||
unsigned level, struct bpos pos)
|
||||
{
|
||||
|
@ -40,8 +40,8 @@ int bch2_journal_key_insert(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bkey_i *);
|
||||
int bch2_journal_key_delete(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bpos);
|
||||
void bch2_journal_key_overwritten(struct bch_fs *, enum btree_id,
|
||||
unsigned, struct bpos);
|
||||
bool bch2_key_deleted_in_journal(struct btree_trans *, enum btree_id, unsigned, struct bpos);
|
||||
void bch2_journal_key_overwritten(struct bch_fs *, enum btree_id, unsigned, struct bpos);
|
||||
|
||||
void bch2_btree_and_journal_iter_advance(struct btree_and_journal_iter *);
|
||||
struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter *);
|
||||
|
@ -1380,9 +1380,16 @@ static void __btree_split_node(struct btree_update *as,
|
||||
if (bkey_deleted(k))
|
||||
continue;
|
||||
|
||||
uk = bkey_unpack_key(b, k);
|
||||
|
||||
if (b->c.level &&
|
||||
u64s < n1_u64s &&
|
||||
u64s + k->u64s >= n1_u64s &&
|
||||
bch2_key_deleted_in_journal(trans, b->c.btree_id, b->c.level, uk.p))
|
||||
n1_u64s += k->u64s;
|
||||
|
||||
i = u64s >= n1_u64s;
|
||||
u64s += k->u64s;
|
||||
uk = bkey_unpack_key(b, k);
|
||||
if (!i)
|
||||
n1_pos = uk.p;
|
||||
bch2_bkey_format_add_key(&format[i], &uk);
|
||||
|
Loading…
Reference in New Issue
Block a user