Add the '--trace-version=<1|2>' command line option to select the trace protocol version requested from the kernel. Requesting version 1 forces blktrace to use the old BLKTRACESETUP ioctl, while version 2 (the default) uses BLKTRACESETUP2. Signed-off-by: Johannes Thumshirn --- blktrace.c | 30 ++++++++++++++++++++++++++++-- doc/blktrace.8 | 7 +++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/blktrace.c b/blktrace.c index 72562fdc9d9e..35db26fd4e23 100644 --- a/blktrace.c +++ b/blktrace.c @@ -283,6 +283,7 @@ static unsigned long long act_mask = ~0U; static int kill_running_trace; static int stop_watch; static int piped_output; +static int v1; static char *debugfs_path = "/sys/kernel/debug"; static char *output_name; @@ -329,6 +330,10 @@ static int *cl_fds; static int (*handle_pfds)(struct tracer *, int, int); static int (*handle_list)(struct tracer_devpath_head *, struct list_head *); +enum { + OPT_TRACE_VERSION = 256, +}; + #define S_OPTS "d:a:A:r:o:kw:vVb:n:D:lh:p:sI:" static struct option l_opts[] = { { @@ -433,6 +438,12 @@ static struct option l_opts[] = { .flag = NULL, .val = 's' }, + { + .name = "trace-version", + .has_arg = required_argument, + .flag = NULL, + .val = OPT_TRACE_VERSION + }, { .name = NULL, } @@ -455,6 +466,7 @@ static char usage_str[] = "\n\n" \ "[ -I | --input-devs=]\n" \ "[ -v | --version]\n" \ "[ -V | --version]\n" \ + "[ --trace-version=<1|2> ]\n" \ "\t-d Use specified device. May also be given last after options\n" \ "\t-r Path to mounted debugfs, defaults to /sys/kernel/debug\n" \ @@ -471,7 +483,8 @@ static char usage_str[] = "\n\n" \ "\t-s Make the network client NOT use sendfile() to transfer data\n" \ "\t-I Add devices found in \n" \ "\t-v Print program version info\n" \ - "\t-V Print program version info\n\n"; + "\t-V Print program version info\n" \ + "\t--trace-version Request trace protocol version 1 or 2 from the kernel\n\n"; static void clear_events(struct pollfd *pfd) { @@ -2244,6 +2257,19 @@ static int handle_args(int argc, char *argv[]) case 's': net_use_sendfile = 0; break; + case OPT_TRACE_VERSION: { + int ver = atoi(optarg); + + if (ver == 1) + v1 = 1; + else if (ver == 2) + v1 = 0; + else { + show_usage(argv[0]); + exit(1); + } + break; + } default: show_usage(argv[0]); exit(1); @@ -2714,7 +2740,7 @@ static int run_tracers(void) if (net_mode == Net_client) printf("blktrace: connecting to %s\n", hostname); - if (setup_buts2()) { + if (v1 || setup_buts2()) { if (setup_buts()) { done = 1; return 1; diff --git a/doc/blktrace.8 b/doc/blktrace.8 index 820b03aa4c16..c502adcfaa9d 100644 --- a/doc/blktrace.8 +++ b/doc/blktrace.8 @@ -191,6 +191,13 @@ Outputs version Sets run time to the number of seconds specified .RE +\-\-trace\-version=\fI1|2\fR +.RS +Selects the trace protocol version requested from the kernel. Requesting +version 1 forces blktrace to use the old \fBBLKTRACESETUP\fR ioctl, while +version 2 (the default) uses \fBBLKTRACESETUP2\fR. +.RE + .SH FILTER MASKS The following masks may be passed with the \fI\-a\fR command line -- 2.54.0