Commit 0b0f0ad9 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: remove_backpointer() now checks if dirent points to inode

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a6508079
...@@ -389,14 +389,17 @@ static int reattach_inode(struct btree_trans *trans, ...@@ -389,14 +389,17 @@ static int reattach_inode(struct btree_trans *trans,
static int remove_backpointer(struct btree_trans *trans, static int remove_backpointer(struct btree_trans *trans,
struct bch_inode_unpacked *inode) struct bch_inode_unpacked *inode)
{ {
struct btree_iter iter; if (!inode->bi_dir)
struct bkey_s_c_dirent d; return 0;
int ret;
d = bch2_bkey_get_iter_typed(trans, &iter, BTREE_ID_dirents, struct bch_fs *c = trans->c;
POS(inode->bi_dir, inode->bi_dir_offset), 0, 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); dirent);
ret = bkey_err(d) ?: int ret = bkey_err(d) ?:
dirent_points_to_inode(c, d, inode) ?:
__remove_dirent(trans, d.k->p); __remove_dirent(trans, d.k->p);
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
return ret; return ret;
......
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