diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-03-24 17:00:48 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:37 -0400 |
commit | 47143a75e01354ee0daef6667cbe7b08bd89ed84 (patch) | |
tree | 909c094f8bff7ff662e6eb276f0f824f7e8e2328 /fs/bcachefs/bkey_sort.c | |
parent | 0728eed7b6ec673d2b6e0f86b6daf240a2948292 (diff) | |
download | linux-stable-47143a75e01354ee0daef6667cbe7b08bd89ed84.tar.gz linux-stable-47143a75e01354ee0daef6667cbe7b08bd89ed84.tar.bz2 linux-stable-47143a75e01354ee0daef6667cbe7b08bd89ed84.zip |
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: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey_sort.c')
-rw-r--r-- | fs/bcachefs/bkey_sort.c | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/fs/bcachefs/bkey_sort.c b/fs/bcachefs/bkey_sort.c index 68965a0f973a..839e78d1dc35 100644 --- a/fs/bcachefs/bkey_sort.c +++ b/fs/bcachefs/bkey_sort.c @@ -130,44 +130,21 @@ bch2_key_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, 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, struct bkey_format *f, struct btree_nr_keys *nr, - struct bkey_packed *start, - struct bkey_packed **prev, + struct bkey_packed **out, struct bkey_s k) { - if (bkey_whiteout(k.k)) - return; - - /* - * prev is always unpacked, for key merging - until right before we - * advance it: - */ + if (!bkey_whiteout(k.k)) { + if (!bch2_bkey_pack_key(*out, k.k, f)) + memcpy_u64s_small(*out, k.k, BKEY_U64s); - if (*prev && - bch2_bkey_merge(c, bkey_i_to_s((void *) *prev), k) == - BCH_MERGE_MERGE) - return; + memcpy_u64s_small(bkeyp_val(f, *out), k.v, bkey_val_u64s(k.k)); - extent_sort_advance_prev(f, nr, start, prev); - - bkey_reassemble((void *) *prev, k.s_c); + btree_keys_account_key_add(nr, 0, *out); + *out = bkey_next(*out); + } } /* Sort + repack in a new format: */ @@ -201,7 +178,7 @@ bch2_sort_repack(struct bset *dst, struct btree *src, return nr; } -/* Sort, repack, and merge: */ +/* Sort, repack, and call bch2_bkey_normalize() to drop stale pointers: */ struct btree_nr_keys bch2_sort_repack_merge(struct bch_fs *c, struct bset *dst, struct btree *src, @@ -209,7 +186,7 @@ bch2_sort_repack_merge(struct bch_fs *c, struct bkey_format *out_f, 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 btree_nr_keys nr; @@ -234,13 +211,10 @@ bch2_sort_repack_merge(struct bch_fs *c, bch2_bkey_normalize(c, bkey_i_to_s(k.k))) continue; - extent_sort_append(c, out_f, &nr, vstruct_last(dst), - &prev, bkey_i_to_s(k.k)); + extent_sort_append(c, out_f, &nr, &out, 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); + dst->u64s = cpu_to_le16((u64 *) out - dst->_data); bkey_on_stack_exit(&k, c); return nr; } @@ -337,7 +311,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, struct btree *b = iter->b; struct bkey_format *f = &b->format; 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_s l, r; struct btree_nr_keys nr; @@ -360,7 +334,7 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, l = __bkey_disassemble(b, _l->k, &l_unpacked); 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); continue; } @@ -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 (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); continue; } @@ -414,17 +388,15 @@ bch2_extent_sort_fix_overlapping(struct bch_fs *c, struct bset *dst, __sort_iter_sift(iter, 0, extent_sort_fix_overlapping_cmp); - extent_sort_append(c, f, &nr, dst->start, - &prev, bkey_i_to_s(split.k)); + extent_sort_append(c, f, &nr, &out, + bkey_i_to_s(split.k)); } else { bch2_cut_back_s(bkey_start_pos(r.k), l); extent_save(b, _l->k, l.k); } } - extent_sort_advance_prev(f, &nr, dst->start, &prev); - - dst->u64s = cpu_to_le16((u64 *) prev - dst->_data); + dst->u64s = cpu_to_le16((u64 *) out - dst->_data); bkey_on_stack_exit(&split, c); return nr; |