Skip to content

Commit c1e4446

Browse files
author
Kent Overstreet
committed
bcachefs: Improved allocator debugging for ec
chasing down a device removal deadlock with erasure coding Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 02026e8 commit c1e4446

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

fs/bcachefs/alloc_foreground.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,8 @@ void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, struct ope
16031603
prt_newline(out);
16041604
}
16051605

1606-
void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c)
1606+
void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c,
1607+
struct bch_dev *ca)
16071608
{
16081609
struct open_bucket *ob;
16091610

@@ -1613,7 +1614,8 @@ void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c)
16131614
ob < c->open_buckets + ARRAY_SIZE(c->open_buckets);
16141615
ob++) {
16151616
spin_lock(&ob->lock);
1616-
if (ob->valid && !ob->on_partial_list)
1617+
if (ob->valid && !ob->on_partial_list &&
1618+
(!ca || ob->dev == ca->dev_idx))
16171619
bch2_open_bucket_to_text(out, c, ob);
16181620
spin_unlock(&ob->lock);
16191621
}

fs/bcachefs/alloc_foreground.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static inline struct write_point_specifier writepoint_ptr(struct write_point *wp
223223
void bch2_fs_allocator_foreground_init(struct bch_fs *);
224224

225225
void bch2_open_bucket_to_text(struct printbuf *, struct bch_fs *, struct open_bucket *);
226-
void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *);
226+
void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *, struct bch_dev *);
227227
void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *);
228228

229229
void bch2_write_points_to_text(struct printbuf *, struct bch_fs *);

fs/bcachefs/ec.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,23 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
22352235
mutex_unlock(&c->ec_stripes_heap_lock);
22362236
}
22372237

2238+
static void bch2_new_stripe_to_text(struct printbuf *out, struct bch_fs *c,
2239+
struct ec_stripe_new *s)
2240+
{
2241+
prt_printf(out, "\tidx %llu blocks %u+%u allocated %u ref %u %u %s obs",
2242+
s->idx, s->nr_data, s->nr_parity,
2243+
bitmap_weight(s->blocks_allocated, s->nr_data),
2244+
atomic_read(&s->ref[STRIPE_REF_io]),
2245+
atomic_read(&s->ref[STRIPE_REF_stripe]),
2246+
bch2_watermarks[s->h->watermark]);
2247+
2248+
struct bch_stripe *v = &bkey_i_to_stripe(&s->new_stripe.key)->v;
2249+
unsigned i;
2250+
for_each_set_bit(i, s->blocks_gotten, v->nr_blocks)
2251+
prt_printf(out, " %u", s->blocks[i]);
2252+
prt_newline(out);
2253+
}
2254+
22382255
void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c)
22392256
{
22402257
struct ec_stripe_head *h;
@@ -2247,23 +2264,15 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c)
22472264
bch2_watermarks[h->watermark]);
22482265

22492266
if (h->s)
2250-
prt_printf(out, "\tidx %llu blocks %u+%u allocated %u\n",
2251-
h->s->idx, h->s->nr_data, h->s->nr_parity,
2252-
bitmap_weight(h->s->blocks_allocated,
2253-
h->s->nr_data));
2267+
bch2_new_stripe_to_text(out, c, h->s);
22542268
}
22552269
mutex_unlock(&c->ec_stripe_head_lock);
22562270

22572271
prt_printf(out, "in flight:\n");
22582272

22592273
mutex_lock(&c->ec_stripe_new_lock);
2260-
list_for_each_entry(s, &c->ec_stripe_new_list, list) {
2261-
prt_printf(out, "\tidx %llu blocks %u+%u ref %u %u %s\n",
2262-
s->idx, s->nr_data, s->nr_parity,
2263-
atomic_read(&s->ref[STRIPE_REF_io]),
2264-
atomic_read(&s->ref[STRIPE_REF_stripe]),
2265-
bch2_watermarks[s->h->watermark]);
2266-
}
2274+
list_for_each_entry(s, &c->ec_stripe_new_list, list)
2275+
bch2_new_stripe_to_text(out, c, s);
22672276
mutex_unlock(&c->ec_stripe_new_lock);
22682277
}
22692278

fs/bcachefs/sysfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ SHOW(bch2_fs)
367367
bch2_stripes_heap_to_text(out, c);
368368

369369
if (attr == &sysfs_open_buckets)
370-
bch2_open_buckets_to_text(out, c);
370+
bch2_open_buckets_to_text(out, c, NULL);
371371

372372
if (attr == &sysfs_open_buckets_partial)
373373
bch2_open_buckets_partial_to_text(out, c);
@@ -811,6 +811,9 @@ SHOW(bch2_dev)
811811
if (attr == &sysfs_alloc_debug)
812812
bch2_dev_alloc_debug_to_text(out, ca);
813813

814+
if (attr == &sysfs_open_buckets)
815+
bch2_open_buckets_to_text(out, c, ca);
816+
814817
return 0;
815818
}
816819

@@ -892,6 +895,7 @@ struct attribute *bch2_dev_files[] = {
892895

893896
/* debug: */
894897
&sysfs_alloc_debug,
898+
&sysfs_open_buckets,
895899
NULL
896900
};
897901

0 commit comments

Comments
 (0)