Commit b874d4aa authored by Jens Axboe's avatar Jens Axboe

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: da4c8c3d ("block: cache current nsec time in struct blk_plug")
Reported-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 259f7d5e
......@@ -534,7 +534,7 @@ static inline u64 blk_time_get_ns(void)
{
struct blk_plug *plug = current->plug;
if (!plug)
if (!plug || !in_task())
return ktime_get_ns();
/*
......
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