After sending a SIGINT to a "blktrace .. | blkparse .. " pipeline,
occasionally I would not be able to run blktrace again. On my next run
of the same pipeline I would get the following error:
cs411vm:/usr/src/bt# ./blktrace -d /dev/sdb -o - | ./blkparse -i -
BLKTRACESETUP: No such file or directory
Failed to start trace on /dev/sdb
After rebooting, I could reproduce this by starting the pipeline, and
kicking off a big write and sending a SIGINT to blktrace. The following
is what I used for a write:
while [ 1 ]
do
dd if=/dev/zero of=/test/write bs=1M
done
It seemed like blktrace was not handling signals correctly, so I
strace'd the process to see what was happening.
Sure enough:
--- SIGINT (Interrupt) @ 0 (0) ---
ioctl(3, 0x1275, 0xb7fa6000) = 0
sigreturn() = ? (mask now [])
write(1, "O\0\0\0\20\0\200\0\0\0\0\0\0\0\0\0\7taeN3\1\0\257R\260"...,
4096) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
+++ killed by SIGPIPE +++
Any idea what clean-up is not happening? I tried to figure it out, but
my only work-around was a reboot.
My patch against 2.6.17-rc3 just tells blktrace to ignore SIGPIPE.
Nothing crazy. :) blktrace already does enough error checking elsewhere
to handle a bad write.
On a completely unrelated note, the write_data function calls fwrite,
which will not return -1 on error. Instead you'll need to use ferror to
check if there was a problem. I'm not sure if this is a cause of any
bugs, but it seemed worth mentioning.
Furthermore, I updated the URLs in the documentation to point at a valid
git repo.
signal(SIGHUP, handle_sigint);
signal(SIGTERM, handle_sigint);
signal(SIGALRM, handle_sigint);
+ signal(SIGPIPE, SIG_IGN);
if (net_mode == Net_client && net_setup_client())
return 1;
The blktrace and blkparse utilities and associated kernel patch are provided
as part of the following git repository:
-rsync://rsync.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git
+git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt
%--------------------------
\newpage\section{\label{sec:quick-start}Quick Start Guide}
As noted above, the kernel patch along with the blktrace and blkparse utilities are stored in a git repository. One simple way to get going would be:
\begin{verbatim}
-% git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt
+% git clone git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git bt
% cd bt
% git checkout
\end{verbatim}