Commit cdda2126 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_btree_reserve_cache_to_text()

Add a pretty printer so the btree reserve cache can be seen in sysfs; as
it pins open_buckets we need it for tracking down open_buckets issues.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d06a26d2
...@@ -1589,7 +1589,7 @@ void bch2_fs_allocator_foreground_init(struct bch_fs *c) ...@@ -1589,7 +1589,7 @@ void bch2_fs_allocator_foreground_init(struct bch_fs *c)
} }
} }
static void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, struct open_bucket *ob) void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, struct open_bucket *ob)
{ {
struct bch_dev *ca = ob_dev(c, ob); struct bch_dev *ca = ob_dev(c, ob);
unsigned data_type = ob->data_type; unsigned data_type = ob->data_type;
......
...@@ -222,6 +222,7 @@ static inline struct write_point_specifier writepoint_ptr(struct write_point *wp ...@@ -222,6 +222,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_buckets_to_text(struct printbuf *, struct bch_fs *); void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *);
void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *); void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *);
......
...@@ -2647,6 +2647,28 @@ bch2_btree_roots_to_journal_entries(struct bch_fs *c, ...@@ -2647,6 +2647,28 @@ bch2_btree_roots_to_journal_entries(struct bch_fs *c,
return end; return end;
} }
static void bch2_btree_alloc_to_text(struct printbuf *out,
struct bch_fs *c,
struct btree_alloc *a)
{
printbuf_indent_add(out, 2);
bch2_bkey_val_to_text(out, c, bkey_i_to_s_c(&a->k));
prt_newline(out);
struct open_bucket *ob;
unsigned i;
open_bucket_for_each(c, &a->ob, ob, i)
bch2_open_bucket_to_text(out, c, ob);
printbuf_indent_sub(out, 2);
}
void bch2_btree_reserve_cache_to_text(struct printbuf *out, struct bch_fs *c)
{
for (unsigned i = 0; i < c->btree_reserve_cache_nr; i++)
bch2_btree_alloc_to_text(out, c, &c->btree_reserve_cache[i]);
}
void bch2_fs_btree_interior_update_exit(struct bch_fs *c) void bch2_fs_btree_interior_update_exit(struct bch_fs *c)
{ {
if (c->btree_node_rewrite_worker) if (c->btree_node_rewrite_worker)
......
...@@ -335,6 +335,8 @@ struct jset_entry *bch2_btree_roots_to_journal_entries(struct bch_fs *, ...@@ -335,6 +335,8 @@ struct jset_entry *bch2_btree_roots_to_journal_entries(struct bch_fs *,
void bch2_do_pending_node_rewrites(struct bch_fs *); void bch2_do_pending_node_rewrites(struct bch_fs *);
void bch2_free_pending_node_rewrites(struct bch_fs *); void bch2_free_pending_node_rewrites(struct bch_fs *);
void bch2_btree_reserve_cache_to_text(struct printbuf *, struct bch_fs *);
void bch2_fs_btree_interior_update_exit(struct bch_fs *); void bch2_fs_btree_interior_update_exit(struct bch_fs *);
void bch2_fs_btree_interior_update_init_early(struct bch_fs *); void bch2_fs_btree_interior_update_init_early(struct bch_fs *);
int bch2_fs_btree_interior_update_init(struct bch_fs *); int bch2_fs_btree_interior_update_init(struct bch_fs *);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "btree_iter.h" #include "btree_iter.h"
#include "btree_key_cache.h" #include "btree_key_cache.h"
#include "btree_update.h" #include "btree_update.h"
#include "btree_update_interior.h"
#include "btree_gc.h" #include "btree_gc.h"
#include "buckets.h" #include "buckets.h"
#include "clock.h" #include "clock.h"
...@@ -170,6 +171,7 @@ read_attribute(compression_stats); ...@@ -170,6 +171,7 @@ read_attribute(compression_stats);
read_attribute(journal_debug); read_attribute(journal_debug);
read_attribute(btree_cache); read_attribute(btree_cache);
read_attribute(btree_key_cache); read_attribute(btree_key_cache);
read_attribute(btree_reserve_cache);
read_attribute(stripes_heap); read_attribute(stripes_heap);
read_attribute(open_buckets); read_attribute(open_buckets);
read_attribute(open_buckets_partial); read_attribute(open_buckets_partial);
...@@ -390,6 +392,9 @@ SHOW(bch2_fs) ...@@ -390,6 +392,9 @@ SHOW(bch2_fs)
if (attr == &sysfs_btree_key_cache) if (attr == &sysfs_btree_key_cache)
bch2_btree_key_cache_to_text(out, &c->btree_key_cache); bch2_btree_key_cache_to_text(out, &c->btree_key_cache);
if (attr == &sysfs_btree_reserve_cache)
bch2_btree_reserve_cache_to_text(out, c);
if (attr == &sysfs_stripes_heap) if (attr == &sysfs_stripes_heap)
bch2_stripes_heap_to_text(out, c); bch2_stripes_heap_to_text(out, c);
...@@ -607,6 +612,7 @@ struct attribute *bch2_fs_internal_files[] = { ...@@ -607,6 +612,7 @@ struct attribute *bch2_fs_internal_files[] = {
&sysfs_journal_debug, &sysfs_journal_debug,
&sysfs_btree_cache, &sysfs_btree_cache,
&sysfs_btree_key_cache, &sysfs_btree_key_cache,
&sysfs_btree_reserve_cache,
&sysfs_new_stripes, &sysfs_new_stripes,
&sysfs_stripes_heap, &sysfs_stripes_heap,
&sysfs_open_buckets, &sysfs_open_buckets,
......
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