bcachefs: fsck: Print path when we find a subvol loop
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 7 Jun 2025 23:33:59 +0000 (19:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 16 Jun 2025 23:04:48 +0000 (19:04 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fsck.c

index f25d33fb3e232ee48b1169e65fa4e20126f6bf41..0d87aa9b4f2314a85e4fa71f0876d727662d942b 100644 (file)
@@ -2578,6 +2578,11 @@ static int check_subvol_path(struct btree_trans *trans, struct btree_iter *iter,
        if (k.k->type != KEY_TYPE_subvolume)
                return 0;
 
+       subvol_inum start = {
+               .subvol = k.k->p.offset,
+               .inum   = le64_to_cpu(bkey_s_c_to_subvolume(k).v->inode),
+       };
+
        while (k.k->p.offset != BCACHEFS_ROOT_SUBVOL) {
                ret = darray_push(&subvol_path, k.k->p.offset);
                if (ret)
@@ -2596,11 +2601,11 @@ static int check_subvol_path(struct btree_trans *trans, struct btree_iter *iter,
 
                if (darray_u32_has(&subvol_path, parent)) {
                        printbuf_reset(&buf);
-                       prt_printf(&buf, "subvolume loop:\n");
+                       prt_printf(&buf, "subvolume loop: ");
 
-                       darray_for_each_reverse(subvol_path, i)
-                               prt_printf(&buf, "%u ", *i);
-                       prt_printf(&buf, "%u", parent);
+                       ret = bch2_inum_to_path(trans, start, &buf);
+                       if (ret)
+                               goto err;
 
                        if (fsck_err(trans, subvol_loop, "%s", buf.buf))
                                ret = reattach_subvol(trans, s);