Re: [PATCH 03/11] blktrace: add option to request a specific trace protocol version

Damien Le Moal <[email protected]>
Newsgroups org.kernel.vger.linux-block,org.kernel.vger.linux-btrace
Organization Western Digital Research
Message-ID <[email protected]>
On 7/16/26 20:04, Johannes Thumshirn wrote:
> 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 <[email protected]>
> ---
>  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;

bool ?

Or maybe less confusing/more scalable:

static int trace_ver = 2;

to match the default and the --trace-version option changes that to the
specified value? That simplifies the code below too.
>  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: {

		case OPT_TRACE_VERSION:
			trace_ver = atoi(optarg);
			if (trace_ver != 1 && trace_ver != 2) {
				show_usage(argv[0]);
				exit(1);
			}
			break;

> +			int ver = atoi(optarg);
> +
> +			if (ver == 1)
> +				v1 = 1;
> +			else if (ver == 2)
> +				v1 = 0;
> +			else {
> +				show_usage(argv[0]);
> +				exit(1);
> +			}
> +			break;
> +		}


-- 
Damien Le Moal
Western Digital Research
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.