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

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