: bch2_btree_delete(trans, BTREE_ID_backpointers, pos, 0);
 }
 
-static int bch2_backpointers_maybe_flush(struct btree_trans *trans,
+static inline int bch2_backpointers_maybe_flush(struct btree_trans *trans,
                                         struct bkey_s_c visiting_k,
                                         struct bkey_buf *last_flushed)
 {
 
        bch2_bkey_buf_init(&tmp);
 
        if (!bkey_and_val_eq(referring_k, bkey_i_to_s_c(last_flushed->k))) {
+               if (trace_write_buffer_maybe_flush_enabled()) {
+                       struct printbuf buf = PRINTBUF;
+
+                       bch2_bkey_val_to_text(&buf, c, referring_k);
+                       trace_write_buffer_maybe_flush(trans, _RET_IP_, buf.buf);
+                       printbuf_exit(&buf);
+               }
+
                bch2_bkey_buf_reassemble(&tmp, c, referring_k);
 
                if (bkey_is_btree_ptr(referring_k.k)) {
 
        TP_printk("%zu/%zu", __entry->slowpath, __entry->total)
 );
 
+TRACE_EVENT(write_buffer_maybe_flush,
+       TP_PROTO(struct btree_trans *trans, unsigned long caller_ip, const char *key),
+       TP_ARGS(trans, caller_ip, key),
+
+       TP_STRUCT__entry(
+               __array(char,                   trans_fn, 32    )
+               __field(unsigned long,          caller_ip       )
+               __string(key,           key                     )
+       ),
+
+       TP_fast_assign(
+               strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
+               __assign_str(key);
+       ),
+
+       TP_printk("%s %pS %s", __entry->trans_fn, (void *) __entry->caller_ip, __get_str(key))
+);
+
 DEFINE_EVENT(fs_str, rebalance_extent,
        TP_PROTO(struct bch_fs *c, const char *str),
        TP_ARGS(c, str)