@@ -2371,22 +2371,6 @@ static bool darray_u32_has(darray_u32 *d, u32 v)
23712371 return false;
23722372}
23732373
2374- /*
2375- * We've checked that inode backpointers point to valid dirents; here, it's
2376- * sufficient to check that the subvolume root has a dirent:
2377- */
2378- static int subvol_has_dirent (struct btree_trans * trans , struct bkey_s_c_subvolume s )
2379- {
2380- struct bch_inode_unpacked inode ;
2381- int ret = bch2_inode_find_by_inum_trans (trans ,
2382- (subvol_inum ) { s .k -> p .offset , le64_to_cpu (s .v -> inode ) },
2383- & inode );
2384- if (ret )
2385- return ret ;
2386-
2387- return inode .bi_dir != 0 ;
2388- }
2389-
23902374static int check_subvol_path (struct btree_trans * trans , struct btree_iter * iter , struct bkey_s_c k )
23912375{
23922376 struct bch_fs * c = trans -> c ;
@@ -2405,14 +2389,24 @@ static int check_subvol_path(struct btree_trans *trans, struct btree_iter *iter,
24052389
24062390 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume (k );
24072391
2408- ret = subvol_has_dirent (trans , s );
2409- if (ret < 0 )
2392+ struct bch_inode_unpacked subvol_root ;
2393+ ret = bch2_inode_find_by_inum_trans (trans ,
2394+ (subvol_inum ) { s .k -> p .offset , le64_to_cpu (s .v -> inode ) },
2395+ & subvol_root );
2396+ if (ret )
24102397 break ;
24112398
2412- if (fsck_err_on (!ret ,
2399+ /*
2400+ * We've checked that inode backpointers point to valid dirents;
2401+ * here, it's sufficient to check that the subvolume root has a
2402+ * dirent:
2403+ */
2404+ if (fsck_err_on (!subvol_root .bi_dir ,
24132405 trans , subvol_unreachable ,
24142406 "unreachable subvolume %s" ,
24152407 (bch2_bkey_val_to_text (& buf , c , s .s_c ),
2408+ prt_newline (& buf ),
2409+ bch2_inode_unpacked_to_text (& buf , & subvol_root ),
24162410 buf .buf ))) {
24172411 ret = reattach_subvol (trans , s );
24182412 break ;
0 commit comments