bcachefs: Fix bch2_verify_bucket_evacuated()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 27 Mar 2023 20:25:15 +0000 (16:25 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:58 +0000 (17:09 -0400)
We were going into an infinite loop when printing out backpointers, due
to never incrementing bp_offset - whoops.

Also limit the number of backpointers we print to 10; this is debug code
and we only need to print a sample, not all of them.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/move.c

index ff4a74de728d40ec2cd31314c431972710794474..9717fdce3ba5f8877a2ff65abd3f963cf5801727 100644 (file)
@@ -627,6 +627,7 @@ void bch2_verify_bucket_evacuated(struct btree_trans *trans, struct bpos bucket,
        struct printbuf buf = PRINTBUF;
        struct bch_backpointer bp;
        u64 bp_offset = 0;
+       unsigned nr_bps = 0;
        int ret;
 
        bch2_trans_begin(trans);
@@ -688,6 +689,10 @@ failed_to_evacuate:
                prt_newline(&buf);
                bch2_bkey_val_to_text(&buf, c, k);
                bch2_trans_iter_exit(trans, &iter);
+
+               if (++nr_bps > 10)
+                       break;
+               bp_offset++;
        }
 
        bch2_print_string_as_lines(KERN_ERR, buf.buf);