bcachefs: Don't use bkey cache for inode update in fsck

fsck doesn't know about the btree key cache, and non-cached iterators
aren't cache coherent (yet?)

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2020-11-20 21:21:28 -05:00 committed by Kent Overstreet
parent f302055077
commit 6584e84a97
4 changed files with 13 additions and 7 deletions

View File

@ -1262,7 +1262,7 @@ static void bch2_evict_inode(struct inode *vinode)
KEY_TYPE_QUOTA_WARN); KEY_TYPE_QUOTA_WARN);
bch2_quota_acct(c, inode->ei_qid, Q_INO, -1, bch2_quota_acct(c, inode->ei_qid, Q_INO, -1,
KEY_TYPE_QUOTA_WARN); KEY_TYPE_QUOTA_WARN);
bch2_inode_rm(c, inode->v.i_ino); bch2_inode_rm(c, inode->v.i_ino, true);
} }
} }

View File

@ -1254,7 +1254,7 @@ static int check_inode(struct btree_trans *trans,
bch2_fs_lazy_rw(c); bch2_fs_lazy_rw(c);
ret = bch2_inode_rm(c, u.bi_inum); ret = bch2_inode_rm(c, u.bi_inum, false);
if (ret) if (ret)
bch_err(c, "error in fsck: error %i while deleting inode", ret); bch_err(c, "error in fsck: error %i while deleting inode", ret);
return ret; return ret;

View File

@ -542,7 +542,7 @@ found_slot:
return ret; return ret;
} }
int bch2_inode_rm(struct bch_fs *c, u64 inode_nr) int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached)
{ {
struct btree_trans trans; struct btree_trans trans;
struct btree_iter *iter; struct btree_iter *iter;
@ -576,9 +576,15 @@ retry:
bi_generation = 0; bi_generation = 0;
iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr), if (cached) {
BTREE_ITER_CACHED|BTREE_ITER_INTENT); iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
k = bch2_btree_iter_peek_cached(iter); BTREE_ITER_CACHED|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_cached(iter);
} else {
iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter);
}
ret = bkey_err(k); ret = bkey_err(k);
if (ret) if (ret)

View File

@ -71,7 +71,7 @@ void bch2_inode_init(struct bch_fs *, struct bch_inode_unpacked *,
int bch2_inode_create(struct btree_trans *, struct bch_inode_unpacked *); int bch2_inode_create(struct btree_trans *, struct bch_inode_unpacked *);
int bch2_inode_rm(struct bch_fs *, u64); int bch2_inode_rm(struct bch_fs *, u64, bool);
int bch2_inode_find_by_inum_trans(struct btree_trans *, u64, int bch2_inode_find_by_inum_trans(struct btree_trans *, u64,
struct bch_inode_unpacked *); struct bch_inode_unpacked *);