提交 ce40426f 编写于 作者: K Khazhismel Kumykov 提交者: Mike Snitzer

dm mpath: only use ktime_get_ns() in historical selector

Mixing sched_clock() and ktime_get_ns() usage will give bad results.

Switch hst_select_path() from using sched_clock() to ktime_get_ns().
Also rename path_service_time()'s 'sched_now' variable to 'now'.

Fixes: 2613eab1 ("dm mpath: add Historical Service Time Path Selector")
Signed-off-by: NKhazhismel Kumykov <khazhy@google.com>
Signed-off-by: NMike Snitzer <snitzer@kernel.org>
上级 08c1af8f
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/sched/clock.h>
#define DM_MSG_PREFIX "multipath historical-service-time" #define DM_MSG_PREFIX "multipath historical-service-time"
...@@ -433,7 +432,7 @@ static struct dm_path *hst_select_path(struct path_selector *ps, ...@@ -433,7 +432,7 @@ static struct dm_path *hst_select_path(struct path_selector *ps,
{ {
struct selector *s = ps->context; struct selector *s = ps->context;
struct path_info *pi = NULL, *best = NULL; struct path_info *pi = NULL, *best = NULL;
u64 time_now = sched_clock(); u64 time_now = ktime_get_ns();
struct dm_path *ret = NULL; struct dm_path *ret = NULL;
unsigned long flags; unsigned long flags;
...@@ -474,7 +473,7 @@ static int hst_start_io(struct path_selector *ps, struct dm_path *path, ...@@ -474,7 +473,7 @@ static int hst_start_io(struct path_selector *ps, struct dm_path *path,
static u64 path_service_time(struct path_info *pi, u64 start_time) static u64 path_service_time(struct path_info *pi, u64 start_time)
{ {
u64 sched_now = ktime_get_ns(); u64 now = ktime_get_ns();
/* if a previous disk request has finished after this IO was /* if a previous disk request has finished after this IO was
* sent to the hardware, pretend the submission happened * sent to the hardware, pretend the submission happened
...@@ -483,11 +482,11 @@ static u64 path_service_time(struct path_info *pi, u64 start_time) ...@@ -483,11 +482,11 @@ static u64 path_service_time(struct path_info *pi, u64 start_time)
if (time_after64(pi->last_finish, start_time)) if (time_after64(pi->last_finish, start_time))
start_time = pi->last_finish; start_time = pi->last_finish;
pi->last_finish = sched_now; pi->last_finish = now;
if (time_before64(sched_now, start_time)) if (time_before64(now, start_time))
return 0; return 0;
return sched_now - start_time; return now - start_time;
} }
static int hst_end_io(struct path_selector *ps, struct dm_path *path, static int hst_end_io(struct path_selector *ps, struct dm_path *path,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册