Commit 9e1a66e6 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix lookup_first_inode() when inode_generations are present

This function is used for finding the hash seed (which is the same in
all versions of an inode in different snapshots): ff an inode has been
deleted in a child snapshot we need to iterate until we find a live
version.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 1292bc2e
...@@ -77,21 +77,17 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr, ...@@ -77,21 +77,17 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr,
struct bkey_s_c k; struct bkey_s_c k;
int ret; int ret;
bch2_trans_iter_init(trans, &iter, BTREE_ID_inodes, for_each_btree_key_norestart(trans, iter, BTREE_ID_inodes, POS(0, inode_nr),
POS(0, inode_nr), BTREE_ITER_all_snapshots, k, ret) {
BTREE_ITER_all_snapshots); if (k.k->p.offset != inode_nr)
k = bch2_btree_iter_peek(&iter); break;
ret = bkey_err(k); if (!bkey_is_inode(k.k))
if (ret) continue;
goto err; ret = bch2_inode_unpack(k, inode);
goto found;
if (!k.k || !bkey_eq(k.k->p, POS(0, inode_nr))) {
ret = -BCH_ERR_ENOENT_inode;
goto err;
} }
ret = -BCH_ERR_ENOENT_inode;
ret = bch2_inode_unpack(k, inode); found:
err:
bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr); bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr);
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
return ret; return ret;
......
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