From: Nikita Ofitserov via B4 Relay <devnull+himikof.gmail.com@kernel.org>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org, Nikita Ofitserov <himikof@gmail.com>
Subject: [PATCH v2 14/15] bcachefs: Better progress reporting for btree iteration without leaves
Date: Thu, 28 Aug 2025 17:16:16 +0300 [thread overview]
Message-ID: <20250828-better-progress-v2-14-c088a2003940@gmail.com> (raw)
In-Reply-To: <20250828-better-progress-v2-0-c088a2003940@gmail.com>
From: Nikita Ofitserov <himikof@gmail.com>
Signed-off-by: Nikita Ofitserov <himikof@gmail.com>
---
fs/bcachefs/progress.c | 17 +++++++++++++----
fs/bcachefs/progress.h | 12 +++++++++++-
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/fs/bcachefs/progress.c b/fs/bcachefs/progress.c
index 8181f6d2ca3808f57bef179383bd969d9a375d5f..7cc16490ffa98fec34ff228cb56bd1af0f42da3d 100644
--- a/fs/bcachefs/progress.c
+++ b/fs/bcachefs/progress.c
@@ -4,9 +4,10 @@
#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));
@@ -16,6 +17,8 @@ void bch2_progress_init(struct progress_indicator_state *s,
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;
@@ -31,11 +34,17 @@ void bch2_progress_init(struct progress_indicator_state *s,
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
diff --git a/fs/bcachefs/progress.h b/fs/bcachefs/progress.h
index 972a73087ffe06632abef015e4556d8ee196eb24..91f3453377093e2713aa4198b68e13601223688e 100644
--- a/fs/bcachefs/progress.h
+++ b/fs/bcachefs/progress.h
@@ -20,7 +20,17 @@ struct progress_indicator_state {
struct btree *last_node;
};
-void bch2_progress_init(struct progress_indicator_state *, struct bch_fs *, u64);
+void bch2_progress_init_inner(struct progress_indicator_state *s,
+ struct bch_fs *c,
+ u64 leaf_btree_id_mask,
+ u64 inner_btree_id_mask);
+
+static inline void bch2_progress_init(struct progress_indicator_state *s,
+ struct bch_fs *c, u64 btree_id_mask)
+{
+ bch2_progress_init_inner(s, c, btree_id_mask, 0);
+}
+
void bch2_progress_update_iter(struct btree_trans *,
struct progress_indicator_state *,
struct btree_iter *,
--
2.50.1
next prev parent reply other threads:[~2025-08-28 14:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 14:16 [PATCH v2 00/15] Accounting for accurate progress reporting Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 01/15] bcachefs: Introduce btree_leaf_has_triggers_mask Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 02/15] bcachefs: Refactor bch2_gc_btree/bch2_gc_btrees Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 03/15] bcachefs: Improve check_allocations pass speed when not in fsck Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 04/15] bcachefs: Refactor/rename btree_type_has_ptrs Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 05/15] bcachefs: Fix progress reporting for unknown btrees Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 06/15] bcachefs: Partially fix old device removal with " Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 07/15] bcachefs: Fix missing c->usage updates from early recovery Nikita Ofitserov via B4 Relay
2025-09-01 23:55 ` Kent Overstreet
2025-08-28 14:16 ` [PATCH v2 08/15] bcachefs: Optimize/fix bch2_dev_usage_remove Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 09/15] bcachefs: Fix online hidden (sb+journal) data accounting Nikita Ofitserov via B4 Relay
2025-09-02 0:14 ` Kent Overstreet
2025-08-28 14:16 ` [PATCH v2 10/15] bcachefs: Fix outdated documentation comment Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 11/15] bcachefs: Relax restrictions on the number of accounting counters Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 12/15] bcachefs: bcachefs_metadata_version_btree_node_accounting Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` [PATCH v2 13/15] bcachefs: Use explicit node counts in progress reporting Nikita Ofitserov via B4 Relay
2025-08-28 14:16 ` Nikita Ofitserov via B4 Relay [this message]
2025-08-28 14:16 ` [PATCH v2 15/15] bcachefs: More accurate progress reporting for inner node iteration Nikita Ofitserov via B4 Relay
2025-09-01 22:33 ` [PATCH v2 00/15] Accounting for accurate progress reporting Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250828-better-progress-v2-14-c088a2003940@gmail.com \
--to=devnull+himikof.gmail.com@kernel.org \
--cc=himikof@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox