Commit a965ef49 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix bch2_sort_keys() to not modify src keys

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5525f632
......@@ -254,23 +254,18 @@ unsigned bch2_sort_keys(struct bkey_packed *dst,
sort_iter_sort(iter, sort_keys_cmp);
while ((in = sort_iter_next(iter, sort_keys_cmp))) {
bool needs_whiteout = false;
if (bkey_whiteout(in) &&
(filter_whiteouts || !in->needs_whiteout))
continue;
if (bkey_whiteout(in) &&
(next = sort_iter_peek(iter)) &&
!bkey_cmp_packed(iter->b, in, next)) {
while ((next = sort_iter_peek(iter)) &&
!bkey_cmp_packed(iter->b, in, next)) {
BUG_ON(in->needs_whiteout &&
next->needs_whiteout);
/*
* XXX racy, called with read lock from write path
*
* leads to spurious BUG_ON() in bkey_unpack_key() in
* debug mode
*/
next->needs_whiteout |= in->needs_whiteout;
continue;
needs_whiteout |= in->needs_whiteout;
in = sort_iter_next(iter, sort_keys_cmp);
}
if (bkey_whiteout(in)) {
......@@ -279,6 +274,7 @@ unsigned bch2_sort_keys(struct bkey_packed *dst,
} else {
bkey_copy(out, in);
}
out->needs_whiteout |= needs_whiteout;
out = bkey_next(out);
}
......
......@@ -199,12 +199,6 @@ __bkey_unpack_key_format_checked(const struct btree *b,
if (btree_keys_expensive_checks(b)) {
struct bkey dst2 = __bch2_bkey_unpack_key(&b->format, src);
/*
* hack around a harmless race when compacting whiteouts
* for a write:
*/
dst2.needs_whiteout = dst->needs_whiteout;
BUG_ON(memcmp(dst, &dst2, sizeof(*dst)));
}
}
......
......@@ -1339,12 +1339,6 @@ static inline struct bkey_s_c btree_iter_peek_uptodate(struct btree_iter *iter)
if (debug_check_iterators(iter->trans->c)) {
struct bkey k = bkey_unpack_key(l->b, _k);
/*
* this flag is internal to the btree code,
* we don't care if it doesn't match - if it's now set
* it just means the key has been written out to disk:
*/
k.needs_whiteout = iter->k.needs_whiteout;
BUG_ON(memcmp(&k, &iter->k, sizeof(k)));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment