return bch2_trans_update_buffered(trans, btree, &k);
 }
 
-static int __bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf, unsigned u64s)
+int bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf)
 {
+       unsigned u64s = DIV_ROUND_UP(buf->pos, sizeof(u64));
+       prt_chars(buf, '\0', u64s * sizeof(u64) - buf->pos);
+
+       int ret = buf->allocation_failure ? -BCH_ERR_ENOMEM_trans_log_msg : 0;
+       if (ret)
+               return ret;
+
        struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, jset_u64s(u64s));
-       int ret = PTR_ERR_OR_ZERO(e);
+       ret = PTR_ERR_OR_ZERO(e);
        if (ret)
                return ret;
 
                c->journal.early_journal_entries.nr += jset_u64s(u64s);
        } else {
                ret = bch2_trans_commit_do(c, NULL, NULL, commit_flags,
-                       __bch2_trans_log_msg(trans, &buf, u64s));
+                       bch2_trans_log_msg(trans, &buf));
        }
 err:
        printbuf_exit(&buf);
 
                            struct btree_trans_commit_hook *);
 int __bch2_trans_commit(struct btree_trans *, unsigned);
 
+int bch2_trans_log_msg(struct btree_trans *, struct printbuf *);
 __printf(2, 3) int bch2_fs_log_msg(struct bch_fs *, const char *, ...);
 __printf(2, 3) int bch2_journal_log_msg(struct bch_fs *, const char *, ...);