Commit 47143a75 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Disable extent merging

Extent merging is currently broken, and will be reimplemented
differently soon - right now it only happens when btree nodes are being
compacted, which makes it difficult to test.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0728eed7
...@@ -408,9 +408,8 @@ static inline int bch2_compile_bkey_format(const struct bkey_format *format, ...@@ -408,9 +408,8 @@ static inline int bch2_compile_bkey_format(const struct bkey_format *format,
static inline void bkey_reassemble(struct bkey_i *dst, static inline void bkey_reassemble(struct bkey_i *dst,
struct bkey_s_c src) struct bkey_s_c src)
{ {
BUG_ON(bkey_packed(src.k));
dst->k = *src.k; dst->k = *src.k;
memcpy_u64s(&dst->v, src.v, bkey_val_u64s(src.k)); memcpy_u64s_small(&dst->v, src.v, bkey_val_u64s(src.k));
} }
#define bkey_s_null ((struct bkey_s) { .k = NULL }) #define bkey_s_null ((struct bkey_s) { .k = NULL })
......
...@@ -130,44 +130,21 @@ bch2_key_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, ...@@ -130,44 +130,21 @@ bch2_key_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
return nr; return nr;
} }
static void extent_sort_advance_prev(struct bkey_format *f,
struct btree_nr_keys *nr,
struct bkey_packed *start,
struct bkey_packed **prev)
{
if (*prev) {
bch2_bkey_pack(*prev, (void *) *prev, f);
btree_keys_account_key_add(nr, 0, *prev);
*prev = bkey_next(*prev);
} else {
*prev = start;
}
}
static void extent_sort_append(struct bch_fs *c, static void extent_sort_append(struct bch_fs *c,
struct bkey_format *f, struct bkey_format *f,
struct btree_nr_keys *nr, struct btree_nr_keys *nr,
struct bkey_packed *start, struct bkey_packed **out,
struct bkey_packed **prev,
struct bkey_s k) struct bkey_s k)
{ {
if (bkey_whiteout(k.k)) if (!bkey_whiteout(k.k)) {
return; if (!bch2_bkey_pack_key(*out, k.k, f))
memcpy_u64s_small(*out, k.k, BKEY_U64s);
/*
* prev is always unpacked, for key merging - until right before we
* advance it:
*/
if (*prev && memcpy_u64s_small(bkeyp_val(f, *out), k.v, bkey_val_u64s(k.k));
bch2_bkey_merge(c, bkey_i_to_s((void *) *prev), k) ==
BCH_MERGE_MERGE)
return;
extent_sort_advance_prev(f, nr, start, prev); btree_keys_account_key_add(nr, 0, *out);
*out = bkey_next(*out);
bkey_reassemble((void *) *prev, k.s_c); }
} }
/* Sort + repack in a new format: */ /* Sort + repack in a new format: */
...@@ -201,7 +178,7 @@ bch2_sort_repack(struct bset *dst, struct btree *src, ...@@ -201,7 +178,7 @@ bch2_sort_repack(struct bset *dst, struct btree *src,
return nr; return nr;
} }
/* Sort, repack, and merge: */ /* Sort, repack, and call bch2_bkey_normalize() to drop stale pointers: */
struct btree_nr_keys struct btree_nr_keys
bch2_sort_repack_merge(struct bch_fs *c, bch2_sort_repack_merge(struct bch_fs *c,
struct bset *dst, struct btree *src, struct bset *dst, struct btree *src,
...@@ -209,7 +186,7 @@ bch2_sort_repack_merge(struct bch_fs *c, ...@@ -209,7 +186,7 @@ bch2_sort_repack_merge(struct bch_fs *c,
struct bkey_format *out_f, struct bkey_format *out_f,
bool filter_whiteouts) bool filter_whiteouts)
{ {
struct bkey_packed *prev = NULL, *k_packed; struct bkey_packed *out = vstruct_last(dst), *k_packed;
struct bkey_on_stack k; struct bkey_on_stack k;
struct btree_nr_keys nr; struct btree_nr_keys nr;
...@@ -234,13 +211,10 @@ bch2_sort_repack_merge(struct bch_fs *c, ...@@ -234,13 +211,10 @@ bch2_sort_repack_merge(struct bch_fs *c,
bch2_bkey_normalize(c, bkey_i_to_s(k.k))) bch2_bkey_normalize(c, bkey_i_to_s(k.k)))
continue; continue;
extent_sort_append(c, out_f, &nr, vstruct_last(dst), extent_sort_append(c, out_f, &nr, &out, bkey_i_to_s(k.k));
&prev, bkey_i_to_s(k.k));
} }
extent_sort_advance_prev(out_f, &nr, vstruct_last(dst), &prev); dst->u64s = cpu_to_le16((u64 *) out - dst->_data);
dst->u64s = cpu_to_le16((u64 *) prev - dst->_data);
bkey_on_stack_exit(&k, c); bkey_on_stack_exit(&k, c);
return nr; return nr;
} }
...@@ -337,7 +311,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, ...@@ -337,7 +311,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
struct btree *b = iter->b; struct btree *b = iter->b;
struct bkey_format *f = &b->format; struct bkey_format *f = &b->format;
struct sort_iter_set *_l = iter->data, *_r = iter->data + 1; struct sort_iter_set *_l = iter->data, *_r = iter->data + 1;
struct bkey_packed *prev = NULL; struct bkey_packed *out = dst->start;
struct bkey l_unpacked, r_unpacked; struct bkey l_unpacked, r_unpacked;
struct bkey_s l, r; struct bkey_s l, r;
struct btree_nr_keys nr; struct btree_nr_keys nr;
...@@ -360,7 +334,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, ...@@ -360,7 +334,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
l = __bkey_disassemble(b, _l->k, &l_unpacked); l = __bkey_disassemble(b, _l->k, &l_unpacked);
if (iter->used == 1) { if (iter->used == 1) {
extent_sort_append(c, f, &nr, dst->start, &prev, l); extent_sort_append(c, f, &nr, &out, l);
extent_iter_advance(iter, 0); extent_iter_advance(iter, 0);
continue; continue;
} }
...@@ -369,7 +343,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, ...@@ -369,7 +343,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
/* If current key and next key don't overlap, just append */ /* If current key and next key don't overlap, just append */
if (bkey_cmp(l.k->p, bkey_start_pos(r.k)) <= 0) { if (bkey_cmp(l.k->p, bkey_start_pos(r.k)) <= 0) {
extent_sort_append(c, f, &nr, dst->start, &prev, l); extent_sort_append(c, f, &nr, &out, l);
extent_iter_advance(iter, 0); extent_iter_advance(iter, 0);
continue; continue;
} }
...@@ -414,17 +388,15 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, ...@@ -414,17 +388,15 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
__sort_iter_sift(iter, 0, __sort_iter_sift(iter, 0,
extent_sort_fix_overlapping_cmp); extent_sort_fix_overlapping_cmp);
extent_sort_append(c, f, &nr, dst->start, extent_sort_append(c, f, &nr, &out,
&prev, bkey_i_to_s(split.k)); bkey_i_to_s(split.k));
} else { } else {
bch2_cut_back_s(bkey_start_pos(r.k), l); bch2_cut_back_s(bkey_start_pos(r.k), l);
extent_save(b, _l->k, l.k); extent_save(b, _l->k, l.k);
} }
} }
extent_sort_advance_prev(f, &nr, dst->start, &prev); dst->u64s = cpu_to_le16((u64 *) out - dst->_data);
dst->u64s = cpu_to_le16((u64 *) prev - dst->_data);
bkey_on_stack_exit(&split, c); bkey_on_stack_exit(&split, c);
return nr; return nr;
......
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