Commit edaed8ee authored by Kent Overstreet's avatar Kent Overstreet
Browse files

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2b47102b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1143,7 +1143,8 @@ static inline __u64 __bset_magic(struct bch_sb *sb)
	x(log,			9)		\
	x(overwrite,		10)		\
	x(write_buffer_keys,	11)		\
	x(datetime,		12)
	x(datetime,		12)		\
	x(log_bkey,		13)

enum bch_jset_entry_type {
#define x(f, nr)	BCH_JSET_ENTRY_##f	= nr,
+13 −0
Original line number Diff line number Diff line
@@ -846,6 +846,19 @@ int bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf)
	return 0;
}

int bch2_trans_log_bkey(struct btree_trans *trans, enum btree_id btree,
			unsigned level, struct bkey_i *k)
{
	struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, jset_u64s(k->k.u64s));
	int ret = PTR_ERR_OR_ZERO(e);
	if (ret)
		return ret;

	journal_entry_init(e, BCH_JSET_ENTRY_log_bkey, btree, level, k->k.u64s);
	bkey_copy(e->start, k);
	return 0;
}

__printf(3, 0)
static int
__bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
+2 −0
Original line number Diff line number Diff line
@@ -170,6 +170,8 @@ void bch2_trans_commit_hook(struct btree_trans *,
int __bch2_trans_commit(struct btree_trans *, unsigned);

int bch2_trans_log_msg(struct btree_trans *, struct printbuf *);
int bch2_trans_log_bkey(struct btree_trans *, enum btree_id, unsigned, struct bkey_i *);

__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 *, ...);

+17 −0
Original line number Diff line number Diff line
@@ -764,6 +764,23 @@ static void journal_entry_overwrite_to_text(struct printbuf *out, struct bch_fs
	journal_entry_btree_keys_to_text(out, c, entry);
}

static int journal_entry_log_bkey_validate(struct bch_fs *c,
				struct jset *jset,
				struct jset_entry *entry,
				unsigned version, int big_endian,
				struct bkey_validate_context from)
{
	from.flags = 0;
	return journal_entry_btree_keys_validate(c, jset, entry,
				version, big_endian, from);
}

static void journal_entry_log_bkey_to_text(struct printbuf *out, struct bch_fs *c,
					   struct jset_entry *entry)
{
	journal_entry_btree_keys_to_text(out, c, entry);
}

static int journal_entry_write_buffer_keys_validate(struct bch_fs *c,
				struct jset *jset,
				struct jset_entry *entry,