[PATCH] Move open of logging file
authorJens Axboe <axboe@wiggum>
Mon, 5 Sep 2005 14:35:10 +0000 (16:35 +0200)
committerJens Axboe <axboe@wiggum>
Mon, 5 Sep 2005 14:35:10 +0000 (16:35 +0200)
It should not be in the sorting, move it to the dumping place instead.

blkparse.c

index 14b5b022f58acf5784f855affe2263d3abd0eaa6..37f9ae3c1e8df910a291104db332d59513015d13 100644 (file)
@@ -159,7 +159,7 @@ static void output(struct per_cpu_info *pci, char *s)
        printf("%s", s);
 
        if (pci->ofp)
-               fprintf(pci->ofp,"%s",s);
+               fprintf(pci->ofp, "%s", s);
 }
 
 static char hstring[256];
@@ -333,6 +333,17 @@ static int dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci)
 {
        int ret = 0;
 
+       if (output_name && !pci->ofp) {
+               snprintf(pci->ofname, sizeof(pci->ofname) - 1,
+                               "%s_log.%d", output_name, pci->cpu);
+
+               pci->ofp = fopen(pci->ofname, "w");
+               if (pci->ofp == NULL) {
+                       perror(pci->ofname);
+                       return 1;
+               }
+       }
+
        if (t->action & BLK_TC_ACT(BLK_TC_PC))
                ret = dump_trace_pc(t, pci);
        else
@@ -444,17 +455,6 @@ static int sort_entries(void *traces, unsigned long offset, int nr)
 
                pci = &per_cpu_info[bit->cpu];
 
-               if (output_name && !pci->ofp) {
-                       snprintf(pci->ofname, sizeof(pci->ofname) - 1,
-                                       "%s_log.%d", output_name, bit->cpu);
-
-                       pci->ofp = fopen(pci->ofname, "w");
-                       if (pci->ofp == NULL) {
-                               perror(pci->ofname);
-                               break;
-                       }
-               }
-
                pci->nelems++;
 
                if (trace_rb_insert(t))