bcachefs: check_subvol_path() now prints subvol root inode

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+14 -20
+13 -19
fs/bcachefs/fsck.c
··· 2371 return false; 2372 } 2373 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 - 2390 static int check_subvol_path(struct btree_trans *trans, struct btree_iter *iter, struct bkey_s_c k) 2391 { 2392 struct bch_fs *c = trans->c; ··· 2389 2390 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k); 2391 2392 - ret = subvol_has_dirent(trans, s); 2393 - if (ret < 0) 2394 break; 2395 2396 - if (fsck_err_on(!ret, 2397 trans, subvol_unreachable, 2398 "unreachable subvolume %s", 2399 (bch2_bkey_val_to_text(&buf, c, s.s_c), 2400 buf.buf))) { 2401 ret = reattach_subvol(trans, s); 2402 break;
··· 2371 return false; 2372 } 2373 2374 static int check_subvol_path(struct btree_trans *trans, struct btree_iter *iter, struct bkey_s_c k) 2375 { 2376 struct bch_fs *c = trans->c; ··· 2405 2406 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k); 2407 2408 + struct bch_inode_unpacked subvol_root; 2409 + ret = bch2_inode_find_by_inum_trans(trans, 2410 + (subvol_inum) { s.k->p.offset, le64_to_cpu(s.v->inode) }, 2411 + &subvol_root); 2412 + if (ret) 2413 break; 2414 2415 + /* 2416 + * We've checked that inode backpointers point to valid dirents; 2417 + * here, it's sufficient to check that the subvolume root has a 2418 + * dirent: 2419 + */ 2420 + if (fsck_err_on(!subvol_root.bi_dir, 2421 trans, subvol_unreachable, 2422 "unreachable subvolume %s", 2423 (bch2_bkey_val_to_text(&buf, c, s.s_c), 2424 + prt_newline(&buf), 2425 + bch2_inode_unpacked_to_text(&buf, &subvol_root), 2426 buf.buf))) { 2427 ret = reattach_subvol(trans, s); 2428 break;
+1 -1
fs/bcachefs/sb-errors_format.h
··· 271 x(subvol_children_not_set, 256, 0) \ 272 x(subvol_children_bad, 257, 0) \ 273 x(subvol_loop, 258, 0) \ 274 - x(subvol_unreachable, 259, 0) \ 275 x(btree_node_bkey_bad_u64s, 260, 0) \ 276 x(btree_node_topology_empty_interior_node, 261, 0) \ 277 x(btree_ptr_v2_min_key_bad, 262, 0) \
··· 271 x(subvol_children_not_set, 256, 0) \ 272 x(subvol_children_bad, 257, 0) \ 273 x(subvol_loop, 258, 0) \ 274 + x(subvol_unreachable, 259, FSCK_AUTOFIX) \ 275 x(btree_node_bkey_bad_u64s, 260, 0) \ 276 x(btree_node_topology_empty_interior_node, 261, 0) \ 277 x(btree_ptr_v2_min_key_bad, 262, 0) \