]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Drop empty accounting updates
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 21 May 2025 19:54:56 +0000 (15:54 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:19:24 +0000 (20:19 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/disk_accounting.c

index 488c342b9cd7f83e56f99b0b6db072b5eba44392..b3840ff7c40791cb6f78a976ab29cee6d12044a8 100644 (file)
@@ -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