Commit 4eb3877e authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: fsck -> bch2_trans_run()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent cea07a7b
...@@ -973,21 +973,19 @@ static int check_inode(struct btree_trans *trans, ...@@ -973,21 +973,19 @@ static int check_inode(struct btree_trans *trans,
int bch2_check_inodes(struct bch_fs *c) int bch2_check_inodes(struct bch_fs *c)
{ {
bool full = c->opts.fsck; bool full = c->opts.fsck;
struct btree_trans *trans = bch2_trans_get(c);
struct bch_inode_unpacked prev = { 0 }; struct bch_inode_unpacked prev = { 0 };
struct snapshots_seen s; struct snapshots_seen s;
int ret;
snapshots_seen_init(&s); snapshots_seen_init(&s);
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_inodes, int ret = bch2_trans_run(c,
POS_MIN, for_each_btree_key_commit(trans, iter, BTREE_ID_inodes,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, POS_MIN,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
check_inode(trans, &iter, k, &prev, &s, full)); NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
check_inode(trans, &iter, k, &prev, &s, full)));
snapshots_seen_exit(&s); snapshots_seen_exit(&s);
bch2_trans_put(trans);
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1417,30 +1415,28 @@ int bch2_check_extents(struct bch_fs *c) ...@@ -1417,30 +1415,28 @@ int bch2_check_extents(struct bch_fs *c)
{ {
struct inode_walker w = inode_walker_init(); struct inode_walker w = inode_walker_init();
struct snapshots_seen s; struct snapshots_seen s;
struct btree_trans *trans = bch2_trans_get(c);
struct extent_ends extent_ends; struct extent_ends extent_ends;
struct disk_reservation res = { 0 }; struct disk_reservation res = { 0 };
int ret = 0;
snapshots_seen_init(&s); snapshots_seen_init(&s);
extent_ends_init(&extent_ends); extent_ends_init(&extent_ends);
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_extents, int ret = bch2_trans_run(c,
POS(BCACHEFS_ROOT_INO, 0), for_each_btree_key_commit(trans, iter, BTREE_ID_extents,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, POS(BCACHEFS_ROOT_INO, 0),
&res, NULL, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
BCH_TRANS_COMMIT_no_enospc, ({ &res, NULL,
bch2_disk_reservation_put(c, &res); BCH_TRANS_COMMIT_no_enospc, ({
check_extent(trans, &iter, k, &w, &s, &extent_ends) ?: bch2_disk_reservation_put(c, &res);
check_extent_overbig(trans, &iter, k); check_extent(trans, &iter, k, &w, &s, &extent_ends) ?:
})) ?: check_extent_overbig(trans, &iter, k);
check_i_sectors(trans, &w); })) ?:
check_i_sectors(trans, &w));
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
extent_ends_exit(&extent_ends); extent_ends_exit(&extent_ends);
inode_walker_exit(&w); inode_walker_exit(&w);
snapshots_seen_exit(&s); snapshots_seen_exit(&s);
bch2_trans_put(trans);
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
...@@ -1448,22 +1444,19 @@ int bch2_check_extents(struct bch_fs *c) ...@@ -1448,22 +1444,19 @@ int bch2_check_extents(struct bch_fs *c)
int bch2_check_indirect_extents(struct bch_fs *c) int bch2_check_indirect_extents(struct bch_fs *c)
{ {
struct btree_trans *trans = bch2_trans_get(c);
struct disk_reservation res = { 0 }; struct disk_reservation res = { 0 };
int ret = 0;
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_reflink, int ret = bch2_trans_run(c,
POS_MIN, for_each_btree_key_commit(trans, iter, BTREE_ID_reflink,
BTREE_ITER_PREFETCH, k, POS_MIN,
&res, NULL, BTREE_ITER_PREFETCH, k,
BCH_TRANS_COMMIT_no_enospc, ({ &res, NULL,
bch2_disk_reservation_put(c, &res); BCH_TRANS_COMMIT_no_enospc, ({
check_extent_overbig(trans, &iter, k); bch2_disk_reservation_put(c, &res);
})); check_extent_overbig(trans, &iter, k);
})));
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
bch2_trans_put(trans);
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1816,20 +1809,18 @@ int bch2_check_dirents(struct bch_fs *c) ...@@ -1816,20 +1809,18 @@ int bch2_check_dirents(struct bch_fs *c)
struct inode_walker target = inode_walker_init(); struct inode_walker target = inode_walker_init();
struct snapshots_seen s; struct snapshots_seen s;
struct bch_hash_info hash_info; struct bch_hash_info hash_info;
struct btree_trans *trans = bch2_trans_get(c);
int ret = 0;
snapshots_seen_init(&s); snapshots_seen_init(&s);
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_dirents, int ret = bch2_trans_run(c,
POS(BCACHEFS_ROOT_INO, 0), for_each_btree_key_commit(trans, iter, BTREE_ID_dirents,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, POS(BCACHEFS_ROOT_INO, 0),
k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS,
NULL, NULL, k,
BCH_TRANS_COMMIT_no_enospc, NULL, NULL,
check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)); BCH_TRANS_COMMIT_no_enospc,
check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)));
bch2_trans_put(trans);
snapshots_seen_exit(&s); snapshots_seen_exit(&s);
inode_walker_exit(&dir); inode_walker_exit(&dir);
inode_walker_exit(&target); inode_walker_exit(&target);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment