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 12/12] bcachefs: Fix online hidden (sb+journal) data accounting
Date: Wed, 27 Aug 2025 01:49:18 +0300 [thread overview]
Message-ID: <20250827-better-progress-v1-12-74c24de7988a@gmail.com> (raw)
In-Reply-To: <20250827-better-progress-v1-0-74c24de7988a@gmail.com>
From: Nikita Ofitserov <himikof@gmail.com>
Now the c->usage->hidden counters are kept up to date by the same
trigger-based mechanism as the other ones.
Signed-off-by: Nikita Ofitserov <himikof@gmail.com>
---
fs/bcachefs/disk_accounting.c | 12 ++++++++----
fs/bcachefs/disk_accounting.h | 10 +++++++---
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c
index 53080f4449737ff384d56a3a150b376dadbfdc73..ea375b8bcebc33917eeaf754934815581232a97e 100644
--- a/fs/bcachefs/disk_accounting.c
+++ b/fs/bcachefs/disk_accounting.c
@@ -1064,13 +1064,17 @@ void bch2_verify_accounting_clean(struct bch_fs *c)
case BCH_DISK_ACCOUNTING_dev_data_type: {
{
guard(rcu)(); /* scoped guard is a loop, and doesn't play nicely with continue */
+ const enum bch_data_type data_type = acc_k.dev_data_type.data_type;
struct bch_dev *ca = bch2_dev_rcu_noerror(c, acc_k.dev_data_type.dev);
if (!ca)
continue;
- v[0] = percpu_u64_get(&ca->usage->d[acc_k.dev_data_type.data_type].buckets);
- v[1] = percpu_u64_get(&ca->usage->d[acc_k.dev_data_type.data_type].sectors);
- v[2] = percpu_u64_get(&ca->usage->d[acc_k.dev_data_type.data_type].fragmented);
+ v[0] = percpu_u64_get(&ca->usage->d[data_type].buckets);
+ v[1] = percpu_u64_get(&ca->usage->d[data_type].sectors);
+ v[2] = percpu_u64_get(&ca->usage->d[data_type].fragmented);
+
+ if (data_type == BCH_DATA_sb || data_type == BCH_DATA_journal)
+ base.hidden += a.v->d[0] * ca->mi.bucket_size;
}
if (memcmp(a.v->d, v, 3 * sizeof(u64))) {
@@ -1098,7 +1102,7 @@ void bch2_verify_accounting_clean(struct bch_fs *c)
mismatch = true; \
}
- //check(hidden);
+ check(hidden);
check(btree);
check(data);
check(cached);
diff --git a/fs/bcachefs/disk_accounting.h b/fs/bcachefs/disk_accounting.h
index 9e46aaf74704eaf51a643c3e746a440abd175b9e..9fcfc6a6e36958a27b312dad9de29455a6ee8f87 100644
--- a/fs/bcachefs/disk_accounting.h
+++ b/fs/bcachefs/disk_accounting.h
@@ -186,11 +186,15 @@ static inline int bch2_accounting_mem_mod_locked(struct btree_trans *trans,
break;
case BCH_DISK_ACCOUNTING_dev_data_type: {
guard(rcu)();
+ const enum bch_data_type data_type = acc_k.dev_data_type.data_type;
struct bch_dev *ca = bch2_dev_rcu_noerror(c, acc_k.dev_data_type.dev);
if (ca) {
- this_cpu_add(ca->usage->d[acc_k.dev_data_type.data_type].buckets, a.v->d[0]);
- this_cpu_add(ca->usage->d[acc_k.dev_data_type.data_type].sectors, a.v->d[1]);
- this_cpu_add(ca->usage->d[acc_k.dev_data_type.data_type].fragmented, a.v->d[2]);
+ this_cpu_add(ca->usage->d[data_type].buckets, a.v->d[0]);
+ this_cpu_add(ca->usage->d[data_type].sectors, a.v->d[1]);
+ this_cpu_add(ca->usage->d[data_type].fragmented, a.v->d[2]);
+
+ if (data_type == BCH_DATA_sb || data_type == BCH_DATA_journal)
+ trans->fs_usage_delta.hidden += a.v->d[0] * ca->mi.bucket_size;
}
break;
}
--
2.50.1
next prev parent reply other threads:[~2025-08-26 22:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 22:49 [PATCH 00/12] Accounting for accurate progress reporting Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 01/12] bcachefs: Relax restrictions on the number of accounting counters Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 02/12] bcachefs: Introduce btree node number accounting Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 03/12] bcachefs: Use explicit node counts in progress reporting Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 04/12] bcachefs: Introduce btree_leaf_has_triggers_mask Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 05/12] bcachefs: Better progress reporting for btree iteration without leaves Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 06/12] bcachefs: Refactor/rename btree_type_has_ptrs Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 07/12] bcachefs: More accurate progress reporting for inner node iteration Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 08/12] bcachefs: Fix progress reporting for unknown btrees Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 09/12] bcachefs: Partially fix old device removal with " Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 10/12] bcachefs: Improve check_allocations pass speed not in fsck Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` [PATCH 11/12] bcachefs: Fix missing c->usage updates from early recovery Nikita Ofitserov via B4 Relay
2025-08-26 22:49 ` Nikita Ofitserov via B4 Relay [this message]
2025-08-27 17:17 ` [PATCH 00/12] 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=20250827-better-progress-v1-12-74c24de7988a@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;
as well as URLs for NNTP newsgroup(s).