Skip to content

Commit 14a73f5

Browse files
chlundetorvalds
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 95dcf83 commit 14a73f5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

block/blktrace.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
7979
{
8080
int n;
8181
va_list args;
82+
unsigned long flags;
8283
char *buf;
8384

84-
preempt_disable();
85+
local_irq_save(flags);
8586
buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
8687
va_start(args, fmt);
8788
n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
8889
va_end(args);
8990

9091
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n);
91-
preempt_enable();
92+
local_irq_restore(flags);
9293
}
9394
EXPORT_SYMBOL_GPL(__trace_note_message);
9495

@@ -158,10 +159,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
158159
/*
159160
* A word about the locking here - we disable interrupts to reserve
160161
* some space in the relay per-cpu buffer, to prevent an irq
161-
* from coming in and stepping on our toes. Once reserved, it's
162-
* enough to get preemption disabled to prevent read of this data
163-
* before we are through filling it. get_cpu()/put_cpu() does this
164-
* for us
162+
* from coming in and stepping on our toes.
165163
*/
166164
local_irq_save(flags);
167165

0 commit comments

Comments
 (0)