Add the definitions for I/O priority tracing from the kernel UAPI: the BLKTRACE_FLAG_IOPRIO setup flag, the __BLK_TA_IOPRIO action flag and the ioprio member of struct blk_io_trace2. Convert the ioprio when the trace was recorded on a host with different endianness, and clear __BLK_TA_IOPRIO when converting to the v1 format, which cannot carry an I/O priority. Signed-off-by: Johannes Thumshirn --- blktrace.h | 3 ++- blktrace_api.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/blktrace.h b/blktrace.h index 370e921..ea48f3e 100644 --- a/blktrace.h +++ b/blktrace.h @@ -137,7 +137,7 @@ static inline void bit2_to_bit(struct blk_io_trace2 *new, old->time = new->time; old->sector = new->sector; old->bytes = new->bytes; - old->action = new->action; + old->action = new->action & ~__BLK_TA_IOPRIO; old->pid = new->pid; old->device = new->device; old->cpu = new->cpu; @@ -165,6 +165,7 @@ static inline void bit2_trace_to_cpu(struct blk_io_trace2 *t) t->cpu = be32_to_cpu(t->cpu); t->error = be16_to_cpu(t->error); t->pdu_len = be16_to_cpu(t->pdu_len); + t->ioprio = be16_to_cpu(t->ioprio); } static inline void bit_trace_to_cpu(struct blk_io_trace *t) diff --git a/blktrace_api.h b/blktrace_api.h index 00740d9..4b56e96 100644 --- a/blktrace_api.h +++ b/blktrace_api.h @@ -65,6 +65,7 @@ enum { __BLK_TA_ZONE_PLUG, /* zone write plug was plugged */ __BLK_TA_ZONE_UNPLUG, /* zone write plug was unplugged */ __BLK_TA_CGROUP = 1 << 8, + __BLK_TA_IOPRIO = 1 << 9, }; /* @@ -150,7 +151,8 @@ struct blk_io_trace2 { __u32 cpu; /* on what cpu did it happen */ __u16 error; /* completion error */ __u16 pdu_len; /* length of data after this trace */ - __u8 pad[12]; + __u16 ioprio; /* IO priority */ + __u8 pad[10]; /* cgroup id will be stored here if exists */ }; -- 2.56.1