diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-05 19:38:19 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-10 15:34:09 -0400 |
commit | 3d4998c202978e5389b660cdfa33299d531b3f4f (patch) | |
tree | 25d61ba19324498ae52a46235886f670c647bf84 /fs/bcachefs/fsck.c | |
parent | 11def1888f26e7ec373e85d77c5b425632ef175f (diff) | |
download | linux-stable-3d4998c202978e5389b660cdfa33299d531b3f4f.tar.gz linux-stable-3d4998c202978e5389b660cdfa33299d531b3f4f.tar.bz2 linux-stable-3d4998c202978e5389b660cdfa33299d531b3f4f.zip |
bcachefs: factor out check_inode_backpointer()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r-- | fs/bcachefs/fsck.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index f05896dcb4bd..24f8657370ce 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1461,16 +1461,15 @@ fsck_err: return ret ?: trans_was_restarted(trans, restart_count); } -static int check_dirent_target(struct btree_trans *trans, - struct btree_iter *iter, - struct bkey_s_c_dirent d, - struct bch_inode_unpacked *target, - u32 target_snapshot) +static int check_inode_backpointer(struct btree_trans *trans, + struct btree_iter *iter, + struct bkey_s_c_dirent d, + struct bch_inode_unpacked *target, + u32 target_snapshot) { struct bch_fs *c = trans->c; - struct bkey_i_dirent *n; - struct printbuf buf = PRINTBUF; struct btree_iter bp_iter = { NULL }; + struct printbuf buf = PRINTBUF; int ret = 0; if (!target->bi_dir && @@ -1541,6 +1540,29 @@ static int check_dirent_target(struct btree_trans *trans, goto err; } } +out: +err: +fsck_err: + bch2_trans_iter_exit(trans, &bp_iter); + printbuf_exit(&buf); + bch_err_fn(c, ret); + return ret; +} + +static int check_dirent_target(struct btree_trans *trans, + struct btree_iter *iter, + struct bkey_s_c_dirent d, + struct bch_inode_unpacked *target, + u32 target_snapshot) +{ + struct bch_fs *c = trans->c; + struct bkey_i_dirent *n; + struct printbuf buf = PRINTBUF; + int ret = 0; + + ret = check_inode_backpointer(trans, iter, d, target, target_snapshot); + if (ret) + goto err; if (fsck_err_on(d.v->d_type != inode_d_type(target), c, dirent_d_type_wrong, @@ -1584,10 +1606,8 @@ static int check_dirent_target(struct btree_trans *trans, d = dirent_i_to_s_c(n); } -out: err: fsck_err: - bch2_trans_iter_exit(trans, &bp_iter); printbuf_exit(&buf); bch_err_fn(c, ret); return ret; |