diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-09-09 16:09:20 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-09-14 11:28:41 -0400 |
commit | 6ad0fa30a9c5aafda1206a64ba1262796ed35457 (patch) | |
tree | d779ccee13ee4e8fa7a7b21e799dd6126a48274d /libbcachefs/progress.c | |
parent | 0c6b9627a40559939ae58d305089c17dea7df5df (diff) |
Update bcachefs sources to 1c8d3fc41e72 bcachefs: fast_list.c is only required for async obj debugging
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/progress.c')
-rw-r--r-- | libbcachefs/progress.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/libbcachefs/progress.c b/libbcachefs/progress.c index 541ee951..7cc16490 100644 --- a/libbcachefs/progress.c +++ b/libbcachefs/progress.c @@ -4,14 +4,21 @@ #include "disk_accounting.h" #include "progress.h" -void bch2_progress_init(struct progress_indicator_state *s, - struct bch_fs *c, - u64 btree_id_mask) +void bch2_progress_init_inner(struct progress_indicator_state *s, + struct bch_fs *c, + u64 leaf_btree_id_mask, + u64 inner_btree_id_mask) { memset(s, 0, sizeof(*s)); s->next_print = jiffies + HZ * 10; + /* This is only an estimation: nodes can have different replica counts */ + const u32 expected_node_disk_sectors = + READ_ONCE(c->opts.metadata_replicas) * btree_sectors(c); + + const u64 btree_id_mask = leaf_btree_id_mask | inner_btree_id_mask; + for (unsigned i = 0; i < btree_id_nr_alive(c); i++) { if (!(btree_id_mask & BIT_ULL(i))) continue; @@ -19,9 +26,29 @@ void bch2_progress_init(struct progress_indicator_state *s, struct disk_accounting_pos acc; disk_accounting_key_init(acc, btree, .id = i); - u64 v; - bch2_accounting_mem_read(c, disk_accounting_pos_to_bpos(&acc), &v, 1); - s->nodes_total += div64_ul(v, btree_sectors(c)); + struct { + u64 disk_sectors; + u64 total_nodes; + u64 inner_nodes; + } v = {0}; + bch2_accounting_mem_read(c, disk_accounting_pos_to_bpos(&acc), + (u64 *)&v, sizeof(v) / sizeof(u64)); + + /* Better to estimate as 0 than the total node count */ + if (inner_btree_id_mask & BIT_ULL(i)) + s->nodes_total += v.inner_nodes; + + if (!(leaf_btree_id_mask & BIT_ULL(i))) + continue; + + /* + * We check for zeros to degrade gracefully when run + * with un-upgraded accounting info (missing some counters). + */ + if (v.total_nodes != 0) + s->nodes_total += v.total_nodes - v.inner_nodes; + else + s->nodes_total += div_u64(v.disk_sectors, expected_node_disk_sectors); } } |