]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Improve warning for copygc failing to move data
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 4 Jun 2020 03:47:50 +0000 (23:47 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:40 +0000 (17:08 -0400)
This will help narrow down which code is at fault when this happens.

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

index 02cc5089a16363b5374de5b9d9c9c53ef51c7501..a061e60e3d7a11ba639cdcc759539ff3b2a93278 100644 (file)
@@ -177,9 +177,12 @@ next:
                }
                continue;
 nomatch:
-               if (m->ctxt)
+               if (m->ctxt) {
+                       BUG_ON(k.k->p.offset <= iter->pos.offset);
+                       atomic64_inc(&m->ctxt->stats->keys_raced);
                        atomic64_add(k.k->p.offset - iter->pos.offset,
                                     &m->ctxt->stats->sectors_raced);
+               }
                atomic_long_inc(&c->extent_migrate_raced);
                trace_move_race(&new->k);
                bch2_btree_iter_next_slot(iter);
index 6788170d3f95de1df173019681a4e146b104d3e1..fc0de165af9fe354b246e24ca223904c87e7dc0b 100644 (file)
@@ -8,6 +8,7 @@ struct bch_move_stats {
        struct bpos             pos;
 
        atomic64_t              keys_moved;
+       atomic64_t              keys_raced;
        atomic64_t              sectors_moved;
        atomic64_t              sectors_seen;
        atomic64_t              sectors_raced;
index 7e08a7940a3509fc8324f1c699bc7760a47da792..d22f26c02b67146b8bf86221d6b4779eb0b74962 100644 (file)
@@ -78,7 +78,17 @@ static bool __copygc_pred(struct bch_dev *ca,
                ssize_t i = eytzinger0_find_le(h->data, h->used,
                                               sizeof(h->data[0]),
                                               bucket_offset_cmp, &search);
+#if 0
+               /* eytzinger search verify code: */
+               ssize_t j = -1, k;
 
+               for (k = 0; k < h->used; k++)
+                       if (h->data[k].offset <= ptr->offset &&
+                           (j < 0 || h->data[k].offset > h->data[j].offset))
+                               j = k;
+
+               BUG_ON(i != j);
+#endif
                return (i >= 0 &&
                        ptr->offset < h->data[i].offset + ca->mi.bucket_size &&
                        ptr->gen == h->data[i].gen);
@@ -203,9 +213,12 @@ static void bch2_copygc(struct bch_fs *c, struct bch_dev *ca)
 
        if (sectors_not_moved && !ret)
                bch_warn_ratelimited(c,
-                       "copygc finished but %llu/%llu sectors, %llu/%llu buckets not moved",
+                       "copygc finished but %llu/%llu sectors, %llu/%llu buckets not moved (move stats: moved %llu sectors, raced %llu keys, %llu sectors)",
                         sectors_not_moved, sectors_to_move,
-                        buckets_not_moved, buckets_to_move);
+                        buckets_not_moved, buckets_to_move,
+                        atomic64_read(&move_stats.sectors_moved),
+                        atomic64_read(&move_stats.keys_raced),
+                        atomic64_read(&move_stats.sectors_raced));
 
        trace_copygc(ca,
                     atomic64_read(&move_stats.sectors_moved), sectors_not_moved,