Commit c1e44462 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improved allocator debugging for ec

chasing down a device removal deadlock with erasure coding
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 02026e89
...@@ -1603,7 +1603,8 @@ void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, struct ope ...@@ -1603,7 +1603,8 @@ void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, struct ope
prt_newline(out); prt_newline(out);
} }
void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c) void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c,
struct bch_dev *ca)
{ {
struct open_bucket *ob; struct open_bucket *ob;
...@@ -1613,7 +1614,8 @@ void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c) ...@@ -1613,7 +1614,8 @@ void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c)
ob < c->open_buckets + ARRAY_SIZE(c->open_buckets); ob < c->open_buckets + ARRAY_SIZE(c->open_buckets);
ob++) { ob++) {
spin_lock(&ob->lock); spin_lock(&ob->lock);
if (ob->valid && !ob->on_partial_list) if (ob->valid && !ob->on_partial_list &&
(!ca || ob->dev == ca->dev_idx))
bch2_open_bucket_to_text(out, c, ob); bch2_open_bucket_to_text(out, c, ob);
spin_unlock(&ob->lock); spin_unlock(&ob->lock);
} }
......
...@@ -223,7 +223,7 @@ static inline struct write_point_specifier writepoint_ptr(struct write_point *wp ...@@ -223,7 +223,7 @@ static inline struct write_point_specifier writepoint_ptr(struct write_point *wp
void bch2_fs_allocator_foreground_init(struct bch_fs *); void bch2_fs_allocator_foreground_init(struct bch_fs *);
void bch2_open_bucket_to_text(struct printbuf *, struct bch_fs *, struct open_bucket *); void bch2_open_bucket_to_text(struct printbuf *, struct bch_fs *, struct open_bucket *);
void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *); void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *, struct bch_dev *);
void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *); void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *);
void bch2_write_points_to_text(struct printbuf *, struct bch_fs *); void bch2_write_points_to_text(struct printbuf *, struct bch_fs *);
......
...@@ -2235,6 +2235,23 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c) ...@@ -2235,6 +2235,23 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
mutex_unlock(&c->ec_stripes_heap_lock); mutex_unlock(&c->ec_stripes_heap_lock);
} }
static void bch2_new_stripe_to_text(struct printbuf *out, struct bch_fs *c,
struct ec_stripe_new *s)
{
prt_printf(out, "\tidx %llu blocks %u+%u allocated %u ref %u %u %s obs",
s->idx, s->nr_data, s->nr_parity,
bitmap_weight(s->blocks_allocated, s->nr_data),
atomic_read(&s->ref[STRIPE_REF_io]),
atomic_read(&s->ref[STRIPE_REF_stripe]),
bch2_watermarks[s->h->watermark]);
struct bch_stripe *v = &bkey_i_to_stripe(&s->new_stripe.key)->v;
unsigned i;
for_each_set_bit(i, s->blocks_gotten, v->nr_blocks)
prt_printf(out, " %u", s->blocks[i]);
prt_newline(out);
}
void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c) void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c)
{ {
struct ec_stripe_head *h; struct ec_stripe_head *h;
...@@ -2247,23 +2264,15 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c) ...@@ -2247,23 +2264,15 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c)
bch2_watermarks[h->watermark]); bch2_watermarks[h->watermark]);
if (h->s) if (h->s)
prt_printf(out, "\tidx %llu blocks %u+%u allocated %u\n", bch2_new_stripe_to_text(out, c, h->s);
h->s->idx, h->s->nr_data, h->s->nr_parity,
bitmap_weight(h->s->blocks_allocated,
h->s->nr_data));
} }
mutex_unlock(&c->ec_stripe_head_lock); mutex_unlock(&c->ec_stripe_head_lock);
prt_printf(out, "in flight:\n"); prt_printf(out, "in flight:\n");
mutex_lock(&c->ec_stripe_new_lock); mutex_lock(&c->ec_stripe_new_lock);
list_for_each_entry(s, &c->ec_stripe_new_list, list) { list_for_each_entry(s, &c->ec_stripe_new_list, list)
prt_printf(out, "\tidx %llu blocks %u+%u ref %u %u %s\n", bch2_new_stripe_to_text(out, c, s);
s->idx, s->nr_data, s->nr_parity,
atomic_read(&s->ref[STRIPE_REF_io]),
atomic_read(&s->ref[STRIPE_REF_stripe]),
bch2_watermarks[s->h->watermark]);
}
mutex_unlock(&c->ec_stripe_new_lock); mutex_unlock(&c->ec_stripe_new_lock);
} }
......
...@@ -367,7 +367,7 @@ SHOW(bch2_fs) ...@@ -367,7 +367,7 @@ SHOW(bch2_fs)
bch2_stripes_heap_to_text(out, c); bch2_stripes_heap_to_text(out, c);
if (attr == &sysfs_open_buckets) if (attr == &sysfs_open_buckets)
bch2_open_buckets_to_text(out, c); bch2_open_buckets_to_text(out, c, NULL);
if (attr == &sysfs_open_buckets_partial) if (attr == &sysfs_open_buckets_partial)
bch2_open_buckets_partial_to_text(out, c); bch2_open_buckets_partial_to_text(out, c);
...@@ -811,6 +811,9 @@ SHOW(bch2_dev) ...@@ -811,6 +811,9 @@ SHOW(bch2_dev)
if (attr == &sysfs_alloc_debug) if (attr == &sysfs_alloc_debug)
bch2_dev_alloc_debug_to_text(out, ca); bch2_dev_alloc_debug_to_text(out, ca);
if (attr == &sysfs_open_buckets)
bch2_open_buckets_to_text(out, c, ca);
return 0; return 0;
} }
...@@ -892,6 +895,7 @@ struct attribute *bch2_dev_files[] = { ...@@ -892,6 +895,7 @@ struct attribute *bch2_dev_files[] = {
/* debug: */ /* debug: */
&sysfs_alloc_debug, &sysfs_alloc_debug,
&sysfs_open_buckets,
NULL NULL
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment