blktrace replay: delay support
[fio.git] / blktrace.c
index 864e9dc7900bf4971fcc70dc7720a0b89be7b42e..5793773a10837799dea5644cef66277ffaf85c7e 100644 (file)
@@ -100,6 +100,7 @@ static void handle_trace(struct thread_data *td, struct blk_io_trace *t,
 
        rw = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
        ios[rw]++;
+       td->o.size += t->bytes;
        store_ipo(td, t->sector, t->bytes, rw, ttime);
 }
 
@@ -109,9 +110,10 @@ static void handle_trace(struct thread_data *td, struct blk_io_trace *t,
  */
 int load_blktrace(struct thread_data *td, const char *filename)
 {
-       unsigned long long ttime;
+       unsigned long long ttime, delay;
        struct blk_io_trace t;
        unsigned long ios[2];
+       unsigned int cpu;
        int fd;
 
        fd = open(filename, O_RDONLY);
@@ -120,8 +122,11 @@ int load_blktrace(struct thread_data *td, const char *filename)
                return 1;
        }
 
+       td->o.size = 0;
+
        ios[0] = ios[1] = 0;
        ttime = 0;
+       cpu = 0;
        do {
                /*
                 * Once this is working fully, I'll add a layer between
@@ -154,10 +159,16 @@ int load_blktrace(struct thread_data *td, const char *filename)
                        td_verror(td, ret, "blktrace lseek");
                        goto err;
                }
-               if (!ttime)
+               if (!ttime) {
                        ttime = t.time;
-               handle_trace(td, &t, t.time - ttime, ios);
+                       cpu = t.cpu;
+               }
+               delay = 0;
+               if (cpu == t.cpu)
+                       delay = t.time - ttime;
+               handle_trace(td, &t, delay, ios);
                ttime = t.time;
+               cpu = t.cpu;
        } while (1);
 
        close(fd);