block: cache current nsec time in struct blk_plug
[linux-2.6-microblaze.git] / block / blk.h
index 79ae533..14bbc4b 100644 (file)
@@ -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)