summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fsck.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-16 21:19:08 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:10:07 +0300
commita57f4d611320a38b1985b2e5ba342d923b35964f (patch)
tree6fe10253c0b7076b0db4c0f2713599dd5c065311 /fs/bcachefs/fsck.c
parent0d8f320dd7e8fb4f1ac125f168e939b952ca3f8c (diff)
downloadlinux-a57f4d611320a38b1985b2e5ba342d923b35964f.tar.xz
bcachefs: fsck: walk_inode() now takes is_whiteout
We only want to synthesize an inode for the current snapshot ID for non whiteouts - this refactoring lets us call walk_inode() earlier and clean up some control flow. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r--fs/bcachefs/fsck.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index aa11f33c2384..f3e3cf475c23 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -675,8 +675,8 @@ static int get_inodes_all_snapshots(struct btree_trans *trans,
}
static struct inode_walker_entry *
-lookup_inode_for_snapshot(struct bch_fs *c,
- struct inode_walker *w, u32 snapshot)
+lookup_inode_for_snapshot(struct bch_fs *c, struct inode_walker *w,
+ u32 snapshot, bool is_whiteout)
{
struct inode_walker_entry *i;
@@ -690,7 +690,7 @@ lookup_inode_for_snapshot(struct bch_fs *c,
found:
BUG_ON(snapshot > i->snapshot);
- if (snapshot != i->snapshot) {
+ if (snapshot != i->snapshot && !is_whiteout) {
struct inode_walker_entry new = *i;
int ret;
@@ -712,7 +712,8 @@ found:
}
static struct inode_walker_entry *walk_inode(struct btree_trans *trans,
- struct inode_walker *w, struct bpos pos)
+ struct inode_walker *w, struct bpos pos,
+ bool is_whiteout)
{
if (w->last_pos.inode != pos.inode) {
int ret = get_inodes_all_snapshots(trans, w, pos.inode);
@@ -728,7 +729,7 @@ static struct inode_walker_entry *walk_inode(struct btree_trans *trans,
w->last_pos = pos;
- return lookup_inode_for_snapshot(trans->c, w, pos.snapshot);
+ return lookup_inode_for_snapshot(trans->c, w, pos.snapshot, is_whiteout);
}
static int __get_visible_inodes(struct btree_trans *trans,
@@ -1359,6 +1360,11 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
extent_ends_reset(extent_ends);
}
+ i = walk_inode(trans, inode, equiv, k.k->type == KEY_TYPE_whiteout);
+ ret = PTR_ERR_OR_ZERO(i);
+ if (ret)
+ goto err;
+
ret = check_overlapping_extents(trans, s, extent_ends, k, iter);
if (ret < 0)
goto err;
@@ -1370,11 +1376,6 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
if (ret)
goto err;
- i = walk_inode(trans, inode, equiv);
- ret = PTR_ERR_OR_ZERO(i);
- if (ret)
- goto err;
-
if (fsck_err_on(!i, c,
"extent in missing inode:\n %s",
(printbuf_reset(&buf),
@@ -1682,7 +1683,7 @@ static int check_dirent(struct btree_trans *trans, struct btree_iter *iter,
BUG_ON(!iter->path->should_be_locked);
- i = walk_inode(trans, dir, equiv);
+ i = walk_inode(trans, dir, equiv, k.k->type == KEY_TYPE_whiteout);
ret = PTR_ERR_OR_ZERO(i);
if (ret < 0)
goto err;
@@ -1859,7 +1860,7 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
if (ret)
return ret;
- i = walk_inode(trans, inode, k.k->p);
+ i = walk_inode(trans, inode, k.k->p, k.k->type == KEY_TYPE_whiteout);
ret = PTR_ERR_OR_ZERO(i);
if (ret)
return ret;