Skip to content

Commit ce40426

Browse files
khazhykMike Snitzer
authored andcommitted
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: 2613eab ("dm mpath: add Historical Service Time Path Selector") Signed-off-by: Khazhismel Kumykov <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 08c1af8 commit ce40426

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/md/dm-ps-historical-service-time.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/blkdev.h>
2828
#include <linux/slab.h>
2929
#include <linux/module.h>
30-
#include <linux/sched/clock.h>
3130

3231

3332
#define DM_MSG_PREFIX "multipath historical-service-time"
@@ -433,7 +432,7 @@ static struct dm_path *hst_select_path(struct path_selector *ps,
433432
{
434433
struct selector *s = ps->context;
435434
struct path_info *pi = NULL, *best = NULL;
436-
u64 time_now = sched_clock();
435+
u64 time_now = ktime_get_ns();
437436
struct dm_path *ret = NULL;
438437
unsigned long flags;
439438

@@ -474,7 +473,7 @@ static int hst_start_io(struct path_selector *ps, struct dm_path *path,
474473

475474
static u64 path_service_time(struct path_info *pi, u64 start_time)
476475
{
477-
u64 sched_now = ktime_get_ns();
476+
u64 now = ktime_get_ns();
478477

479478
/* if a previous disk request has finished after this IO was
480479
* sent to the hardware, pretend the submission happened
@@ -483,11 +482,11 @@ static u64 path_service_time(struct path_info *pi, u64 start_time)
483482
if (time_after64(pi->last_finish, start_time))
484483
start_time = pi->last_finish;
485484

486-
pi->last_finish = sched_now;
487-
if (time_before64(sched_now, start_time))
485+
pi->last_finish = now;
486+
if (time_before64(now, start_time))
488487
return 0;
489488

490-
return sched_now - start_time;
489+
return now - start_time;
491490
}
492491

493492
static int hst_end_io(struct path_selector *ps, struct dm_path *path,

0 commit comments

Comments
 (0)