aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk.h
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk.h')
-rw-r--r--block/blk.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/block/blk.h b/block/blk.h
index 79ae533cdf026f..14bbc4b780f275 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -519,7 +519,19 @@ static inline int req_ref_read(struct request *req)
static inline u64 blk_time_get_ns(void)
{
- return ktime_get_ns();
+ struct blk_plug *plug = current->plug;
+
+ if (!plug)
+ return ktime_get_ns();
+
+ /*
+ * 0 could very well be a valid time, but rather than flag "this is
+ * a valid timestamp" separately, just accept that we'll do an extra
+ * ktime_get_ns() if we just happen to get 0 as the current time.
+ */
+ if (!plug->cur_ktime)
+ plug->cur_ktime = ktime_get_ns();
+ return plug->cur_ktime;
}
static inline ktime_t blk_time_get(void)