Commit 6988e85b authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Trust inode in btree over bch_inode_info

This is the start of some refactoring work to make less code depend on
the linux VFS - here the inode cache - to make e.g. the fuse port
easier.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 21ad9dde
...@@ -156,9 +156,8 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans, ...@@ -156,9 +156,8 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans,
{ {
struct btree_iter *iter = NULL; struct btree_iter *iter = NULL;
struct bkey_inode_buf *inode_p; struct bkey_inode_buf *inode_p;
int ret; struct bkey_s_c k;
int ret = 0;
lockdep_assert_held(&inode->ei_update_lock);
iter = bch2_trans_get_iter(trans, BTREE_ID_INODES, iter = bch2_trans_get_iter(trans, BTREE_ID_INODES,
POS(inode->v.i_ino, 0), POS(inode->v.i_ino, 0),
...@@ -166,12 +165,17 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans, ...@@ -166,12 +165,17 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans,
if (IS_ERR(iter)) if (IS_ERR(iter))
return PTR_ERR(iter); return PTR_ERR(iter);
/* The btree node lock is our lock on the inode: */ k = bch2_btree_iter_peek_slot(iter);
ret = bch2_btree_iter_traverse(iter); ret = bkey_err(k);
if (ret) if (ret)
return ret; return ret;
*inode_u = inode->ei_inode; if (k.k->type != KEY_TYPE_inode)
return -EIO;
ret = bch2_inode_unpack(bkey_s_c_to_inode(k), inode_u);
if (ret)
return ret;
if (set) { if (set) {
ret = set(inode, inode_u, p); ret = set(inode, inode_u, p);
...@@ -185,7 +189,6 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans, ...@@ -185,7 +189,6 @@ int __must_check bch2_write_inode_trans(struct btree_trans *trans,
bch2_inode_pack(inode_p, inode_u); bch2_inode_pack(inode_p, inode_u);
bch2_trans_update(trans, iter, &inode_p->inode.k_i); bch2_trans_update(trans, iter, &inode_p->inode.k_i);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment