aboutsummaryrefslogtreecommitdiff
path: root/block/blk.h
diff options
context:
space:
mode:
authorGravatar Jens Axboe <axboe@kernel.dk> 2024-01-15 14:45:07 -0700
committerGravatar Jens Axboe <axboe@kernel.dk> 2024-02-05 10:07:22 -0700
commit08420cf70cfb32eed2a0abfeb5c54c5651bd0c99 (patch)
treeee9a278750a711e90babcb73cbde53fd7b4fdcf1 /block/blk.h
parentblock: move cgroup time handling code into blk.h (diff)
downloadlinux-08420cf70cfb32eed2a0abfeb5c54c5651bd0c99.tar.gz
linux-08420cf70cfb32eed2a0abfeb5c54c5651bd0c99.tar.bz2
linux-08420cf70cfb32eed2a0abfeb5c54c5651bd0c99.zip
block: add blk_time_get_ns() and blk_time_get() helpers
Convert any user of ktime_get_ns() to use blk_time_get_ns(), and ktime_get() to blk_time_get(), so we have a unified API for querying the current time in nanoseconds or as ktime. No functional changes intended, this patch just wraps ktime_get_ns() and ktime_get() with a block helper. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk.h')
-rw-r--r--block/blk.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/block/blk.h b/block/blk.h
index 620e3a035da1..79ae533cdf02 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -4,6 +4,7 @@
#include <linux/blk-crypto.h>
#include <linux/memblock.h> /* for max_pfn/max_low_pfn */
+#include <linux/timekeeping.h>
#include <xen/xen.h>
#include "blk-crypto-internal.h"
@@ -516,6 +517,16 @@ static inline int req_ref_read(struct request *req)
return atomic_read(&req->ref);
}
+static inline u64 blk_time_get_ns(void)
+{
+ return ktime_get_ns();
+}
+
+static inline ktime_t blk_time_get(void)
+{
+ return ns_to_ktime(blk_time_get_ns());
+}
+
/*
* From most significant bit:
* 1 bit: reserved for other usage, see below
@@ -554,7 +565,7 @@ static inline void bio_issue_init(struct bio_issue *issue,
{
size &= (1ULL << BIO_ISSUE_SIZE_BITS) - 1;
issue->value = ((issue->value & BIO_ISSUE_RES_MASK) |
- (ktime_get_ns() & BIO_ISSUE_TIME_MASK) |
+ (blk_time_get_ns() & BIO_ISSUE_TIME_MASK) |
((u64)size << BIO_ISSUE_SIZE_SHIFT));
}