Skip to content

Commit edaed8e

Browse files
author
Kent Overstreet
committed
bcachefs: BCH_JSET_ENTRY_log_bkey
Add a journal entry type for logging - but logging a bkey, not a string; to be used for data move path debugging. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 2b47102 commit edaed8e

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,8 @@ static inline __u64 __bset_magic(struct bch_sb *sb)
11431143
x(log, 9) \
11441144
x(overwrite, 10) \
11451145
x(write_buffer_keys, 11) \
1146-
x(datetime, 12)
1146+
x(datetime, 12) \
1147+
x(log_bkey, 13)
11471148

11481149
enum bch_jset_entry_type {
11491150
#define x(f, nr) BCH_JSET_ENTRY_##f = nr,

fs/bcachefs/btree_update.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,19 @@ int bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf)
846846
return 0;
847847
}
848848

849+
int bch2_trans_log_bkey(struct btree_trans *trans, enum btree_id btree,
850+
unsigned level, struct bkey_i *k)
851+
{
852+
struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, jset_u64s(k->k.u64s));
853+
int ret = PTR_ERR_OR_ZERO(e);
854+
if (ret)
855+
return ret;
856+
857+
journal_entry_init(e, BCH_JSET_ENTRY_log_bkey, btree, level, k->k.u64s);
858+
bkey_copy(e->start, k);
859+
return 0;
860+
}
861+
849862
__printf(3, 0)
850863
static int
851864
__bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,

fs/bcachefs/btree_update.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ void bch2_trans_commit_hook(struct btree_trans *,
170170
int __bch2_trans_commit(struct btree_trans *, unsigned);
171171

172172
int bch2_trans_log_msg(struct btree_trans *, struct printbuf *);
173+
int bch2_trans_log_bkey(struct btree_trans *, enum btree_id, unsigned, struct bkey_i *);
174+
173175
__printf(2, 3) int bch2_fs_log_msg(struct bch_fs *, const char *, ...);
174176
__printf(2, 3) int bch2_journal_log_msg(struct bch_fs *, const char *, ...);
175177

fs/bcachefs/journal_io.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,23 @@ static void journal_entry_overwrite_to_text(struct printbuf *out, struct bch_fs
764764
journal_entry_btree_keys_to_text(out, c, entry);
765765
}
766766

767+
static int journal_entry_log_bkey_validate(struct bch_fs *c,
768+
struct jset *jset,
769+
struct jset_entry *entry,
770+
unsigned version, int big_endian,
771+
struct bkey_validate_context from)
772+
{
773+
from.flags = 0;
774+
return journal_entry_btree_keys_validate(c, jset, entry,
775+
version, big_endian, from);
776+
}
777+
778+
static void journal_entry_log_bkey_to_text(struct printbuf *out, struct bch_fs *c,
779+
struct jset_entry *entry)
780+
{
781+
journal_entry_btree_keys_to_text(out, c, entry);
782+
}
783+
767784
static int journal_entry_write_buffer_keys_validate(struct bch_fs *c,
768785
struct jset *jset,
769786
struct jset_entry *entry,

0 commit comments

Comments
 (0)