bool filter_whiteouts)
{
struct bkey_packed *prev = NULL, *k_packed;
- struct bkey_s k;
+ struct bkey_on_stack k;
struct btree_nr_keys nr;
- struct bkey unpacked;
memset(&nr, 0, sizeof(nr));
+ bkey_on_stack_init(&k);
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, &unpacked);
+ /*
+ * NOTE:
+ * bch2_bkey_normalize may modify the key we pass it (dropping
+ * stale pointers) and we don't have a write lock on the src
+ * node; we have to make a copy of the entire key before calling
+ * normalize
+ */
+ bkey_on_stack_realloc(&k, c, k_packed->u64s + BKEY_U64s);
+ bch2_bkey_unpack(src, k.k, k_packed);
if (filter_whiteouts &&
- bch2_bkey_normalize(c, k))
+ bch2_bkey_normalize(c, bkey_i_to_s(k.k)))
continue;
- extent_sort_append(c, out_f, &nr, vstruct_last(dst), &prev, k);
+ extent_sort_append(c, out_f, &nr, vstruct_last(dst),
+ &prev, bkey_i_to_s(k.k));
}
extent_sort_advance_prev(out_f, &nr, vstruct_last(dst), &prev);
dst->u64s = cpu_to_le16((u64 *) prev - dst->_data);
+ bkey_on_stack_exit(&k, c);
return nr;
}