Skip to content

Commit

Permalink
blktrace: fix the original blktrace
Browse files Browse the repository at this point in the history
Currently the original blktrace, which is using relay and is used via
ioctl, is broken. You can use ftrace to see the output of blktrace,
but user-space blktrace is unusable.

It's broken by "blktrace: add ftrace plugin"
(c71a896)

 -	if (unlikely(bt->trace_state != Blktrace_running))
 +	if (unlikely(bt->trace_state != Blktrace_running || !blk_tracer_enabled))
		return;

With this patch, both ioctl and ftrace can be used, but of course you
can't use both of them at the same time.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Mar 31, 2009
1 parent b5230b5 commit 5554720
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kernel/trace/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
unsigned long flags;
char *buf;

if (blk_tr) {
if (blk_tracer_enabled) {
va_start(args, fmt);
ftrace_vprintk(fmt, args);
va_end(args);
Expand Down Expand Up @@ -169,7 +169,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
pid_t pid;
int cpu, pc = 0;

if (unlikely(bt->trace_state != Blktrace_running ||
if (unlikely(bt->trace_state != Blktrace_running &&
!blk_tracer_enabled))
return;

Expand All @@ -185,7 +185,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
return;
cpu = raw_smp_processor_id();

if (blk_tr) {
if (blk_tracer_enabled) {
tracing_record_cmdline(current);

pc = preempt_count();
Expand Down Expand Up @@ -235,7 +235,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
if (pdu_len)
memcpy((void *) t + sizeof(*t), pdu_data, pdu_len);

if (blk_tr) {
if (blk_tracer_enabled) {
trace_buffer_unlock_commit(blk_tr, event, 0, pc);
return;
}
Expand Down Expand Up @@ -267,8 +267,7 @@ int blk_trace_remove(struct request_queue *q)
if (!bt)
return -EINVAL;

if (bt->trace_state == Blktrace_setup ||
bt->trace_state == Blktrace_stopped)
if (bt->trace_state != Blktrace_running)
blk_trace_cleanup(bt);

return 0;
Expand Down Expand Up @@ -1273,7 +1272,6 @@ static int blk_trace_setup_queue(struct request_queue *q, dev_t dev)
bt->dev = dev;
bt->act_mask = (u16)-1;
bt->end_lba = -1ULL;
bt->trace_state = Blktrace_running;

old_bt = xchg(&q->blk_trace, bt);
if (old_bt != NULL) {
Expand Down

0 comments on commit 5554720

Please sign in to comment.