[PATCH] blkparse: A couple of fixes: correct time output & flush files.
authorAlan D. Brunelle <Alan.Brunelle@hp.com>
Mon, 13 Nov 2006 13:52:53 +0000 (14:52 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 13 Nov 2006 13:52:53 +0000 (14:52 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
blkparse.c

index 07ea8ce172a47b9ed89bacdf1c05fb687e10dc3a..f02934120817d7df7a00320af37973df4d621d6d 100644 (file)
@@ -2227,6 +2227,8 @@ static int handle(struct ms_stream *msp)
        pci = get_cpu_info(pdi, msp->cpu);
        pci->nelems++;
 
+       bit->time -= genesis_time;
+       pdi->last_reported_time = bit->time;
        if (bit->action & (act_mask << BLK_TC_SHIFT))
                dump_trace(bit, pci, pdi);
 
@@ -2256,6 +2258,12 @@ static int do_file(void)
                        ;
        }
 
+       /*
+        * Get the initial time stamp
+        */
+       if (ms_head)
+               genesis_time = ms_peek_time(ms_head);
+
        /*
         * Keep processing traces while any are left
         */
@@ -2560,9 +2568,13 @@ int main(int argc, char *argv[])
                ret = do_file();
 
        show_stats();
-       if (ofp_buffer)
+       if (ofp_buffer) {
+               fflush(ofp);
                free(ofp_buffer);
-       if (bin_ofp_buffer)
+       }
+       if (bin_ofp_buffer) {
+               fflush(dump_fp);
                free(bin_ofp_buffer);
+       }
        return ret;
 }