summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_gc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-23 22:13:19 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:48 -0400
commit994ba475433a9395cb71e2ffb1928ce9fdb98e80 (patch)
tree17b68d33648215991336796bedd4174d58a730c3 /fs/bcachefs/btree_gc.c
parenta16b19cd1d91366e38c06f1195437b200b32e980 (diff)
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_gc.c')
-rw-r--r--fs/bcachefs/btree_gc.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index d4a0e0a716c5..fdc9de6e9908 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -1578,15 +1578,12 @@ static int bch2_gc_write_reflink_key(struct btree_trans *trans,
" should be %u",
(bch2_bkey_val_to_text(&buf, c, k), buf.buf),
r->refcount)) {
- struct bkey_i *new;
+ struct bkey_i *new = bch2_bkey_make_mut(trans, k);
- new = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
ret = PTR_ERR_OR_ZERO(new);
if (ret)
return ret;
- bkey_reassemble(new, k);
-
if (!r->refcount)
new->k.type = KEY_TYPE_deleted;
else
@@ -1903,13 +1900,11 @@ static int gc_btree_gens_key(struct btree_trans *trans,
percpu_up_read(&c->mark_lock);
return 0;
update:
- u = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
+ u = bch2_bkey_make_mut(trans, k);
ret = PTR_ERR_OR_ZERO(u);
if (ret)
return ret;
- bkey_reassemble(u, k);
-
bch2_extent_normalize(c, bkey_i_to_s(u));
return bch2_trans_update(trans, iter, u, 0);
}