bcachefs: Don't use inode btree key cache in fsck code
We had a cache coherency bug with the btree key cache in the fsck code - this fixes fsck to be consistent about not using it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
bcdb4b9732
commit
fe38b72086
@ -58,7 +58,7 @@ static int __remove_dirent(struct btree_trans *trans,
|
||||
buf[name.len] = '\0';
|
||||
name.name = buf;
|
||||
|
||||
ret = bch2_inode_find_by_inum_trans(trans, dir_inum, &dir_inode);
|
||||
ret = __bch2_inode_find_by_inum_trans(trans, dir_inum, &dir_inode, 0);
|
||||
if (ret && ret != -EINTR)
|
||||
bch_err(c, "remove_dirent: err %i looking up directory inode", ret);
|
||||
if (ret)
|
||||
@ -126,8 +126,8 @@ static int walk_inode(struct btree_trans *trans,
|
||||
struct inode_walker *w, u64 inum)
|
||||
{
|
||||
if (inum != w->cur_inum) {
|
||||
int ret = bch2_inode_find_by_inum_trans(trans, inum,
|
||||
&w->inode);
|
||||
int ret = __bch2_inode_find_by_inum_trans(trans, inum,
|
||||
&w->inode, 0);
|
||||
|
||||
if (ret && ret != -ENOENT)
|
||||
return ret;
|
||||
@ -673,7 +673,7 @@ retry:
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = bch2_inode_find_by_inum_trans(&trans, d_inum, &target);
|
||||
ret = __bch2_inode_find_by_inum_trans(&trans, d_inum, &target, 0);
|
||||
if (ret && ret != -ENOENT)
|
||||
break;
|
||||
|
||||
@ -787,7 +787,9 @@ static int check_root(struct bch_fs *c, struct bch_inode_unpacked *root_inode)
|
||||
|
||||
bch_verbose(c, "checking root directory");
|
||||
|
||||
ret = bch2_inode_find_by_inum(c, BCACHEFS_ROOT_INO, root_inode);
|
||||
ret = bch2_trans_do(c, NULL, NULL, 0,
|
||||
__bch2_inode_find_by_inum_trans(&trans, BCACHEFS_ROOT_INO,
|
||||
root_inode, 0));
|
||||
if (ret && ret != -ENOENT)
|
||||
return ret;
|
||||
|
||||
@ -834,7 +836,8 @@ static int check_lostfound(struct bch_fs *c,
|
||||
goto create_lostfound;
|
||||
}
|
||||
|
||||
ret = bch2_inode_find_by_inum(c, inum, lostfound_inode);
|
||||
ret = bch2_trans_do(c, NULL, NULL, 0,
|
||||
__bch2_inode_find_by_inum_trans(&trans, inum, lostfound_inode, 0));
|
||||
if (ret && ret != -ENOENT)
|
||||
return ret;
|
||||
|
||||
|
@ -628,16 +628,19 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
|
||||
struct bch_inode_unpacked *inode)
|
||||
int __bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
|
||||
struct bch_inode_unpacked *inode,
|
||||
unsigned flags)
|
||||
{
|
||||
struct btree_iter *iter;
|
||||
struct bkey_s_c k;
|
||||
int ret;
|
||||
|
||||
iter = bch2_trans_get_iter(trans, BTREE_ID_INODES,
|
||||
POS(0, inode_nr), BTREE_ITER_CACHED);
|
||||
k = bch2_btree_iter_peek_cached(iter);
|
||||
POS(0, inode_nr), flags);
|
||||
k = (flags & BTREE_ITER_TYPE) == BTREE_ITER_CACHED
|
||||
? bch2_btree_iter_peek_cached(iter)
|
||||
: bch2_btree_iter_peek_slot(iter);
|
||||
ret = bkey_err(k);
|
||||
if (ret)
|
||||
goto err;
|
||||
@ -650,6 +653,14 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
|
||||
struct bch_inode_unpacked *inode)
|
||||
{
|
||||
return __bch2_inode_find_by_inum_trans(trans, inode_nr,
|
||||
inode, BTREE_ITER_CACHED);
|
||||
|
||||
}
|
||||
|
||||
int bch2_inode_find_by_inum(struct bch_fs *c, u64 inode_nr,
|
||||
struct bch_inode_unpacked *inode)
|
||||
{
|
||||
|
@ -73,6 +73,8 @@ int bch2_inode_create(struct btree_trans *, struct bch_inode_unpacked *);
|
||||
|
||||
int bch2_inode_rm(struct bch_fs *, u64, bool);
|
||||
|
||||
int __bch2_inode_find_by_inum_trans(struct btree_trans *, u64,
|
||||
struct bch_inode_unpacked *, unsigned);
|
||||
int bch2_inode_find_by_inum_trans(struct btree_trans *, u64,
|
||||
struct bch_inode_unpacked *);
|
||||
int bch2_inode_find_by_inum(struct bch_fs *, u64, struct bch_inode_unpacked *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user