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: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@ -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;
|
|
||||||
|
|
||||||
if (!k.k || !bkey_eq(k.k->p, POS(0, inode_nr))) {
|
|
||||||
ret = -BCH_ERR_ENOENT_inode;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = bch2_inode_unpack(k, inode);
|
ret = bch2_inode_unpack(k, inode);
|
||||||
err:
|
goto found;
|
||||||
|
}
|
||||||
|
ret = -BCH_ERR_ENOENT_inode;
|
||||||
|
found:
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user