From: Jens Axboe Date: Mon, 5 Sep 2005 14:35:10 +0000 (+0200) Subject: [PATCH] Move open of logging file X-Git-Tag: blktrace-0.99~206 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=33b560191981ef2669d6a5d36a870c29ad23fbc4;p=blktrace.git [PATCH] Move open of logging file It should not be in the sorting, move it to the dumping place instead. --- diff --git a/blkparse.c b/blkparse.c index 14b5b02..37f9ae3 100644 --- a/blkparse.c +++ b/blkparse.c @@ -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))