diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-21 15:54:56 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-21 20:19:24 -0400 |
commit | bfc0c6fecf3bd2da93beb565ccfb9e704cadddcc (patch) | |
tree | a5dec80b476a5cd3771d345ab5f1409a649283a9 | |
parent | 136d082abc2adcdc10a472e29710826eee7f5f80 (diff) |
bcachefs: Drop empty accounting updates
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/disk_accounting.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c index 488c342b9cd7..b3840ff7c407 100644 --- a/fs/bcachefs/disk_accounting.c +++ b/fs/bcachefs/disk_accounting.c @@ -111,6 +111,16 @@ int bch2_disk_accounting_mod(struct btree_trans *trans, if (bpos_eq(a->k.p, pos)) { BUG_ON(nr != bch2_accounting_counters(&a->k)); acc_u64s(a->v.d, d, nr); + + if (bch2_accounting_key_is_zero(accounting_i_to_s_c(a))) { + unsigned offset = (u64 *) a - + (u64 *) btree_trans_subbuf_base(trans, &trans->accounting); + + trans->accounting.u64s -= a->k.u64s; + memmove_u64s_down(a, + bkey_next(&a->k_i), + trans->accounting.u64s - offset); + } return 0; } #endif |