diff options
Diffstat (limited to 'libbcachefs/disk_accounting.c')
-rw-r--r-- | libbcachefs/disk_accounting.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libbcachefs/disk_accounting.c b/libbcachefs/disk_accounting.c index 488c342b..b3840ff7 100644 --- a/libbcachefs/disk_accounting.c +++ b/libbcachefs/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 |