Re: blktrace hangs with "-o -" if BLKTRACESETUP fails

Jeff Moyer <[email protected]>
Newsgroups org.kernel.vger.linux-btrace
Message-ID <[email protected]>
Eric Sandeen <[email protected]> writes:

> I tried to sort through this, but got a bit lost. Possible solution at the
> end of the email.
>
> tl;dr: 
>
> # blktrace -o - /dev/sda /dev/sdb /dev/sdc
>
> has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
> listed. (I simulated this by just catching one of the devices in
> setup_buts(), skipping the ioctl, and doing ret++).
>
> This seems to be because with "-o -" on the command line, use_tracer_devpaths()
> sees piped_output set, so we call process_trace_bufs which ends up waiting on
> (!done) and "done" is never set. i.e.
>
> atexit(exit_tracing)
> 	wait_tracers
> 		if (use_tracer_devpaths()) // true because "-o -"
> 			process_trace_bufs
> 				while (wait_empty_entries())
> 					wait_empty_entries
> 						while (!done ... )
> 							<loop forever>
>
> I think this can be avoided by just setting "done = 1" before returning
> when setup_buts() fails in run_tracers(), but I'm not sure if that's the
> right approach. Thoughts?

I think that looks ok.  I think we probably should also set 'done = 1' if
setup_tracer_devpaths() fails as well.

-Jeff

>
> Thanks,
> -Eric
>
> diff --git a/blktrace.c b/blktrace.c
> index 3444fbb..038b2cb 100644
> --- a/blktrace.c
> +++ b/blktrace.c
> @@ -2684,8 +2684,10 @@ static int run_tracers(void)
>  	if (net_mode == Net_client)
>  		printf("blktrace: connecting to %s\n", hostname);
>  
> -	if (setup_buts())
> +	if (setup_buts()) {
> +		done = 1;
>  		return 1;
> +	}
>  
>  	if (use_tracer_devpaths()) {
>  		if (setup_tracer_devpaths())
> 						
>
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.