Skip to content

Commit c1ca07a

Browse files
author
Kent Overstreet
committed
bcachefs: fsck: Fix remove_backpointer() for subvol roots
The dirent will be in a different snapshot if the inode is a subvolume root. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 7029cc4 commit c1ca07a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

fs/bcachefs/fsck.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,18 @@ static int remove_backpointer(struct btree_trans *trans,
493493
if (!inode->bi_dir)
494494
return 0;
495495

496+
u32 snapshot = inode->bi_snapshot;
497+
498+
if (inode->bi_parent_subvol) {
499+
int ret = bch2_subvolume_get_snapshot(trans, inode->bi_parent_subvol, &snapshot);
500+
if (ret)
501+
return ret;
502+
}
503+
496504
struct bch_fs *c = trans->c;
497505
struct btree_iter iter;
498506
struct bkey_s_c_dirent d = dirent_get_by_pos(trans, &iter,
499-
SPOS(inode->bi_dir, inode->bi_dir_offset, inode->bi_snapshot));
507+
SPOS(inode->bi_dir, inode->bi_dir_offset, snapshot));
500508
int ret = bkey_err(d) ?:
501509
dirent_points_to_inode(c, d, inode) ?:
502510
bch2_fsck_remove_dirent(trans, d.k->p);

0 commit comments

Comments
 (0)