#include <stdio.h>
-#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <math.h>
#include "../blktrace_api.h"
#include "../os/os.h"
#include "../log.h"
-#include "../lib/linux-dev-lookup.h"
+#include "../minmax.h"
+#include "../oslib/linux-dev-lookup.h"
#define TRACE_FIFO_SIZE 8192
uint64_t first_ttime[DDIR_RWDIR_CNT];
uint64_t last_ttime[DDIR_RWDIR_CNT];
- uint64_t kb[DDIR_RWDIR_CNT];
+ uint64_t kib[DDIR_RWDIR_CNT];
uint64_t start_delay;
};
i = inflight_find(t->sector + (t->bytes >> 9));
if (i) {
- i->p->o.kb[t_to_rwdir(t)] += (t->bytes >> 10);
+ i->p->o.kib[t_to_rwdir(t)] += (t->bytes >> 10);
i->p->o.complete_seen = 1;
inflight_remove(i);
}
return bsb->nr - bsa->nr;
}
-static unsigned long o_to_kb_rate(struct btrace_out *o, int rw)
+static unsigned long o_to_kib_rate(struct btrace_out *o, int rw)
{
uint64_t usec = (o->last_ttime[rw] - o->first_ttime[rw]) / 1000ULL;
uint64_t val;
if (!usec)
return 0;
- val = o->kb[rw] * 1000ULL;
+ val = o->kib[rw] * 1000ULL;
return val / usec;
}
printf("\tmerges: %lu (perc=%3.2f%%)\n", o->merges[i], perc);
perc = ((float) o->seq[i] * 100.0) / (float) o->ios[i];
printf("\tseq: %lu (perc=%3.2f%%)\n", (unsigned long) o->seq[i], perc);
- printf("\trate: %lu KB/sec\n", o_to_kb_rate(o, i));
+ printf("\trate: %lu KiB/sec\n", o_to_kib_rate(o, i));
for (j = 0; j < o->nr_bs[i]; j++) {
struct bs *bs = &o->bs[i][j];
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;
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]);
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
unsigned long rate;
- rate = o_to_kb_rate(o, i);
+ rate = o_to_kib_rate(o, i);
if (i)
printf(",");
if (rate)
if (output_ascii)
__output_p_ascii(p, ios);
else
- ret = __output_p_fio(p, ios);
+ ret = __output_p_fio(p, ios, "");
return ret;
}
for (i = 0; i < DDIR_RWDIR_CNT; i++) {
unsigned long this_rate;
- this_rate = o_to_kb_rate(o, i);
+ this_rate = o_to_kib_rate(o, i);
if (this_rate < rate_threshold) {
remove_ddir(o, i);
this_rate = 0;
oa->ios[i] += ob->ios[i];
oa->merges[i] += ob->merges[i];
oa->seq[i] += ob->seq[i];
- oa->kb[i] += ob->kb[i];
+ oa->kib[i] += ob->kib[i];
oa->first_ttime[i] = min(oa->first_ttime[i], ob->first_ttime[i]);
oa->last_ttime[i] = max(oa->last_ttime[i], ob->last_ttime[i]);
merge_bs(&oa->bs[i], &oa->nr_bs[i], ob->bs[i], ob->nr_bs[i]);
return 1;
}
-static void check_merges(struct btrace_pid *p, struct flist_head *pid_list)
+static void check_merges(struct btrace_pid *p, struct flist_head *pidlist)
{
struct flist_head *e, *tmp;
if (p->ignore)
return;
- flist_for_each_safe(e, tmp, pid_list) {
+ flist_for_each_safe(e, tmp, pidlist) {
struct btrace_pid *pidb;
pidb = flist_entry(e, struct btrace_pid, pid_list);
log_err("\t-n\tNumber IOS threshold to ignore task\n");
log_err("\t-f\tFio job file output\n");
log_err("\t-d\tUse this file/device for replay\n");
- log_err("\t-r\tIgnore jobs with less than this KB/sec rate\n");
+ log_err("\t-r\tIgnore jobs with less than this KiB/sec rate\n");
log_err("\t-R\tSet rate in fio job (def=%u)\n", set_rate);
log_err("\t-D\tCap queue depth at this value (def=%u)\n", max_depth);
log_err("\t-c\tCollapse \"identical\" jobs (def=%u)\n", collapse_entries);
int fd, ret;
*swap = -1;
-
+
fd = open(trace_file, O_RDONLY);
if (fd < 0) {
perror("open");