aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-06 23:41:46 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-13 21:22:23 -0400
commit0b498a5a3960e8a9a3411c12fad77ef769ed3c1e (patch)
tree770fff7e6831eb931cfd46f0f482bd2537fc677d
parent971a1503a2220f7e3e4a29e1778949ce84a4ac03 (diff)
downloadvfs-0b498a5a3960e8a9a3411c12fad77ef769ed3c1e.tar.gz
bcachefs: check bi_parent_subvol in check_inode()
check for inodes with a nonzero bi_parent_subvol field that aren't actually subvolume roots Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/fsck.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index 5b059b4fff8c0..cb20a3d3f44ae 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -1009,6 +1009,16 @@ static int check_inode(struct btree_trans *trans,
goto err;
}
+ if (fsck_err_on(u.bi_parent_subvol &&
+ (u.bi_subvol == 0 ||
+ u.bi_subvol == BCACHEFS_ROOT_SUBVOL),
+ c, inode_bi_parent_subvol_nonzero,
+ "inode %llu:%u has subvol %u but nonzero parent subvol %u",
+ u.bi_inum, k.k->p.snapshot, u.bi_subvol, u.bi_parent_subvol)) {
+ u.bi_parent_subvol = 0;
+ do_update = true;
+ }
+
if (u.bi_subvol) {
struct bch_subvolume s;