[PATCH blktrace v2 05/22] blktrace: add definitions for blk_io_trace2

Johannes Thumshirn posted 22 patches 6 days, 9 hours ago
[PATCH blktrace v2 05/22] blktrace: add definitions for blk_io_trace2
Posted by Johannes Thumshirn 6 days, 9 hours ago
Add 'struct blk_io_trace2' which represents the extended version of the
blktrace protocol.

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

diff --git a/blktrace_api.h b/blktrace_api.h
index 9f435a5..bbf075f 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -27,8 +27,19 @@ enum {
 	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
 };
 
+enum blktrace_cat2 {
+	BLK_TC_ZONE_APPEND      = 1 << 1ull,    /* zone append */
+	BLK_TC_ZONE_RESET       = 1 << 2ull,    /* zone reset */
+	BLK_TC_ZONE_RESET_ALL   = 1 << 3ull,    /* zone reset all */
+	BLK_TC_ZONE_FINISH      = 1 << 4ull,    /* zone finish */
+	BLK_TC_ZONE_OPEN        = 1 << 5ull,    /* zone open */
+	BLK_TC_ZONE_CLOSE       = 1 << 6ull,    /* zone close */
+};
+
 #define BLK_TC_SHIFT		(16)
 #define BLK_TC_ACT(act)		((act) << BLK_TC_SHIFT)
+#define BLK_TC_SHIFT2           (32)
+#define BLK_TC_ACT2(act)        ((__u64)(act) << BLK_TC_SHIFT2)
 
 /*
  * Basic trace actions
@@ -51,6 +62,7 @@ enum {
 	__BLK_TA_REMAP,			/* bio was remapped */
 	__BLK_TA_ABORT,			/* request aborted */
 	__BLK_TA_DRV_DATA,		/* binary driver data */
+	__BLK_TA_ZONE_MGMT,		/* zone management command was issued */
 	__BLK_TA_CGROUP = 1 << 8,
 };
 
@@ -85,12 +97,20 @@ enum blktrace_notify {
 #define BLK_TA_ABORT		(__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
 #define BLK_TA_DRV_DATA		(__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
 
+#define BLK_TA_ZONE_APPEND      (__BLK_TA_COMPLETE |\
+				 BLK_TC_ACT2(BLK_TC_ZONE_APPEND))
+#define BLK_TA_ZONE_MGMT        __BLK_TA_ZONE_MGMT
+#define BLK_TA_ZONE_PLUG        (__BLK_TA_ZONE_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_ZONE_UNPLUG      (__BLK_TA_ZONE_UNPLUG |\
+				 BLK_TC_ACT(BLK_TC_QUEUE))
+
 #define BLK_TN_PROCESS		(__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
 #define BLK_TN_TIMESTAMP	(__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
 #define BLK_TN_MESSAGE		(__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
 
 #define BLK_IO_TRACE_MAGIC	0x65617400
 #define BLK_IO_TRACE_VERSION	0x07
+#define BLK_IO_TRACE2_VERSION	0x08
 
 /*
  * The trace itself
@@ -118,6 +138,21 @@ struct blk_io_trace_remap {
 	__u64 sector_from;
 };
 
+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 */
+};
+
 /*
  * Payload with originating cgroup info
  */
-- 
2.51.0
Re: [PATCH blktrace v2 05/22] blktrace: add definitions for blk_io_trace2
Posted by Damien Le Moal 17 hours ago
On 9/26/25 00:04, Johannes Thumshirn wrote:
> Add 'struct blk_io_trace2' which represents the extended version of the
> blktrace protocol.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  blktrace_api.h | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/blktrace_api.h b/blktrace_api.h
> index 9f435a5..bbf075f 100644
> --- a/blktrace_api.h
> +++ b/blktrace_api.h
> @@ -27,8 +27,19 @@ enum {
>  	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
>  };
>  
> +enum blktrace_cat2 {
> +	BLK_TC_ZONE_APPEND      = 1 << 1ull,    /* zone append */

Kernel side starts this at 1ULL << 16. SO I think you are out of sync with the
kernel side with these user patches...


> +	BLK_TC_ZONE_RESET       = 1 << 2ull,    /* zone reset */
> +	BLK_TC_ZONE_RESET_ALL   = 1 << 3ull,    /* zone reset all */
> +	BLK_TC_ZONE_FINISH      = 1 << 4ull,    /* zone finish */
> +	BLK_TC_ZONE_OPEN        = 1 << 5ull,    /* zone open */
> +	BLK_TC_ZONE_CLOSE       = 1 << 6ull,    /* zone close */
> +};

-- 
Damien Le Moal
Western Digital Research