@@ -5,6 +5,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdint.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
@@ -15,6 +16,11 @@
#define HEADER "%D %2c %8s %5T.%9t %5p %2a %3d "
+#ifdef CONFIG_BLKTRACE_EXT
+extern uint32_t blkparse_prio_mask;
+extern int bparse_track_prio;
+#endif /* CONFIG_BLKTRACE_EXT */
+
static char *override_format[256];
static inline int valid_spec(int spec)
@@ -52,6 +58,17 @@ int add_format_spec(char *option)
static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
{
+#ifdef CONFIG_BLKTRACE_EXT
+ uint64_t w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
+ uint64_t a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
+ uint64_t s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
+ uint64_t m = t->action & BLK_TC_ACT(BLK_TC_META);
+ uint64_t d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
+ uint64_t f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
+ uint64_t u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+ uint64_t z = t->action & BLK_TC_ACT(BLK_TC_WRITE_ZEROES);
+ uint64_t r = t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET);
+#else
int w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
int a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
int s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
@@ -59,6 +76,7 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
int d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
int f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
int u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+#endif /* CONFIG_BLKTRACE_EXT */
int i = 0;
if (f)
@@ -66,6 +84,15 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
if (d)
rwbs[i++] = 'D';
+#ifdef CONFIG_BLKTRACE_EXT
+ else if (z) {
+ rwbs[i++] = 'W'; /* write-zeroes */
+ rwbs[i++] = 'Z';
+ } else if (r) {
+ rwbs[i++] = 'Z'; /* zone-reset */
+ rwbs[i++] = 'R';
+ }
+#endif /* CONFIG_BLKTRACE_EXT */
else if (w)
rwbs[i++] = 'W';
else if (t->bytes)
@@ -311,6 +338,35 @@ static void process_default(char *act, struct per_cpu_info *pci,
MAJOR(t->device), MINOR(t->device), pci->cpu, t->sequence,
(int) SECONDS(t->time), (unsigned long) NANO_SECONDS(t->time),
t->pid, act, rwbs);
+#ifdef CONFIG_BLKTRACE_EXT
+ /* XXX: optimize the print format somthing like NN/RT/BT/ID */
+ if (bparse_track_prio) {
+ switch (IOPRIO_PRIO_CLASS(t->ioprio)) {
+ case IOPRIO_CLASS_NONE:
+ if (blkparse_prio_mask & 0x1)
+ fprintf(ofp, "NONE %1lu ",
+ IOPRIO_PRIO_DATA(t->ioprio));
+ break;
+ case IOPRIO_CLASS_RT:
+ if (blkparse_prio_mask & 0x2)
+ fprintf(ofp, "REAL %1lu ",
+ IOPRIO_PRIO_DATA(t->ioprio));
+ break;
+ case IOPRIO_CLASS_BE:
+ if (blkparse_prio_mask & 0x4)
+ fprintf(ofp, "BEST %1lu ",
+ IOPRIO_PRIO_DATA(t->ioprio));
+ break;
+ case IOPRIO_CLASS_IDLE:
+ if (blkparse_prio_mask & 0x8)
+ fprintf(ofp, "IDLE %1lu ",
+ IOPRIO_PRIO_DATA(t->ioprio));
+ break;
+ default:
+ fprintf(ofp, "ERRR ");
+ }
+ }
+#endif /* CONFIG_BLKTRACE_EXT */
name = find_process_name(t->pid);
@@ -324,7 +380,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
fprintf(ofp, "[%d]\n", t->error);
} else {
if (elapsed != -1ULL) {
+#ifdef CONFIG_BLKTRACE_EXT
+ if (t_sec(t) || t->sector) /* needed for ZR */
+#else
if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
fprintf(ofp, "%llu + %u (%8llu) [%d]\n",
(unsigned long long) t->sector,
t_sec(t), elapsed, t->error);
@@ -333,7 +393,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
(unsigned long long) t->sector,
elapsed, t->error);
} else {
+#ifdef CONFIG_BLKTRACE_EXT
+ if (t_sec(t) || t->sector) /* needed for ZR */
+#else
if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
fprintf(ofp, "%llu + %u [%d]\n",
(unsigned long long) t->sector,
t_sec(t), t->error);
@@ -358,7 +422,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
fprintf(ofp, "[%s]\n", name);
} else {
if (elapsed != -1ULL) {
+#ifdef CONFIG_BLKTRACE_EXT
if (t_sec(t))
+#else
+ if (t_sec(t) || t->sector) /* needed for ZR */
+#endif /* CONFIG_BLKTRACE_EXT */
fprintf(ofp, "%llu + %u (%8llu) [%s]\n",
(unsigned long long) t->sector,
t_sec(t), elapsed, name);
@@ -366,7 +434,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
fprintf(ofp, "(%8llu) [%s]\n", elapsed,
name);
} else {
+#ifdef CONFIG_BLKTRACE_EXT
+ if (t_sec(t) || t->sector) /* needed for ZR */
+#else
if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
fprintf(ofp, "%llu + %u [%s]\n",
(unsigned long long) t->sector,
t_sec(t), name);
@@ -380,7 +452,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
case 'F': /* Front merge */
case 'G': /* Get request */
case 'S': /* Sleep request */
+#ifdef CONFIG_BLKTRACE_EXT
+ if (t_sec(t) || t->sector) /* needed for ZR */
+#else
if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
fprintf(ofp, "%llu + %u [%s]\n",
(unsigned long long) t->sector, t_sec(t), name);
else