summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-11-20 21:21:28 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:48 -0400
commit6584e84a978ed710ee295201647b7f05dbbc56ee (patch)
tree066b416323624d61445752849a3f6f70d8c392d3 /fs
parentf3020550777af9a66737334db94d96f8c3253e96 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/fs.c2
-rw-r--r--fs/bcachefs/fsck.c2
-rw-r--r--fs/bcachefs/inode.c14
-rw-r--r--fs/bcachefs/inode.h2
4 files changed, 13 insertions, 7 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 480469784152..a3810493826b 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1262,7 +1262,7 @@ static void bch2_evict_inode(struct inode *vinode)
KEY_TYPE_QUOTA_WARN);
bch2_quota_acct(c, inode->ei_qid, Q_INO, -1,
KEY_TYPE_QUOTA_WARN);
- bch2_inode_rm(c, inode->v.i_ino);
+ bch2_inode_rm(c, inode->v.i_ino, true);
}
}
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index 0c5035270846..09ce6c29b88c 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -1254,7 +1254,7 @@ static int check_inode(struct btree_trans *trans,
bch2_fs_lazy_rw(c);
- ret = bch2_inode_rm(c, u.bi_inum);
+ ret = bch2_inode_rm(c, u.bi_inum, false);
if (ret)
bch_err(c, "error in fsck: error %i while deleting inode", ret);
return ret;
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index f00778d78271..b1f420776d9a 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -542,7 +542,7 @@ found_slot:
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_iter *iter;
@@ -576,9 +576,15 @@ retry:
bi_generation = 0;
- iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
- BTREE_ITER_CACHED|BTREE_ITER_INTENT);
- k = bch2_btree_iter_peek_cached(iter);
+ if (cached) {
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
+ 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);
if (ret)
diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h
index ef7e885dce0c..dbdfcf63d079 100644
--- a/fs/bcachefs/inode.h
+++ b/fs/bcachefs/inode.h
@@ -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_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,
struct bch_inode_unpacked *);