[PATCH 04/16] blktrace: add definitions for struct blk_io_trace2

Johannes Thumshirn posted 16 patches 3 weeks, 2 days ago
There is a newer version of this series
[PATCH 04/16] blktrace: add definitions for struct blk_io_trace2
Posted by Johannes Thumshirn 3 weeks, 2 days ago
Add definitions for the extended version of the blktrace protocol using a
wider action type to be able to record new actions in the kernel.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 include/uapi/linux/blktrace_api.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
index ba61374f90d8..01779f84d09f 100644
--- a/include/uapi/linux/blktrace_api.h
+++ b/include/uapi/linux/blktrace_api.h
@@ -94,6 +94,7 @@ enum blktrace_notify {
 
 #define BLK_IO_TRACE_MAGIC	0x65617400
 #define BLK_IO_TRACE_VERSION	0x07
+#define BLK_IO_TRACE2_VERSION	0x08
 
 /*
  * The trace itself
@@ -113,6 +114,20 @@ struct blk_io_trace {
 	/* cgroup id will be stored here if exists */
 };
 
+struct blk_io_trace2 {
+	__u32 magic;		/* MAGIC << 8 | BLK_IO_TRACE2_VERSION */
+	__u32 sequence;		/* event number */
+	__u64 time;		/* in nanoseconds */
+	__u64 sector;		/* disk offset */
+	__u32 bytes;		/* transfer length */
+	__u32 pid;		/* who did it */
+	__u64 action;		/* what happened */
+	__u32 device;		/* device number */
+	__u32 cpu;		/* on what cpu did it happen */
+	__u16 error;		/* completion error */
+	__u16 pdu_len;		/* length of data after this trace */
+	/* cgroup id will be stored here if exists */
+};
 /*
  * The remap event
  */
-- 
2.51.0
Re: [PATCH 04/16] blktrace: add definitions for struct blk_io_trace2
Posted by Christoph Hellwig 1 week, 6 days ago
On Tue, Sep 09, 2025 at 01:05:59PM +0200, Johannes Thumshirn wrote:
> +struct blk_io_trace2 {
> +	__u32 magic;		/* MAGIC << 8 | BLK_IO_TRACE2_VERSION */
> +	__u32 sequence;		/* event number */
> +	__u64 time;		/* in nanoseconds */
> +	__u64 sector;		/* disk offset */
> +	__u32 bytes;		/* transfer length */
> +	__u32 pid;		/* who did it */
> +	__u64 action;		/* what happened */
> +	__u32 device;		/* device number */
> +	__u32 cpu;		/* on what cpu did it happen */
> +	__u16 error;		/* completion error */
> +	__u16 pdu_len;		/* length of data after this trace */
> +	/* cgroup id will be stored here if exists */
> +};

This structure is not u64-aligned, which means it will have different
sizes for x86-32 vs all other architectures, making it a pain to handle.

Also maybe add some extra padding so that we can extend this?