Commit 55547204 authored by Li Zefan's avatar Li Zefan Committed by Ingo Molnar

blktrace: fix the original blktrace

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"
(c71a8961)

 -	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: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarJens 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: default avatarIngo Molnar <mingo@elte.hu>
parent b5230b56
...@@ -110,7 +110,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...) ...@@ -110,7 +110,7 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
unsigned long flags; unsigned long flags;
char *buf; char *buf;
if (blk_tr) { if (blk_tracer_enabled) {
va_start(args, fmt); va_start(args, fmt);
ftrace_vprintk(fmt, args); ftrace_vprintk(fmt, args);
va_end(args); va_end(args);
...@@ -169,7 +169,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -169,7 +169,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
pid_t pid; pid_t pid;
int cpu, pc = 0; int cpu, pc = 0;
if (unlikely(bt->trace_state != Blktrace_running || if (unlikely(bt->trace_state != Blktrace_running &&
!blk_tracer_enabled)) !blk_tracer_enabled))
return; return;
...@@ -185,7 +185,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -185,7 +185,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
return; return;
cpu = raw_smp_processor_id(); cpu = raw_smp_processor_id();
if (blk_tr) { if (blk_tracer_enabled) {
tracing_record_cmdline(current); tracing_record_cmdline(current);
pc = preempt_count(); pc = preempt_count();
...@@ -235,7 +235,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -235,7 +235,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
if (pdu_len) if (pdu_len)
memcpy((void *) t + sizeof(*t), pdu_data, 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); trace_buffer_unlock_commit(blk_tr, event, 0, pc);
return; return;
} }
...@@ -267,8 +267,7 @@ int blk_trace_remove(struct request_queue *q) ...@@ -267,8 +267,7 @@ int blk_trace_remove(struct request_queue *q)
if (!bt) if (!bt)
return -EINVAL; return -EINVAL;
if (bt->trace_state == Blktrace_setup || if (bt->trace_state != Blktrace_running)
bt->trace_state == Blktrace_stopped)
blk_trace_cleanup(bt); blk_trace_cleanup(bt);
return 0; return 0;
...@@ -1273,7 +1272,6 @@ static int blk_trace_setup_queue(struct request_queue *q, dev_t dev) ...@@ -1273,7 +1272,6 @@ static int blk_trace_setup_queue(struct request_queue *q, dev_t dev)
bt->dev = dev; bt->dev = dev;
bt->act_mask = (u16)-1; bt->act_mask = (u16)-1;
bt->end_lba = -1ULL; bt->end_lba = -1ULL;
bt->trace_state = Blktrace_running;
old_bt = xchg(&q->blk_trace, bt); old_bt = xchg(&q->blk_trace, bt);
if (old_bt != NULL) { if (old_bt != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment