diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-09-24 04:27:13 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-09-28 04:32:23 +0200 |
commit | 0b0f0ad93c0833ed3b5457eb308274f340535988 (patch) | |
tree | 98b346037d5114d5a88bd6acbe52af86fa5fdfc6 /fs | |
parent | bcachefs: dirent_points_to_inode() now warns on mismatch (diff) | |
download | linux-0b0f0ad93c0833ed3b5457eb308274f340535988.tar.xz linux-0b0f0ad93c0833ed3b5457eb308274f340535988.zip |
bcachefs: remove_backpointer() now checks if dirent points to inode
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/fsck.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 0e397d0ef3dd..8f52911558a7 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -389,14 +389,17 @@ static int reattach_inode(struct btree_trans *trans, static int remove_backpointer(struct btree_trans *trans, struct bch_inode_unpacked *inode) { - struct btree_iter iter; - struct bkey_s_c_dirent d; - int ret; + if (!inode->bi_dir) + return 0; - d = bch2_bkey_get_iter_typed(trans, &iter, BTREE_ID_dirents, - POS(inode->bi_dir, inode->bi_dir_offset), 0, + struct bch_fs *c = trans->c; + struct btree_iter iter; + struct bkey_s_c_dirent d = + bch2_bkey_get_iter_typed(trans, &iter, BTREE_ID_dirents, + SPOS(inode->bi_dir, inode->bi_dir_offset, inode->bi_snapshot), 0, dirent); - ret = bkey_err(d) ?: + int ret = bkey_err(d) ?: + dirent_points_to_inode(c, d, inode) ?: __remove_dirent(trans, d.k->p); bch2_trans_iter_exit(trans, &iter); return ret; |