From 33b560191981ef2669d6a5d36a870c29ad23fbc4 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 5 Sep 2005 16:35:10 +0200 Subject: [PATCH] [PATCH] Move open of logging file It should not be in the sorting, move it to the dumping place instead. --- blkparse.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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)) -- 2.25.1