Commit 5a21764d authored by Kent Overstreet's avatar Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 09ebfa61
...@@ -92,6 +92,17 @@ static int insert_snapshot_whiteouts(struct btree_trans *trans, ...@@ -92,6 +92,17 @@ static int insert_snapshot_whiteouts(struct btree_trans *trans,
return ret; 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, static void trace_move_extent_fail2(struct data_update *m,
struct bkey_s_c new, struct bkey_s_c new,
struct bkey_s_c wrote, struct bkey_s_c wrote,
...@@ -342,7 +353,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans, ...@@ -342,7 +353,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
bch2_btree_iter_set_pos(&iter, next_pos); bch2_btree_iter_set_pos(&iter, next_pos);
this_cpu_add(c->counters[BCH_COUNTER_move_extent_finish], new->k.size); 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: err:
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
......
...@@ -25,6 +25,39 @@ ...@@ -25,6 +25,39 @@
#include <linux/ioprio.h> #include <linux/ioprio.h>
#include <linux/kthread.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) static void progress_list_add(struct bch_fs *c, struct bch_move_stats *stats)
{ {
mutex_lock(&c->data_progress_lock); mutex_lock(&c->data_progress_lock);
...@@ -269,6 +302,8 @@ static int bch2_move_extent(struct btree_trans *trans, ...@@ -269,6 +302,8 @@ static int bch2_move_extent(struct btree_trans *trans,
unsigned sectors = k.k->size, pages; unsigned sectors = k.k->size, pages;
int ret = -ENOMEM; int ret = -ENOMEM;
trace_move_extent2(c, k);
bch2_data_update_opts_normalize(k, &data_opts); bch2_data_update_opts_normalize(k, &data_opts);
if (!data_opts.rewrite_ptrs && if (!data_opts.rewrite_ptrs &&
...@@ -346,8 +381,7 @@ static int bch2_move_extent(struct btree_trans *trans, ...@@ -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_io_move], k.k->size);
this_cpu_add(c->counters[BCH_COUNTER_move_extent_read], 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); mutex_lock(&ctxt->lock);
atomic_add(io->read_sectors, &ctxt->read_sectors); atomic_add(io->read_sectors, &ctxt->read_sectors);
...@@ -373,7 +407,8 @@ static int bch2_move_extent(struct btree_trans *trans, ...@@ -373,7 +407,8 @@ static int bch2_move_extent(struct btree_trans *trans,
err_free: err_free:
kfree(io); kfree(io);
err: 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; return ret;
} }
...@@ -719,6 +754,8 @@ int __bch2_evacuate_bucket(struct btree_trans *trans, ...@@ -719,6 +754,8 @@ int __bch2_evacuate_bucket(struct btree_trans *trans,
struct bpos bp_pos = POS_MIN; struct bpos bp_pos = POS_MIN;
int ret = 0; int ret = 0;
trace_bucket_evacuate(c, &bucket);
bch2_bkey_buf_init(&sk); bch2_bkey_buf_init(&sk);
/* /*
......
...@@ -33,23 +33,18 @@ DECLARE_EVENT_CLASS(bpos, ...@@ -33,23 +33,18 @@ DECLARE_EVENT_CLASS(bpos,
); );
DECLARE_EVENT_CLASS(bkey, DECLARE_EVENT_CLASS(bkey,
TP_PROTO(const struct bkey *k), TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(k), TP_ARGS(c, k),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(u64, inode ) __string(k, k )
__field(u64, offset )
__field(u32, size )
), ),
TP_fast_assign( TP_fast_assign(
__entry->inode = k->p.inode; __assign_str(k, k);
__entry->offset = k->p.offset;
__entry->size = k->size;
), ),
TP_printk("%llu:%llu len %u", __entry->inode, TP_printk("%s", __get_str(k))
__entry->offset, __entry->size)
); );
DECLARE_EVENT_CLASS(btree_node, DECLARE_EVENT_CLASS(btree_node,
...@@ -667,19 +662,45 @@ TRACE_EVENT(bucket_invalidate, ...@@ -667,19 +662,45 @@ TRACE_EVENT(bucket_invalidate,
/* Moving IO */ /* 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, DEFINE_EVENT(bkey, move_extent_read,
TP_PROTO(const struct bkey *k), TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(k) TP_ARGS(c, k)
); );
DEFINE_EVENT(bkey, move_extent_write, DEFINE_EVENT(bkey, move_extent_write,
TP_PROTO(const struct bkey *k), TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(k) TP_ARGS(c, k)
); );
DEFINE_EVENT(bkey, move_extent_finish, DEFINE_EVENT(bkey, move_extent_finish,
TP_PROTO(const struct bkey *k), TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(k) TP_ARGS(c, k)
); );
TRACE_EVENT(move_extent_fail, TRACE_EVENT(move_extent_fail,
...@@ -700,8 +721,8 @@ TRACE_EVENT(move_extent_fail, ...@@ -700,8 +721,8 @@ TRACE_EVENT(move_extent_fail,
); );
DEFINE_EVENT(bkey, move_extent_alloc_mem_fail, DEFINE_EVENT(bkey, move_extent_alloc_mem_fail,
TP_PROTO(const struct bkey *k), TP_PROTO(struct bch_fs *c, const char *k),
TP_ARGS(k) TP_ARGS(c, k)
); );
TRACE_EVENT(move_data, TRACE_EVENT(move_data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment