summaryrefslogtreecommitdiff
path: root/fs/bcachefs/inode.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-03-25 15:10:15 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:18 -0400
commit424eb881300467a21a108d04c9dd08a6f8c007dc (patch)
tree760482adf8b16aa98b03932d5fabaab8e514c998 /fs/bcachefs/inode.c
parent5df4be3f62c9bde73db801504b3db2693b28328c (diff)
downloadlwn-424eb881300467a21a108d04c9dd08a6f8c007dc.tar.gz
lwn-424eb881300467a21a108d04c9dd08a6f8c007dc.zip
bcachefs: Only get btree iters from btree transactions
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/inode.c')
-rw-r--r--fs/bcachefs/inode.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 811c917cba84..c6336e7a2a23 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -447,13 +447,15 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr)
int bch2_inode_find_by_inum(struct bch_fs *c, u64 inode_nr,
struct bch_inode_unpacked *inode)
{
- struct btree_iter iter;
+ struct btree_trans trans;
+ struct btree_iter *iter;
struct bkey_s_c k;
int ret = -ENOENT;
- for_each_btree_key(&iter, c, BTREE_ID_INODES,
- POS(inode_nr, 0),
- BTREE_ITER_SLOTS, k) {
+ bch2_trans_init(&trans, c);
+
+ for_each_btree_key(&trans, iter, BTREE_ID_INODES,
+ POS(inode_nr, 0), BTREE_ITER_SLOTS, k) {
switch (k.k->type) {
case KEY_TYPE_inode:
ret = bch2_inode_unpack(bkey_s_c_to_inode(k), inode);
@@ -466,7 +468,7 @@ int bch2_inode_find_by_inum(struct bch_fs *c, u64 inode_nr,
break;
}
- return bch2_btree_iter_unlock(&iter) ?: ret;
+ return bch2_trans_exit(&trans) ?: ret;
}
#ifdef CONFIG_BCACHEFS_DEBUG