blktrace: disallow -o when using multiple devices
authorAlan D. Brunelle <alan.brunelle@hp.com>
Thu, 16 Sep 2010 13:26:22 +0000 (09:26 -0400)
committerAlan D. Brunelle <alan.brunelle@hp.com>
Thu, 16 Sep 2010 13:26:22 +0000 (09:26 -0400)
Document that "-o" does not work when specyfing multiple devices to
blktrace, also: enforce this by stopping blktrace when one tries do
do this.

The technical reason why "-o" doesn't work with multiple devices is
because we use multiple threads of execution - one per device/CPU pair -
and each of them opens a file named "<prefix>.blktrace.<cpu>". With the
"-o" all of the "<prefix>" values are the same - so multiple threads
open the same file and try to do output. Not good. Without the "-o"
we get unique files named: "<device>.blktrace.<cpu>"  - as the tuple
(<device>,<cpu>) is unique.

Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com>
blktrace.c
doc/blktrace.8
doc/blktrace.tex

index b9f9b689cf65e5de63dd47eff01281633a61a516..4671a0479f0ea5003c037db2d25572f82d404968 100644 (file)
@@ -2626,6 +2626,12 @@ int main(int argc, char *argv[])
                goto out;
        }
 
+       if (ndevs > 1 && output_name && strcmp(output_name, "-") != 0) {
+               fprintf(stderr, "-o not supported with multiple devices\n");
+               ret = 1;
+               goto out;
+       }
+
        signal(SIGINT, handle_sigint);
        signal(SIGHUP, handle_sigint);
        signal(SIGTERM, handle_sigint);
index ab6a3f3366e9840b1f24aa1159266fee998bb0e2..50b3a62212cb55f972f2c9267fdc626eba8b1f80 100644 (file)
@@ -122,6 +122,9 @@ Specifies number of buffers to use. blktrace defaults to 4 sub buffers.
 \-\-output=\fIfile\fR        
 .RS
 Prepend \fIfile\fR to output file name(s)  
+
+This only works when supplying a single device, or when piping the output
+via "-o -" with multiple devices.
 .RE
 
 \-r \fIrel-path\fR
index 54fe45170bcf7000d207fb792321729bece786ee..4d8278e8eec42057ffd4a8445067f329b7c6ee55 100644 (file)
@@ -389,7 +389,10 @@ Short              & Long                       & Description \\ \hline\hline
 -d \emph{dev}      & --dev=\emph{dev}           & Adds \emph{dev} as a device to trace \\ \hline
 -k                 & --kill                     & Kill on-going trace \\ \hline
 -n \emph{num-sub}  & --num-sub=\emph{num-sub}   & Specifies number of buffers to use \\ \hline
--o \emph{file}     & --output=\emph{file}       & Prepend \emph{file} to output file name(s) \\ \hline
+-o \emph{file}     & --output=\emph{file}       & Prepend \emph{file} to output file name(s) \\
+                   &                            & \textbf{This only works when using a single device} \\
+                   &                            & \textbf{or when piping the output via \texttt{-o -}} \\
+                   &                            & \textbf{with multiple devices.} \\ \hline
 -r \emph{rel-path} & --relay=\emph{rel-path}    & Specifies debugfs mount point \\ \hline
 -V                 & --version                  & Outputs version \\ \hline
 -w \emph{seconds}  & --stopwatch=\emph{seconds} & Sets run time to the number of seconds specified \\ \hline