block: disable IRQs until data is written to relay channel

As we may run relay_reserve from interrupt context we must always disable
IRQs.  This is because a call to relay_reserve may expose previously written
data to use space.

Updated new message code and an old but related comment.

Signed-off-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Carl Henrik Lunde 2008-06-12 20:13:58 +02:00 committed by Linus Torvalds
parent 95dcf8350d
commit 14a73f5479

View File

@ -79,16 +79,17 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
{ {
int n; int n;
va_list args; va_list args;
unsigned long flags;
char *buf; char *buf;
preempt_disable(); local_irq_save(flags);
buf = per_cpu_ptr(bt->msg_data, smp_processor_id()); buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
va_start(args, fmt); va_start(args, fmt);
n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args); n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
va_end(args); va_end(args);
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n); trace_note(bt, 0, BLK_TN_MESSAGE, buf, n);
preempt_enable(); local_irq_restore(flags);
} }
EXPORT_SYMBOL_GPL(__trace_note_message); EXPORT_SYMBOL_GPL(__trace_note_message);
@ -158,10 +159,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
/* /*
* A word about the locking here - we disable interrupts to reserve * A word about the locking here - we disable interrupts to reserve
* some space in the relay per-cpu buffer, to prevent an irq * some space in the relay per-cpu buffer, to prevent an irq
* from coming in and stepping on our toes. Once reserved, it's * from coming in and stepping on our toes.
* enough to get preemption disabled to prevent read of this data
* before we are through filling it. get_cpu()/put_cpu() does this
* for us
*/ */
local_irq_save(flags); local_irq_save(flags);