Skip to content

Commit 3a5895e

Browse files
author
Kent Overstreet
committed
bcachefs: check_subvol_path() now prints subvol root inode
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 0b0f0ad commit 3a5895e

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

fs/bcachefs/fsck.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
23902374
static 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;

fs/bcachefs/sb-errors_format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ enum bch_fsck_flags {
271271
x(subvol_children_not_set, 256, 0) \
272272
x(subvol_children_bad, 257, 0) \
273273
x(subvol_loop, 258, 0) \
274-
x(subvol_unreachable, 259, 0) \
274+
x(subvol_unreachable, 259, FSCK_AUTOFIX) \
275275
x(btree_node_bkey_bad_u64s, 260, 0) \
276276
x(btree_node_topology_empty_interior_node, 261, 0) \
277277
x(btree_ptr_v2_min_key_bad, 262, 0) \

0 commit comments

Comments
 (0)