blktrace: kill zero sized write test
[fio.git] / blktrace.c
index 1d5403a5a0fc59cad41278ed8a368033c733fcf0..e256d633d929cd5f7b60936bdb39bb84cddc9b48 100644 (file)
@@ -222,8 +222,9 @@ static void store_ipo(struct thread_data *td, unsigned long long offset,
                      unsigned int bytes, int rw, unsigned long long ttime,
                      int fileno, unsigned int bs)
 {
-       struct io_piece *ipo = malloc(sizeof(*ipo));
+       struct io_piece *ipo;
 
+       ipo = calloc(1, sizeof(*ipo));
        init_ipo(ipo);
 
        ipo->offset = offset * bs;
@@ -268,10 +269,11 @@ static void handle_trace_discard(struct thread_data *td,
                                 unsigned long long ttime,
                                 unsigned long *ios, unsigned int *rw_bs)
 {
-       struct io_piece *ipo = malloc(sizeof(*ipo));
+       struct io_piece *ipo;
        unsigned int bs;
        int fileno;
 
+       ipo = calloc(1, sizeof(*ipo));
        init_ipo(ipo);
        fileno = trace_add_file(td, t->device, &bs);
 
@@ -310,6 +312,8 @@ static void handle_trace_fs(struct thread_data *td, struct blk_io_trace *t,
 
        rw = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
 
+       assert(t->bytes);
+
        if (t->bytes > rw_bs[rw])
                rw_bs[rw] = t->bytes;
 
@@ -318,6 +322,25 @@ static void handle_trace_fs(struct thread_data *td, struct blk_io_trace *t,
        store_ipo(td, t->sector, t->bytes, rw, ttime, fileno, bs);
 }
 
+static void handle_trace_flush(struct thread_data *td, struct blk_io_trace *t,
+                              unsigned long long ttime)
+{
+       struct io_piece *ipo;
+       unsigned int bs;
+       int fileno;
+
+       ipo = calloc(1, sizeof(*ipo));
+       init_ipo(ipo);
+       fileno = trace_add_file(td, t->device, &bs);
+
+       ipo->delay = ttime / 1000;
+       ipo->ddir = DDIR_SYNC;
+       ipo->fileno = fileno;
+
+       dprint(FD_BLKTRACE, "store flush delay=%lu\n", ipo->delay);
+       queue_io_piece(td, ipo);
+}
+
 /*
  * We only care for queue traces, most of the others are side effects
  * due to internal workings of the block layer.
@@ -353,6 +376,8 @@ static void handle_trace(struct thread_data *td, struct blk_io_trace *t,
                handle_trace_notify(t);
        else if (t->action & BLK_TC_ACT(BLK_TC_DISCARD))
                handle_trace_discard(td, t, delay, ios, bs);
+       else if (t->action & BLK_TC_ACT(BLK_TC_FLUSH))
+               handle_trace_flush(td, t, delay);
        else
                handle_trace_fs(td, t, delay, ios, bs);
 }