diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-09-06 15:38:12 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:11 -0400 |
commit | cf3c68cda684b41bcdd4d9a8dba4abd4abb32881 (patch) | |
tree | 1c921e9f2401846dcdb2db1fb80ea003d87f36df /fs/bcachefs/btree_update_leaf.c | |
parent | 22b383ad7e1928de8da14d66a7154a9bfebf9a46 (diff) | |
download | lwn-cf3c68cda684b41bcdd4d9a8dba4abd4abb32881.tar.gz lwn-cf3c68cda684b41bcdd4d9a8dba4abd4abb32881.zip |
bcachefs: No need to clone iterators for update
Since btree_path is now internally refcounted, we don't need to clone an
iterator before calling bch2_trans_update() if we'll be mutating it.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_update_leaf.c')
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index dfa1086e5247..310442fcc37f 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -875,12 +875,7 @@ static noinline int extent_front_merge(struct btree_trans *trans, bkey_reassemble(update, k); if (bch2_bkey_merge(c, bkey_i_to_s(update), bkey_i_to_s_c(*insert))) { - struct btree_iter update_iter; - - bch2_trans_copy_iter(&update_iter, iter); - ret = bch2_btree_delete_at(trans, &update_iter, flags); - bch2_trans_iter_exit(trans, &update_iter); - + ret = bch2_btree_delete_at(trans, iter, flags); if (ret) return ret; @@ -959,10 +954,7 @@ static int bch2_trans_update_extent(struct btree_trans *trans, } if (bkey_cmp(k.k->p, insert->k.p) <= 0) { - bch2_trans_copy_iter(&update_iter, &iter); - ret = bch2_btree_delete_at(trans, &update_iter, flags); - bch2_trans_iter_exit(trans, &update_iter); - + ret = bch2_btree_delete_at(trans, &iter, flags); if (ret) goto err; } @@ -975,9 +967,10 @@ static int bch2_trans_update_extent(struct btree_trans *trans, bkey_reassemble(update, k); bch2_cut_front(insert->k.p, update); - bch2_trans_copy_iter(&update_iter, &iter); - bch2_trans_update(trans, &update_iter, update, flags); - bch2_trans_iter_exit(trans, &update_iter); + ret = bch2_trans_update(trans, &iter, update, flags); + if (ret) + goto err; + goto out; } next: @@ -1081,8 +1074,7 @@ int __bch2_btree_insert(struct btree_trans *trans, int ret; bch2_trans_iter_init(trans, &iter, id, bkey_start_pos(&k->k), - BTREE_ITER_INTENT); - + BTREE_ITER_INTENT); ret = bch2_btree_iter_traverse(&iter) ?: bch2_trans_update(trans, &iter, k, 0); bch2_trans_iter_exit(trans, &iter); |