diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-11-09 16:01:15 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:32 -0400 |
commit | 35189e09ab46785746df7007ed2a57ee78b56191 (patch) | |
tree | 8ef014d34714c88f3d0942a7ec3efb7358f07144 /fs/bcachefs/extents.c | |
parent | 03c8c747a0f2ee5f2b45ad692d51f6e2bdce21cb (diff) | |
download | lwn-35189e09ab46785746df7007ed2a57ee78b56191.tar.gz lwn-35189e09ab46785746df7007ed2a57ee78b56191.zip |
bcachefs: bkey_on_stack
This implements code for storing small bkeys on the stack and allocating
out of a mempool if they're too big.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.c')
-rw-r--r-- | fs/bcachefs/extents.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index b12798103763..46eeaa574e86 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -8,6 +8,7 @@ #include "bcachefs.h" #include "bkey_methods.h" +#include "bkey_on_stack.h" #include "btree_gc.h" #include "btree_update.h" #include "btree_update_interior.h" @@ -1132,7 +1133,11 @@ extent_squash(struct bch_fs *c, struct btree_iter *iter, break; } case BCH_EXTENT_OVERLAP_MIDDLE: { - BKEY_PADDED(k) split; + struct bkey_on_stack split; + + bkey_on_stack_init(&split); + bkey_on_stack_realloc(&split, c, k.k->u64s); + /* * The insert key falls 'in the middle' of k * The insert key splits k in 3: @@ -1147,18 +1152,19 @@ extent_squash(struct bch_fs *c, struct btree_iter *iter, * modify k _before_ doing the insert (which will move * what k points to) */ - bkey_reassemble(&split.k, k.s_c); - split.k.k.needs_whiteout |= bkey_written(l->b, _k); + bkey_reassemble(split.k, k.s_c); + split.k->k.needs_whiteout |= bkey_written(l->b, _k); - bch2_cut_back(bkey_start_pos(&insert->k), &split.k.k); - BUG_ON(bkey_deleted(&split.k.k)); + bch2_cut_back(bkey_start_pos(&insert->k), &split.k->k); + BUG_ON(bkey_deleted(&split.k->k)); __bch2_cut_front(insert->k.p, k); BUG_ON(bkey_deleted(k.k)); extent_save(l->b, _k, k.k); bch2_btree_iter_fix_key_modified(iter, l->b, _k); - extent_bset_insert(c, iter, &split.k); + extent_bset_insert(c, iter, split.k); + bkey_on_stack_exit(&split, c); break; } } |