Added in %done for btt
[blktrace.git] / btt / trace.c
index 1d9a1c08d28c4ec914948039ec25ea29e7d6648e..ee5a654a133f9c5198642af375289527407f53ed 100644 (file)
@@ -28,7 +28,7 @@ static void __add_trace(struct io *iop)
        iostat_check_time(iop->t.time);
 
        if (verbose && ((now - last_vtrace) > 0)) {
-               printf("%10lu t\r", n_traces);
+               printf("%10lu t (%6.2lf%%)\r", n_traces, pct_done());
                if ((n_traces % 1000000) == 0) printf("\n");
                fflush(stdout);
                last_vtrace = now;
@@ -54,6 +54,23 @@ static void __add_trace(struct io *iop)
        }
 }
 
+static void trace_message(struct io *iop)
+{
+       char scratch[15];
+       char msg[iop->t.pdu_len + 1];
+
+       if (!io_setup(iop, IOP_M))
+               return;
+
+       memcpy(msg, iop->pdu, iop->t.pdu_len);
+       msg[iop->t.pdu_len] = '\0';
+
+       fprintf(msgs_ofp, "%s %5d.%09lu %s\n",
+               make_dev_hdr(scratch, 15, iop->dip, 1),
+               (int)SECONDS(iop->t.time),
+               (unsigned long)NANO_SECONDS(iop->t.time), msg);
+}
+
 void add_trace(struct io *iop)
 {
        if (iop->t.action & BLK_TC_ACT(BLK_TC_NOTIFY)) {
@@ -68,6 +85,8 @@ void add_trace(struct io *iop)
                                add_process(iop->t.pid, iop->pdu);
                        }
                }
+               else if (iop->t.action == BLK_TN_MESSAGE)
+                       trace_message(iop);
                io_release(iop);
        }
        else if (iop->t.action & BLK_TC_ACT(BLK_TC_PC))