diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-23 22:13:19 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:48 -0400 |
commit | 994ba475433a9395cb71e2ffb1928ce9fdb98e80 (patch) | |
tree | 17b68d33648215991336796bedd4174d58a730c3 /fs/bcachefs/lru.c | |
parent | a16b19cd1d91366e38c06f1195437b200b32e980 (diff) | |
download | linux-994ba475433a9395cb71e2ffb1928ce9fdb98e80.tar.gz linux-994ba475433a9395cb71e2ffb1928ce9fdb98e80.tar.bz2 linux-994ba475433a9395cb71e2ffb1928ce9fdb98e80.zip |
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/lru.c')
-rw-r--r-- | fs/bcachefs/lru.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/fs/bcachefs/lru.c b/fs/bcachefs/lru.c index db1674ef1d22..e16686b3b45a 100644 --- a/fs/bcachefs/lru.c +++ b/fs/bcachefs/lru.c @@ -101,14 +101,12 @@ int bch2_lru_set(struct btree_trans *trans, u64 lru_id, u64 idx, u64 *time) BUG_ON(iter.pos.inode != lru_id); *time = iter.pos.offset; - lru = bch2_trans_kmalloc(trans, sizeof(*lru)); + lru = bch2_bkey_alloc(trans, &iter, lru); ret = PTR_ERR_OR_ZERO(lru); if (ret) goto err; - bkey_lru_init(&lru->k_i); - lru->k.p = iter.pos; - lru->v.idx = cpu_to_le64(idx); + lru->v.idx = cpu_to_le64(idx); ret = bch2_trans_update(trans, &iter, &lru->k_i, 0); if (ret) @@ -164,17 +162,7 @@ static int bch2_check_lru_key(struct btree_trans *trans, " for %s", (bch2_bkey_val_to_text(&buf1, c, lru_k), buf1.buf), (bch2_bkey_val_to_text(&buf2, c, k), buf2.buf))) { - struct bkey_i *update = - bch2_trans_kmalloc(trans, sizeof(*update)); - - ret = PTR_ERR_OR_ZERO(update); - if (ret) - goto err; - - bkey_init(&update->k); - update->k.p = lru_iter->pos; - - ret = bch2_trans_update(trans, lru_iter, update, 0); + ret = bch2_btree_delete_at(trans, lru_iter, 0); if (ret) goto err; } |