From: Kent Overstreet Date: Wed, 21 May 2025 19:54:56 +0000 (-0400) Subject: bcachefs: Drop empty accounting updates X-Git-Tag: v6.16-rc1~211^2~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfc0c6fecf3bd2da93beb565ccfb9e704cadddcc;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Drop empty accounting updates Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c index 488c342b9cd7f..b3840ff7c4079 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