fix hang when BLKTRACESETUP fails and "-o -" is used
authorEric Sandeen <sandeen@redhat.com>
Thu, 6 Jun 2024 04:07:27 +0000 (23:07 -0500)
committerJens Axboe <axboe@kernel.dk>
Wed, 12 Jun 2024 20:45:58 +0000 (14:45 -0600)
commit1836be5d99c9362f1e2b39206c95270f19cb7faa
treee3ad6192578acf9a3c745c11ae2edcebeec52e17
parentb9ea6e507e8849f01d06aa48c0c59c5cee4820be
fix hang when BLKTRACESETUP fails and "-o -" is used

# 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().

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Link: https://lore.kernel.org/r/f3204c9d-1384-40b5-a5fb-3bb967ca2bec@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
blktrace.c