Blame SOURCES/0056-multipathd-use-get_monotonic_time-in-io_err_stat-cod.patch

b7337d
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b7337d
From: Benjamin Marzinski <bmarzins@redhat.com>
b7337d
Date: Thu, 14 Jan 2021 20:20:25 -0600
b7337d
Subject: [PATCH] multipathd: use get_monotonic_time() in io_err_stat code
b7337d
b7337d
Instead of calling clock_gettime(), and dealing with failure
b7337d
conditions, just call get_monotonic_time().
b7337d
b7337d
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
b7337d
Reviewed-by: Martin Wilck <mwilck@suse.com>
b7337d
---
b7337d
 libmultipath/io_err_stat.c | 34 +++++++++++-----------------------
b7337d
 1 file changed, 11 insertions(+), 23 deletions(-)
b7337d
b7337d
diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
b7337d
index 63ee2e07..3389d693 100644
b7337d
--- a/libmultipath/io_err_stat.c
b7337d
+++ b/libmultipath/io_err_stat.c
b7337d
@@ -305,8 +305,7 @@ int io_err_stat_handle_pathfail(struct path *path)
b7337d
 	 * the repeated count threshold and time frame, we assume a path
b7337d
 	 * which fails at least twice within 60 seconds is flaky.
b7337d
 	 */
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &curr_time) != 0)
b7337d
-		return 1;
b7337d
+	get_monotonic_time(&curr_time);
b7337d
 	if (path->io_err_pathfail_cnt == 0) {
b7337d
 		path->io_err_pathfail_cnt++;
b7337d
 		path->io_err_pathfail_starttime = curr_time.tv_sec;
b7337d
@@ -362,9 +361,9 @@ int need_io_err_check(struct path *pp)
b7337d
 	}
b7337d
 	if (pp->io_err_pathfail_cnt != PATH_IO_ERR_WAITING_TO_CHECK)
b7337d
 		return 1;
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &curr_time) != 0 ||
b7337d
-	    (curr_time.tv_sec - pp->io_err_dis_reinstate_time) >
b7337d
-			pp->mpp->marginal_path_err_recheck_gap_time) {
b7337d
+	get_monotonic_time(&curr_time);
b7337d
+	if ((curr_time.tv_sec - pp->io_err_dis_reinstate_time) >
b7337d
+	    pp->mpp->marginal_path_err_recheck_gap_time) {
b7337d
 		io_err_stat_log(4, "%s: reschedule checking after %d seconds",
b7337d
 				pp->dev,
b7337d
 				pp->mpp->marginal_path_err_recheck_gap_time);
b7337d
@@ -410,8 +409,7 @@ static int io_err_stat_time_up(struct io_err_stat_path *pp)
b7337d
 {
b7337d
 	struct timespec currtime, difftime;
b7337d
 
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &currtime) != 0)
b7337d
-		return 0;
b7337d
+	get_monotonic_time(&currtime);
b7337d
 	timespecsub(&currtime, &pp->start_time, &difftime);
b7337d
 	if (difftime.tv_sec < pp->total_time)
b7337d
 		return 0;
b7337d
@@ -424,8 +422,7 @@ static void end_io_err_stat(struct io_err_stat_path *pp)
b7337d
 	struct path *path;
b7337d
 	double err_rate;
b7337d
 
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &currtime) != 0)
b7337d
-		currtime = pp->start_time;
b7337d
+	get_monotonic_time(&currtime);
b7337d
 
b7337d
 	io_err_stat_log(4, "%s: check end", pp->devname);
b7337d
 
b7337d
@@ -474,11 +471,7 @@ static int send_each_async_io(struct dio_ctx *ct, int fd, char *dev)
b7337d
 			ct->io_starttime.tv_sec == 0) {
b7337d
 		struct iocb *ios[1] = { &ct->io };
b7337d
 
b7337d
-		if (clock_gettime(CLOCK_MONOTONIC, &ct->io_starttime) != 0) {
b7337d
-			ct->io_starttime.tv_sec = 0;
b7337d
-			ct->io_starttime.tv_nsec = 0;
b7337d
-			return rc;
b7337d
-		}
b7337d
+		get_monotonic_time(&ct->io_starttime);
b7337d
 		io_prep_pread(&ct->io, fd, ct->buf, ct->blksize, 0);
b7337d
 		if (io_submit(ioctx, 1, ios) != 1) {
b7337d
 			io_err_stat_log(5, "%s: io_submit error %i",
b7337d
@@ -497,8 +490,7 @@ static void send_batch_async_ios(struct io_err_stat_path *pp)
b7337d
 	struct dio_ctx *ct;
b7337d
 	struct timespec currtime, difftime;
b7337d
 
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &currtime) != 0)
b7337d
-		return;
b7337d
+	get_monotonic_time(&currtime);
b7337d
 	/*
b7337d
 	 * Give a free time for all IO to complete or timeout
b7337d
 	 */
b7337d
@@ -513,11 +505,8 @@ static void send_batch_async_ios(struct io_err_stat_path *pp)
b7337d
 		if (!send_each_async_io(ct, pp->fd, pp->devname))
b7337d
 			pp->io_nr++;
b7337d
 	}
b7337d
-	if (pp->start_time.tv_sec == 0 && pp->start_time.tv_nsec == 0 &&
b7337d
-		clock_gettime(CLOCK_MONOTONIC, &pp->start_time)) {
b7337d
-		pp->start_time.tv_sec = 0;
b7337d
-		pp->start_time.tv_nsec = 0;
b7337d
-	}
b7337d
+	if (pp->start_time.tv_sec == 0 && pp->start_time.tv_nsec == 0)
b7337d
+		get_monotonic_time(&pp->start_time);
b7337d
 }
b7337d
 
b7337d
 static int try_to_cancel_timeout_io(struct dio_ctx *ct, struct timespec *t,
b7337d
@@ -556,8 +545,7 @@ static void poll_async_io_timeout(void)
b7337d
 	int		rc = PATH_UNCHECKED;
b7337d
 	int		i, j;
b7337d
 
b7337d
-	if (clock_gettime(CLOCK_MONOTONIC, &curr_time) != 0)
b7337d
-		return;
b7337d
+	get_monotonic_time(&curr_time);
b7337d
 	vector_foreach_slot(io_err_pathvec, pp, i) {
b7337d
 		for (j = 0; j < CONCUR_NR_EVENT; j++) {
b7337d
 			rc = try_to_cancel_timeout_io(pp->dio_ctx_array + j,
b7337d
-- 
b7337d
2.17.2
b7337d