* [PATCH] blktrace: fix ftrace record generation for v2 format
@ 2026-11-24 12:42 Johannes Thumshirn
2026-11-25 4:56 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2026-11-24 12:42 UTC (permalink / raw)
To: axboe@kernel.dk
Cc: linux-block, Damien Le Moal, Niklas Cassel, Christoph Hellwig,
Johannes Thumshirn
Since commit 4d8bc7bd4f73 ("blktrace: move ftrace blk_io_tracer to
blk_io_trace2") ftrace's blktrace records are in the blk_io_trace2
format, but blk_trace_synthesize_old_trace() still copies the raw bytes
after sector like it did in the v1 layout. With the 'bin' trace option
set, the synthesized v1 records therefore contain the pid in the action
field, the action in the pid and device fields and so on, and the PDU is
read from the wrong offset.
Manually create the struct in blk_trace_synthesize_old_trace() instead
of copying over.
Fixes: 4d8bc7bd4f73 ("blktrace: move ftrace blk_io_tracer to blk_io_trace2")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
kernel/trace/blktrace.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 8cd2520b4c99..27936cd64fc2 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1770,15 +1770,21 @@ static void blk_trace_synthesize_old_trace(struct trace_iterator *iter)
{
struct trace_seq *s = &iter->seq;
struct blk_io_trace2 *t = (struct blk_io_trace2 *)iter->ent;
- const int offset = offsetof(struct blk_io_trace2, sector);
struct blk_io_trace old = {
.magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION,
.time = iter->ts,
+ .sector = t->sector,
+ .bytes = t->bytes,
+ .action = lower_32_bits(t->action),
+ .pid = t->pid,
+ .device = t->device,
+ .cpu = t->cpu,
+ .error = t->error,
+ .pdu_len = t->pdu_len,
};
- trace_seq_putmem(s, &old, offset);
- trace_seq_putmem(s, &t->sector,
- sizeof(old) - offset + t->pdu_len);
+ trace_seq_putmem(s, &old, sizeof(old));
+ trace_seq_putmem(s, t + 1, t->pdu_len);
}
static enum print_line_t
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] blktrace: fix ftrace record generation for v2 format
2026-11-24 12:42 [PATCH] blktrace: fix ftrace record generation for v2 format Johannes Thumshirn
@ 2026-11-25 4:56 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-11-25 4:56 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: axboe@kernel.dk, linux-block, Damien Le Moal, Niklas Cassel
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 4:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 12:42 [PATCH] blktrace: fix ftrace record generation for v2 format Johannes Thumshirn
2026-11-25 4:56 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox