summaryrefslogtreecommitdiff
path: root/blkparse.c
diff options
context:
space:
mode:
authorAlan D. Brunelle <Alan.Brunelle@hp.com>2006-11-13 14:49:48 +0100
committerJens Axboe <jens.axboe@oracle.com>2006-11-13 14:49:48 +0100
commit234db09d1aa776f92738bb8d20771d945039b348 (patch)
treebf9ec30e6de0c27c18abea2f477c079d9a1faf78 /blkparse.c
parentec685dd2e5c6030493e4fc4ae23619227e93129c (diff)
downloadblktrace-234db09d1aa776f92738bb8d20771d945039b348.tar.gz
blktrace-234db09d1aa776f92738bb8d20771d945039b348.tar.bz2
[PATCH] blkparse Added --no-text-output (-O)
Removes textual output, useful for bin only. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'blkparse.c')
-rw-r--r--blkparse.c167
1 files changed, 100 insertions, 67 deletions
diff --git a/blkparse.c b/blkparse.c
index a73d3dd..607d17e 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -104,7 +104,7 @@ static struct per_process_info *ppi_hash_table[PPI_HASH_SIZE];
static struct per_process_info *ppi_list;
static int ppi_list_entries;
-#define S_OPTS "a:A:i:o:b:stqw:f:F:vVhD:d:"
+#define S_OPTS "a:A:b:D:d:f:F:hi:o:Oqstw:vV"
static struct option l_opts[] = {
{
.name = "act-mask",
@@ -119,88 +119,94 @@ static struct option l_opts[] = {
.val = 'A'
},
{
- .name = "input",
+ .name = "batch",
.has_arg = required_argument,
.flag = NULL,
- .val = 'i'
+ .val = 'b'
},
{
- .name = "output",
+ .name = "input-directory",
.has_arg = required_argument,
.flag = NULL,
- .val = 'o'
+ .val = 'D'
},
{
- .name = "batch",
+ .name = "dump-binary",
.has_arg = required_argument,
.flag = NULL,
- .val = 'b'
+ .val = 'd'
},
{
- .name = "per-program-stats",
- .has_arg = no_argument,
+ .name = "format",
+ .has_arg = required_argument,
.flag = NULL,
- .val = 's'
+ .val = 'f'
},
{
- .name = "track-ios",
- .has_arg = no_argument,
+ .name = "format-spec",
+ .has_arg = required_argument,
.flag = NULL,
- .val = 't'
+ .val = 'F'
},
{
- .name = "quiet",
+ .name = "hash-by-name",
.has_arg = no_argument,
.flag = NULL,
- .val = 'q'
+ .val = 'h'
},
{
- .name = "stopwatch",
+ .name = "input",
.has_arg = required_argument,
.flag = NULL,
- .val = 'w'
+ .val = 'i'
},
{
- .name = "format",
+ .name = "output",
.has_arg = required_argument,
.flag = NULL,
- .val = 'f'
+ .val = 'o'
},
{
- .name = "format-spec",
- .has_arg = required_argument,
+ .name = "no-text-output",
+ .has_arg = no_argument,
.flag = NULL,
- .val = 'F'
+ .val = 'O'
},
{
- .name = "hash-by-name",
+ .name = "quiet",
.has_arg = no_argument,
.flag = NULL,
- .val = 'h'
+ .val = 'q'
},
{
- .name = "verbose",
+ .name = "per-program-stats",
.has_arg = no_argument,
.flag = NULL,
- .val = 'v'
+ .val = 's'
},
{
- .name = "version",
+ .name = "track-ios",
.has_arg = no_argument,
.flag = NULL,
- .val = 'V'
+ .val = 't'
},
{
- .name = "input-directory",
+ .name = "stopwatch",
.has_arg = required_argument,
.flag = NULL,
- .val = 'D'
+ .val = 'w'
},
{
- .name = "dump-binary",
- .has_arg = required_argument,
+ .name = "verbose",
+ .has_arg = no_argument,
.flag = NULL,
- .val = 'd'
+ .val = 'v'
+ },
+ {
+ .name = "version",
+ .has_arg = no_argument,
+ .flag = NULL,
+ .val = 'V'
},
{
.name = NULL,
@@ -277,6 +283,8 @@ static unsigned int rb_batch = RB_BATCH_DEFAULT;
static int pipeline;
+static int text_output = 1;
+
#define is_done() (*(volatile int *)(&done))
static volatile int done;
@@ -1415,10 +1423,12 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
struct per_dev_info *pdi)
{
- if (t->action & BLK_TC_ACT(BLK_TC_PC))
- dump_trace_pc(t, pci);
- else
- dump_trace_fs(t, pdi, pci);
+ if (text_output) {
+ if (t->action & BLK_TC_ACT(BLK_TC_PC))
+ dump_trace_pc(t, pci);
+ else
+ dump_trace_fs(t, pdi, pci);
+ }
if (!pdi->events)
pdi->first_reported_time = t->time;
@@ -2194,24 +2204,41 @@ static int find_stopwatch_interval(char *string)
return 0;
}
-static char usage_str[] = \
- "[ -i <input name> ] [-o <output name> [ -s ] [ -t ] [ -q ]\n" \
- "[ -w start:stop ] [ -f output format ] [ -F format spec ] [ -v] \n\n" \
- "\t-i Input file containing trace data, or '-' for stdin\n" \
+#define S_OPTS "a:A:b:D:d:f:F:hi:o:Oqstw:vV"
+static char usage_str[] = "\n\n" \
+ "-i <file> | --input=<file>\n" \
+ "[ -a <action field> | --act-mask=<action field> ]\n" \
+ "[ -A <action mask> | --set-mask=<action mask> ]\n" \
+ "[ -b <traces> | --batch=<traces> ]\n" \
+ "[ -d <file> | --dump-binary=<file> ]\n" \
+ "[ -D <dir> | --input-directory=<dir> ]\n" \
+ "[ -f <format> | --format=<format> ]\n" \
+ "[ -F <spec> | --format-spec=<spec> ]\n" \
+ "[ -h | --hash-by-name ]\n" \
+ "[ -o <file> | --output=<file> ]\n" \
+ "[ -O | --no-text-output ]\n" \
+ "[ -q | --quiet ]\n" \
+ "[ -s | --per-program-stats ]\n" \
+ "[ -t | --track-ios ]\n" \
+ "[ -w <time> | --stopwatch=<time> ]\n" \
+ "[ -v | --verbose ]\n" \
+ "[ -V | --version ]\n\n" \
+ "\t-b stdin read batching\n" \
+ "\t-d Output file. If specified, binary data is written to file\n" \
"\t-D Directory to prepend to input file names\n" \
+ "\t-f Output format. Customize the output format. The format field\n" \
+ "\t identifies can be found in the documentation\n" \
+ "\t-F Format specification. Can be found in the documentation\n" \
+ "\t-h Hash processes by name, not pid\n" \
+ "\t-i Input file containing trace data, or '-' for stdin\n" \
"\t-o Output file. If not given, output is stdout\n" \
- "\t-d Output file. If specified, binary data is written to file\n" \
- "\t-b stdin read batching\n" \
+ "\t-O Do NOT output text data\n" \
+ "\t-q Quiet. Don't display any stats at the end of the trace\n" \
"\t-s Show per-program io statistics\n" \
- "\t-h Hash processes by name, not pid\n" \
"\t-t Track individual ios. Will tell you the time a request took\n" \
"\t to get queued, to get dispatched, and to get completed\n" \
- "\t-q Quiet. Don't display any stats at the end of the trace\n" \
"\t-w Only parse data between the given time interval in seconds.\n" \
"\t If 'start' isn't given, blkparse defaults the start time to 0\n" \
- "\t-f Output format. Customize the output format. The format field\n" \
- "\t identifies can be found in the documentation\n" \
- "\t-F Format specification. Can be found in the documentation\n" \
"\t-v More verbose for marginal errors\n" \
"\t-V Print program version info\n\n";
@@ -2222,9 +2249,9 @@ static void usage(char *prog)
int main(int argc, char *argv[])
{
- char *ofp_buffer;
int i, c, ret, mode;
int act_mask_tmp = 0;
+ char *ofp_buffer = NULL;
while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) != -1) {
switch (c) {
@@ -2260,6 +2287,9 @@ int main(int argc, char *argv[])
case 'o':
output_name = optarg;
break;
+ case 'O':
+ text_output = 0;
+ break;
case 'b':
rb_batch = atoi(optarg);
if (rb_batch <= 0)
@@ -2327,26 +2357,28 @@ int main(int argc, char *argv[])
setlocale(LC_NUMERIC, "en_US");
- if (!output_name) {
- ofp = fdopen(STDOUT_FILENO, "w");
- mode = _IOLBF;
- } else {
- char ofname[128];
+ if (text_output) {
+ if (!output_name) {
+ ofp = fdopen(STDOUT_FILENO, "w");
+ mode = _IOLBF;
+ } else {
+ char ofname[128];
- snprintf(ofname, sizeof(ofname) - 1, "%s", output_name);
- ofp = fopen(ofname, "w");
- mode = _IOFBF;
- }
+ snprintf(ofname, sizeof(ofname) - 1, "%s", output_name);
+ ofp = fopen(ofname, "w");
+ mode = _IOFBF;
+ }
- if (!ofp) {
- perror("fopen");
- return 1;
- }
+ if (!ofp) {
+ perror("fopen");
+ return 1;
+ }
- ofp_buffer = malloc(4096);
- if (setvbuf(ofp, ofp_buffer, mode, 4096)) {
- perror("setvbuf");
- return 1;
+ ofp_buffer = malloc(4096);
+ if (setvbuf(ofp, ofp_buffer, mode, 4096)) {
+ perror("setvbuf");
+ return 1;
+ }
}
if (dump_binary) {
@@ -2364,6 +2396,7 @@ int main(int argc, char *argv[])
ret = do_file();
show_stats();
- free(ofp_buffer);
+ if (text_output)
+ free(ofp_buffer);
return ret;
}