Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: Add open_buckets to sysfs

This is to help debug a rare shutdown deadlock in the allocator code -
the btree code is leaking open_buckets.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>

authored by

Kent Overstreet and committed by
Kent Overstreet
2e655e6d 003e738d

+28
+19
fs/bcachefs/alloc_background.c
··· 1232 1232 { 1233 1233 spin_lock_init(&c->freelist_lock); 1234 1234 } 1235 + 1236 + void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c) 1237 + { 1238 + struct open_bucket *ob; 1239 + 1240 + for (ob = c->open_buckets; 1241 + ob < c->open_buckets + ARRAY_SIZE(c->open_buckets); 1242 + ob++) { 1243 + spin_lock(&ob->lock); 1244 + if (ob->valid && !ob->on_partial_list) { 1245 + pr_buf(out, "%zu ref %u type %s\n", 1246 + ob - c->open_buckets, 1247 + atomic_read(&ob->pin), 1248 + bch2_data_types[ob->type]); 1249 + } 1250 + spin_unlock(&ob->lock); 1251 + } 1252 + 1253 + }
+2
fs/bcachefs/alloc_background.h
··· 132 132 int bch2_alloc_write(struct bch_fs *, unsigned); 133 133 void bch2_fs_allocator_background_init(struct bch_fs *); 134 134 135 + void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *); 136 + 135 137 #endif /* _BCACHEFS_ALLOC_BACKGROUND_H */
+7
fs/bcachefs/sysfs.c
··· 171 171 read_attribute(btree_key_cache); 172 172 read_attribute(btree_transactions); 173 173 read_attribute(stripes_heap); 174 + read_attribute(open_buckets); 174 175 175 176 read_attribute(internal_uuid); 176 177 ··· 410 409 return out.pos - buf; 411 410 } 412 411 412 + if (attr == &sysfs_open_buckets) { 413 + bch2_open_buckets_to_text(&out, c); 414 + return out.pos - buf; 415 + } 416 + 413 417 if (attr == &sysfs_compression_stats) { 414 418 bch2_compression_stats_to_text(&out, c); 415 419 return out.pos - buf; ··· 573 567 &sysfs_btree_key_cache, 574 568 &sysfs_btree_transactions, 575 569 &sysfs_stripes_heap, 570 + &sysfs_open_buckets, 576 571 577 572 &sysfs_read_realloc_races, 578 573 &sysfs_extent_migrate_done,