Skip to content

Commit b874d4a

Browse files
committed
block: limit block time caching to in_task() context
We should not have any callers of this from non-task context, but Jakub ran [1] into one from blk-iocost. Rather than risk running into others, or future ones, just limit blk_time_get_ns() to when it is called from a task. Any other usage is invalid. [1] https://lore.kernel.org/lkml/CAHk-=wiOaBLqarS2uFhM1YdwOvCX4CZaWkeyNDY1zONpbYw2ig@mail.gmail.com/ Fixes: da4c8c3 ("block: cache current nsec time in struct blk_plug") Reported-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 259f7d5 commit b874d4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static inline u64 blk_time_get_ns(void)
534534
{
535535
struct blk_plug *plug = current->plug;
536536

537-
if (!plug)
537+
if (!plug || !in_task())
538538
return ktime_get_ns();
539539

540540
/*

0 commit comments

Comments
 (0)