X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=blkparse_fmt.c;h=c42e6d7b7219d532c4ae34d937e0ea9660535426;hb=d025d6c67760a52e34e6c7352f33ad5dbbb4f6f4;hp=bc38114ea893f7d745035747c5ceaa42d6d91595;hpb=7bd4fd0a4fca645bb50a641afac1e460a4e32dfd;p=blktrace.git diff --git a/blkparse_fmt.c b/blkparse_fmt.c index bc38114..c42e6d7 100644 --- a/blkparse_fmt.c +++ b/blkparse_fmt.c @@ -11,7 +11,7 @@ #include "blktrace.h" -#define VALID_SPECS "ABCDFGMPQRSTUWX" +#define VALID_SPECS "ABCDFGIMPQRSTUWX" #define HEADER "%D %2c %8s %5T.%9t %5p %2a %3d " @@ -44,19 +44,8 @@ int add_format_spec(char *option) return 1; } option += 2; - if (*option == '\0') { - fprintf(stderr,"Bad format specifier - need fmt %s\n", option); - return 1; - } - /* - * Set both merges (front and back) - */ - if (spec == 'M') { - override_format['B'] = strdup(option); - override_format['M'] = strdup(option); - } else - override_format[spec] = strdup(option); + override_format[spec] = strdup(option); return 0; } @@ -65,19 +54,29 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t) { int w = t->action & BLK_TC_ACT(BLK_TC_WRITE); int a = t->action & BLK_TC_ACT(BLK_TC_AHEAD); - int b = t->action & BLK_TC_ACT(BLK_TC_BARRIER); int s = t->action & BLK_TC_ACT(BLK_TC_SYNC); int m = t->action & BLK_TC_ACT(BLK_TC_META); + 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); int i = 0; - if (w) + if (f) + rwbs[i++] = 'F'; /* flush */ + + if (d) + rwbs[i++] = 'D'; + else if (w) rwbs[i++] = 'W'; - else + else if (t->bytes) rwbs[i++] = 'R'; + else + rwbs[i++] = 'N'; + + if (u) + rwbs[i++] = 'F'; /* fua */ if (a) rwbs[i++] = 'A'; - if (b) - rwbs[i++] = 'B'; if (s) rwbs[i++] = 'S'; if (m) @@ -158,11 +157,11 @@ static unsigned int get_pdu_int(struct blk_io_trace *t) static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_remap *r) { struct blk_io_trace_remap *__r = pdu_start(t); - __u64 sector = __r->sector; + __u64 sector_from = __r->sector_from; - r->device = be32_to_cpu(__r->device); r->device_from = be32_to_cpu(__r->device_from); - r->sector = be64_to_cpu(sector); + r->device_to = be32_to_cpu(__r->device_to); + r->sector_from = be64_to_cpu(sector_from); } static void print_field(char *act, struct per_cpu_info *pci, @@ -194,7 +193,7 @@ static void print_field(char *act, struct per_cpu_info *pci, break; } case 'd': { - char rwbs[6]; + char rwbs[8]; fill_rwbs(rwbs, t); fprintf(ofp, strcat(format, "s"), rwbs); @@ -290,20 +289,24 @@ static void process_default(char *act, struct per_cpu_info *pci, struct blk_io_trace *t, unsigned long long elapsed, int pdu_len, unsigned char *pdu_buf) { - struct blk_io_trace_remap r = { .device = 0, }; - char rwbs[6]; + struct blk_io_trace_remap r = { .device_from = 0, }; + char rwbs[8]; char *name; fill_rwbs(rwbs, t); + /* + * For remaps we have to modify the device using the remap structure + * passed up. + */ + if (act[0] == 'A') { + get_pdu_remap(t, &r); + t->device = r.device_to; + } + /* * The header is always the same */ - if (act[0] == 'A') { /* Remap */ - get_pdu_remap(t, &r); - t->device = r.device_from; - } - fprintf(ofp, "%3d,%-3d %2d %8d %5d.%09lu %5u %2s %3s ", MAJOR(t->device), MINOR(t->device), pci->cpu, t->sequence, (int) SECONDS(t->time), (unsigned long) NANO_SECONDS(t->time), @@ -321,13 +324,23 @@ static void process_default(char *act, struct per_cpu_info *pci, fprintf(ofp, "[%d]\n", t->error); } else { if (elapsed != -1ULL) { - fprintf(ofp, "%llu + %u (%8llu) [%d]\n", - (unsigned long long) t->sector, - t_sec(t), elapsed, t->error); + if (t_sec(t)) + fprintf(ofp, "%llu + %u (%8llu) [%d]\n", + (unsigned long long) t->sector, + t_sec(t), elapsed, t->error); + else + fprintf(ofp, "%llu (%8llu) [%d]\n", + (unsigned long long) t->sector, + elapsed, t->error); } else { - fprintf(ofp, "%llu + %u [%d]\n", - (unsigned long long) t->sector, - t_sec(t), t->error); + if (t_sec(t)) + fprintf(ofp, "%llu + %u [%d]\n", + (unsigned long long) t->sector, + t_sec(t), t->error); + else + fprintf(ofp, "%llu [%d]\n", + (unsigned long long) t->sector, + t->error); } } break; @@ -335,7 +348,7 @@ static void process_default(char *act, struct per_cpu_info *pci, case 'D': /* Issue */ case 'I': /* Insert */ case 'Q': /* Queue */ - case 'W': /* Bounce */ + case 'B': /* Bounce */ if (t->action & BLK_TC_ACT(BLK_TC_PC)) { char *p; fprintf(ofp, "%u ", t->bytes); @@ -345,24 +358,33 @@ static void process_default(char *act, struct per_cpu_info *pci, fprintf(ofp, "[%s]\n", name); } else { if (elapsed != -1ULL) { - fprintf(ofp, "%llu + %u (%8llu) [%s]\n", - (unsigned long long) t->sector, - t_sec(t), elapsed, name); + if (t_sec(t)) + fprintf(ofp, "%llu + %u (%8llu) [%s]\n", + (unsigned long long) t->sector, + t_sec(t), elapsed, name); + else + fprintf(ofp, "(%8llu) [%s]\n", elapsed, + name); } else { - fprintf(ofp, "%llu + %u [%s]\n", - (unsigned long long) t->sector, - t_sec(t), name); + if (t_sec(t)) + fprintf(ofp, "%llu + %u [%s]\n", + (unsigned long long) t->sector, + t_sec(t), name); + else + fprintf(ofp, "[%s]\n", name); } } break; - case 'B': /* Back merge */ + case 'M': /* Back merge */ case 'F': /* Front merge */ - case 'M': /* Front or back merge */ case 'G': /* Get request */ case 'S': /* Sleep request */ - fprintf(ofp, "%llu + %u [%s]\n", (unsigned long long) t->sector, - t_sec(t), name); + if (t_sec(t)) + fprintf(ofp, "%llu + %u [%s]\n", + (unsigned long long) t->sector, t_sec(t), name); + else + fprintf(ofp, "[%s]\n", name); break; case 'P': /* Plug */ @@ -375,17 +397,22 @@ static void process_default(char *act, struct per_cpu_info *pci, break; case 'A': /* remap */ + get_pdu_remap(t, &r); fprintf(ofp, "%llu + %u <- (%d,%d) %llu\n", (unsigned long long) t->sector, t_sec(t), - MAJOR(r.device), MINOR(r.device), - (unsigned long long) r.sector); + MAJOR(r.device_from), MINOR(r.device_from), + (unsigned long long) r.sector_from); break; - + case 'X': /* Split */ fprintf(ofp, "%llu / %u [%s]\n", (unsigned long long) t->sector, get_pdu_int(t), name); break; + case 'm': /* Message */ + fprintf(ofp, "%*s\n", pdu_len, pdu_buf); + break; + default: fprintf(stderr, "Unknown action %c\n", act[0]); break; @@ -423,7 +450,7 @@ void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace *t, case 'r': fprintf(ofp, "\r"); break; case 't': fprintf(ofp, "\t"); break; default: - fprintf(stderr, + fprintf(stderr, "Invalid escape char in format %c\n", p[1]); exit(1);