bcachefs: Improve move path tracepoints

Move path tracepoints now include the key being moved. Also, add new
tracepoints for the start of move_extent, and evacuate_bucket.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-04-20 15:24:07 -04:00
parent 09ebfa6113
commit 5a21764db1
3 changed files with 91 additions and 22 deletions

View File

@ -92,6 +92,17 @@ static int insert_snapshot_whiteouts(struct btree_trans *trans,
return ret;
}
static void trace_move_extent_finish2(struct bch_fs *c, struct bkey_s_c k)
{
if (trace_move_extent_finish_enabled()) {
struct printbuf buf = PRINTBUF;
bch2_bkey_val_to_text(&buf, c, k);
trace_move_extent_finish(c, buf.buf);
printbuf_exit(&buf);
}
}
static void trace_move_extent_fail2(struct data_update *m,
struct bkey_s_c new,
struct bkey_s_c wrote,
@ -342,7 +353,7 @@ restart_drop_extra_replicas:
bch2_btree_iter_set_pos(&iter, next_pos);
this_cpu_add(c->counters[BCH_COUNTER_move_extent_finish], new->k.size);
trace_move_extent_finish(&new->k);
trace_move_extent_finish2(c, bkey_i_to_s_c(&new->k_i));
}
err:
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))

View File

@ -25,6 +25,39 @@
#include <linux/ioprio.h>
#include <linux/kthread.h>
static void trace_move_extent2(struct bch_fs *c, struct bkey_s_c k)
{
if (trace_move_extent_enabled()) {
struct printbuf buf = PRINTBUF;
bch2_bkey_val_to_text(&buf, c, k);
trace_move_extent(c, buf.buf);
printbuf_exit(&buf);
}
}
static void trace_move_extent_read2(struct bch_fs *c, struct bkey_s_c k)
{
if (trace_move_extent_read_enabled()) {
struct printbuf buf = PRINTBUF;
bch2_bkey_val_to_text(&buf, c, k);
trace_move_extent_read(c, buf.buf);
printbuf_exit(&buf);
}
}
static void trace_move_extent_alloc_mem_fail2(struct bch_fs *c, struct bkey_s_c k)
{
if (trace_move_extent_alloc_mem_fail_enabled()) {
struct printbuf buf = PRINTBUF;
bch2_bkey_val_to_text(&buf, c, k);
trace_move_extent_alloc_mem_fail(c, buf.buf);
printbuf_exit(&buf);
}
}
static void progress_list_add(struct bch_fs *c, struct bch_move_stats *stats)
{
mutex_lock(&c->data_progress_lock);
@ -269,6 +302,8 @@ static int bch2_move_extent(struct btree_trans *trans,
unsigned sectors = k.k->size, pages;
int ret = -ENOMEM;
trace_move_extent2(c, k);
bch2_data_update_opts_normalize(k, &data_opts);
if (!data_opts.rewrite_ptrs &&
@ -346,8 +381,7 @@ static int bch2_move_extent(struct btree_trans *trans,
this_cpu_add(c->counters[BCH_COUNTER_io_move], k.k->size);
this_cpu_add(c->counters[BCH_COUNTER_move_extent_read], k.k->size);
trace_move_extent_read(k.k);
trace_move_extent_read2(c, k);
mutex_lock(&ctxt->lock);
atomic_add(io->read_sectors, &ctxt->read_sectors);
@ -373,7 +407,8 @@ err_free_pages:
err_free:
kfree(io);
err:
trace_and_count(c, move_extent_alloc_mem_fail, k.k);
this_cpu_inc(c->counters[BCH_COUNTER_move_extent_alloc_mem_fail]);
trace_move_extent_alloc_mem_fail2(c, k);
return ret;
}
@ -719,6 +754,8 @@ int __bch2_evacuate_bucket(struct btree_trans *trans,
struct bpos bp_pos = POS_MIN;
int ret = 0;
trace_bucket_evacuate(c, &bucket);
bch2_bkey_buf_init(&sk);
/*

View File

@ -33,23 +33,18 @@ DECLARE_EVENT_CLASS(bpos,
);
DECLARE_EVENT_CLASS(bkey,
TP_PROTO(const struct bkey *k),
TP_ARGS(k),
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k),
TP_STRUCT__entry(
__field(u64, inode )
__field(u64, offset )
__field(u32, size )
__string(k, k )
),
TP_fast_assign(
__entry->inode = k->p.inode;
__entry->offset = k->p.offset;
__entry->size = k->size;
__assign_str(k, k);
),
TP_printk("%llu:%llu len %u", __entry->inode,
__entry->offset, __entry->size)
TP_printk("%s", __get_str(k))
);
DECLARE_EVENT_CLASS(btree_node,
@ -667,19 +662,45 @@ TRACE_EVENT(bucket_invalidate,
/* Moving IO */
TRACE_EVENT(bucket_evacuate,
TP_PROTO(struct bch_fs *c, struct bpos *bucket),
TP_ARGS(c, bucket),
TP_STRUCT__entry(
__field(dev_t, dev )
__field(u32, dev_idx )
__field(u64, bucket )
),
TP_fast_assign(
__entry->dev = c->dev;
__entry->dev_idx = bucket->inode;
__entry->bucket = bucket->offset;
),
TP_printk("%d:%d %u:%llu",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->dev_idx, __entry->bucket)
);
DEFINE_EVENT(bkey, move_extent,
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k)
);
DEFINE_EVENT(bkey, move_extent_read,
TP_PROTO(const struct bkey *k),
TP_ARGS(k)
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k)
);
DEFINE_EVENT(bkey, move_extent_write,
TP_PROTO(const struct bkey *k),
TP_ARGS(k)
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k)
);
DEFINE_EVENT(bkey, move_extent_finish,
TP_PROTO(const struct bkey *k),
TP_ARGS(k)
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k)
);
TRACE_EVENT(move_extent_fail,
@ -700,8 +721,8 @@ TRACE_EVENT(move_extent_fail,
);
DEFINE_EVENT(bkey, move_extent_alloc_mem_fail,
TP_PROTO(const struct bkey *k),
TP_ARGS(k)
TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(c, k)
);
TRACE_EVENT(move_data,