summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/fsck.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-13 07:41:02 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:10:07 +0200
commit0d8f320dd7e8fb4f1ac125f168e939b952ca3f8c (patch)
treef560862dec132086b85ddc6b022bbb38580a9342 /fs/bcachefs/fsck.c
parentbcachefs: overlapping_extents_found() (diff)
downloadlinux-0d8f320dd7e8fb4f1ac125f168e939b952ca3f8c.tar.xz
linux-0d8f320dd7e8fb4f1ac125f168e939b952ca3f8c.zip
bcachefs: Simplify check_extent()
Minor refactoring/dead code deletion, prep work for reworking check_extent() to avoid key_visible_in_snapshot(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r--fs/bcachefs/fsck.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index e14e950fcdbc..aa11f33c2384 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -1333,18 +1333,17 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
struct bch_fs *c = trans->c;
struct inode_walker_entry *i;
struct printbuf buf = PRINTBUF;
- struct bpos equiv;
+ struct bpos equiv = k.k->p;
int ret = 0;
+ equiv.snapshot = bch2_snapshot_equiv(c, k.k->p.snapshot);
+
ret = check_key_has_snapshot(trans, iter, k);
if (ret) {
ret = ret < 0 ? ret : 0;
goto out;
}
- equiv = k.k->p;
- equiv.snapshot = bch2_snapshot_equiv(c, k.k->p.snapshot);
-
ret = snapshots_seen_update(c, s, iter->btree_id, k.k->p);
if (ret)
goto err;
@@ -1360,8 +1359,6 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
extent_ends_reset(extent_ends);
}
- BUG_ON(!iter->path->should_be_locked);
-
ret = check_overlapping_extents(trans, s, extent_ends, k, iter);
if (ret < 0)
goto err;
@@ -1381,11 +1378,8 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
if (fsck_err_on(!i, c,
"extent in missing inode:\n %s",
(printbuf_reset(&buf),
- bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
- ret = bch2_btree_delete_at(trans, iter,
- BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
- goto out;
- }
+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
+ goto delete;
if (!i)
goto out;
@@ -1395,11 +1389,8 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
"extent in non regular inode mode %o:\n %s",
i->inode.bi_mode,
(printbuf_reset(&buf),
- bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
- ret = bch2_btree_delete_at(trans, iter,
- BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
- goto out;
- }
+ bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
+ goto delete;
/*
* Check inodes in reverse order, from oldest snapshots to newest, so
@@ -1440,10 +1431,6 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
if (bkey_extent_is_allocation(k.k))
for_each_visible_inode(c, s, inode, equiv.snapshot, i)
i->count += k.k->size;
-#if 0
- bch2_bkey_buf_reassemble(&prev, c, k);
-#endif
-
out:
err:
fsck_err:
@@ -1452,6 +1439,9 @@ fsck_err:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err_fn(c, ret);
return ret;
+delete:
+ ret = bch2_btree_delete_at(trans, iter, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
+ goto out;
}
/*