X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=t%2Fbtrace2fio.c;h=6dca39cbe0a6ffe13369f76e3aee7337ea6b7130;hb=acc481b6d34aab3ee6e19f22b64f8bf0dd30480c;hp=4cdb38d10d3ec8c53ee265787124b70a76893556;hpb=4870138d26a450f9ed900d0a950d3c1a3888eddf;p=fio.git diff --git a/t/btrace2fio.c b/t/btrace2fio.c index 4cdb38d1..6dca39cb 100644 --- a/t/btrace2fio.c +++ b/t/btrace2fio.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -12,6 +11,7 @@ #include "../blktrace_api.h" #include "../os/os.h" #include "../log.h" +#include "../minmax.h" #include "../oslib/linux-dev-lookup.h" #define TRACE_FIFO_SIZE 8192 @@ -645,7 +645,8 @@ static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios) printf("\n"); } -static int __output_p_fio(struct btrace_pid *p, unsigned long *ios) +static int __output_p_fio(struct btrace_pid *p, unsigned long *ios, + const char *name_postfix) { struct btrace_out *o = &p->o; unsigned long total; @@ -654,15 +655,30 @@ static int __output_p_fio(struct btrace_pid *p, unsigned long *ios) int i, j; if ((o->ios[0] + o->ios[1]) && o->ios[2]) { - log_err("fio: trace has both read/write and trim\n"); - return 1; + unsigned long ios_bak[DDIR_RWDIR_CNT]; + + memcpy(ios_bak, o->ios, DDIR_RWDIR_CNT * sizeof(unsigned long)); + + /* create job for read/write */ + o->ios[2] = 0; + __output_p_fio(p, ios, ""); + o->ios[2] = ios_bak[2]; + + /* create job for trim */ + o->ios[0] = 0; + o->ios[1] = 0; + __output_p_fio(p, ios, "_trim"); + o->ios[0] = ios_bak[0]; + o->ios[1] = ios_bak[1]; + + return 0; } if (!p->nr_files) { log_err("fio: no devices found\n"); return 1; } - printf("[pid%u", p->pid); + printf("[pid%u%s", p->pid, name_postfix); if (p->nr_merge_pids) for (i = 0; i < p->nr_merge_pids; i++) printf(",pid%u", p->merge_pids[i]); @@ -783,7 +799,7 @@ static int __output_p(struct btrace_pid *p, unsigned long *ios) if (output_ascii) __output_p_ascii(p, ios); else - ret = __output_p_fio(p, ios); + ret = __output_p_fio(p, ios, ""); return ret; } @@ -1037,7 +1053,7 @@ static int trace_needs_swap(const char *trace_file, int *swap) int fd, ret; *swap = -1; - + fd = open(trace_file, O_RDONLY); if (fd < 0) { perror("open");