mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 02:00:43 -04:00
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>
This commit is contained in:
committed by
Kent Overstreet
parent
76426098e4
commit
e42951b0aa
@@ -415,25 +415,22 @@ bch2_sort_repack_merge(struct bch_fs *c,
|
||||
struct bkey_format *out_f,
|
||||
bool filter_whiteouts)
|
||||
{
|
||||
struct bkey_packed *prev = NULL, *k_packed, *next;
|
||||
struct bkey k_unpacked;
|
||||
struct bkey_packed *prev = NULL, *k_packed;
|
||||
struct bkey_s k;
|
||||
struct btree_nr_keys nr;
|
||||
BKEY_PADDED(k) tmp;
|
||||
|
||||
memset(&nr, 0, sizeof(nr));
|
||||
|
||||
next = bch2_btree_node_iter_next_all(iter, src);
|
||||
while ((k_packed = next)) {
|
||||
/*
|
||||
* The filter might modify the size of @k's value, so advance
|
||||
* the iterator first:
|
||||
*/
|
||||
next = bch2_btree_node_iter_next_all(iter, src);
|
||||
|
||||
while ((k_packed = bch2_btree_node_iter_next_all(iter, src))) {
|
||||
if (filter_whiteouts && bkey_whiteout(k_packed))
|
||||
continue;
|
||||
|
||||
k = __bkey_disassemble(src, k_packed, &k_unpacked);
|
||||
EBUG_ON(bkeyp_val_u64s(&src->format, k_packed) >
|
||||
BKEY_EXTENT_VAL_U64s_MAX);
|
||||
|
||||
bch2_bkey_unpack(src, &tmp.k, k_packed);
|
||||
k = bkey_i_to_s(&tmp.k);
|
||||
|
||||
if (filter_whiteouts &&
|
||||
bch2_bkey_normalize(c, k))
|
||||
|
||||
@@ -1590,9 +1590,9 @@ bool bch2_extent_normalize(struct bch_fs *c, struct bkey_s k)
|
||||
|
||||
/* will only happen if all pointers were cached: */
|
||||
if (!bkey_val_u64s(k.k))
|
||||
k.k->type = KEY_TYPE_deleted;
|
||||
k.k->type = KEY_TYPE_discard;
|
||||
|
||||
return false;
|
||||
return bkey_whiteout(k.k);
|
||||
}
|
||||
|
||||
void bch2_bkey_mark_replicas_cached(struct bch_fs *c, struct bkey_s k,
|
||||
|
||||
Reference in New Issue
Block a user