mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 02:09:42 +00:00
bcachefs: Fix bch2_sort_keys() to not modify src keys
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
5525f632dc
commit
a965ef4986
3 changed files with 7 additions and 23 deletions
|
@ -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)) &&
|
||||
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)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue