#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
+static void io_warn_unless(struct blk_io_trace *t, int condition,
+ const char *fmt, ...)
+{
+ va_list ap;
+
+ if (condition)
+ return;
+ va_start(ap, fmt);
+ printf("(%d,%d) request %llu + %u: ",
+ MAJOR(t->device), MINOR(t->device),
+ t->sector, t->bytes);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
static void output_binary(void *buf, int len)
{
if (dump_binary) {
if (!iot->ppm)
iot->ppm = add_ppm_hash(pid, "unknown");
iot->sector = sector;
+ iot->allocation_time = -1ULL;
+ iot->queue_time = -1ULL;
+ iot->dispatch_time = -1ULL;
+ iot->completion_time = -1ULL;
track_rb_insert(pdi, iot);
}
return;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->allocation_time == -1ULL,
+ "confused about %s time", "allocation");
iot->allocation_time = t->time;
}
return;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
+ "confused about %s time", "dispatch");
iot->dispatch_time = t->time;
}
return -1;
iot = find_track(pdi, t->pid, t->sector);
+ io_warn_unless(t, iot->queue_time == -1ULL,
+ "confused about %s time", "queue");
iot->queue_time = t->time;
- if (!iot->allocation_time)
+ if (iot->allocation_time == -1ULL)
return -1;
elapsed = iot->queue_time - iot->allocation_time;
static unsigned long long log_track_issue(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
+ unsigned long long elapsed = -1ULL;
struct io_track *iot;
if (!track_ios)
return -1;
}
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
+ "confused about %s time", "dispatch");
iot->dispatch_time = t->time;
- elapsed = iot->dispatch_time - iot->queue_time;
+ if (iot->queue_time != -1ULL)
+ elapsed = iot->dispatch_time - iot->queue_time;
- if (per_process_stats) {
+ if (elapsed != -1ULL && per_process_stats) {
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
static unsigned long long log_track_complete(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
+ unsigned long long elapsed = -1ULL;
struct io_track *iot;
if (!track_ios)
return -1;
}
+ io_warn_unless(t, iot->completion_time == -1ULL,
+ "confused about %s time", "completion");
iot->completion_time = t->time;
- elapsed = iot->completion_time - iot->dispatch_time;
+ if (iot->dispatch_time != -1ULL)
+ elapsed = iot->completion_time - iot->dispatch_time;
- if (per_process_stats) {
+ if (elapsed != -1ULL && per_process_stats) {
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;