summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_update_leaf.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-24 06:13:19 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:48 +0300
commit994ba475433a9395cb71e2ffb1928ce9fdb98e80 (patch)
tree17b68d33648215991336796bedd4174d58a730c3 /fs/bcachefs/btree_update_leaf.c
parenta16b19cd1d91366e38c06f1195437b200b32e980 (diff)
downloadlinux-994ba475433a9395cb71e2ffb1928ce9fdb98e80.tar.xz
bcachefs: New btree helpers
This introduces some new conveniences, to help cut down on boilerplate: - bch2_trans_kmalloc_nomemzero() - performance optimiation - bch2_bkey_make_mut() - bch2_bkey_get_mut() - bch2_bkey_get_mut_typed() - bch2_bkey_alloc() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_update_leaf.c')
-rw-r--r--fs/bcachefs/btree_update_leaf.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index f986f1774b51..ca15ed33a204 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -1196,13 +1196,11 @@ static noinline int extent_front_merge(struct btree_trans *trans,
struct bkey_i *update;
int ret;
- update = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
+ update = bch2_bkey_make_mut(trans, k);
ret = PTR_ERR_OR_ZERO(update);
if (ret)
return ret;
- bkey_reassemble(update, k);
-
if (!bch2_bkey_merge(c, bkey_i_to_s(update), bkey_i_to_s_c(*insert)))
return 0;
@@ -1287,12 +1285,10 @@ int bch2_trans_update_extent(struct btree_trans *trans,
trans->extra_journal_res += compressed_sectors;
if (front_split) {
- update = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
+ update = bch2_bkey_make_mut(trans, k);
if ((ret = PTR_ERR_OR_ZERO(update)))
goto err;
- bkey_reassemble(update, k);
-
bch2_cut_back(start, update);
bch2_trans_iter_init(trans, &update_iter, btree_id, update->k.p,
@@ -1311,12 +1307,10 @@ int bch2_trans_update_extent(struct btree_trans *trans,
if (k.k->p.snapshot != insert->k.p.snapshot &&
(front_split || back_split)) {
- update = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
+ update = bch2_bkey_make_mut(trans, k);
if ((ret = PTR_ERR_OR_ZERO(update)))
goto err;
- bkey_reassemble(update, k);
-
bch2_cut_front(start, update);
bch2_cut_back(insert->k.p, update);
@@ -1360,11 +1354,10 @@ int bch2_trans_update_extent(struct btree_trans *trans,
}
if (back_split) {
- update = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
+ update = bch2_bkey_make_mut(trans, k);
if ((ret = PTR_ERR_OR_ZERO(update)))
goto err;
- bkey_reassemble(update, k);
bch2_cut_front(insert->k.p, update);
ret = bch2_trans_update_by_path(trans, iter.path, update,