From 6470837534a8d4aef4120d961d802ec4ed93e0e0 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 2 Aug 2023 13:31:57 +0300 Subject: [PATCH] LU-17011 utils: monotonic clock in lfs mirror use monotonic clocks instead of realtime to avoid affecting bandwidth or hanging the transfer if the clock is changed. Lustre-change: https://review.whamcloud.com/51852 Lustre-commit: TBD (from 81498f782e7c31e6e950352f4dbb2aa6f8052131) Test-Parameters: trivial Signed-off-by: Alex Zhuravlev Change-Id: I58cf327d235448e93fa2ed63cefdf4dd01306e71 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51896 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/utils/lfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 459a2d4..699c902 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1058,7 +1058,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int), } } - clock_gettime(CLOCK_REALTIME, &start_time); + clock_gettime(CLOCK_MONOTONIC, &start_time); now = last_bw_print = start_time; while (1) { @@ -1123,7 +1123,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int), if (bandwidth_bytes_sec == 0) continue; - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); diff = timespec_sub(&start_time, &now); write_target = ((bandwidth_bytes_sec * diff.tv_sec) + ((bandwidth_bytes_sec * @@ -1143,7 +1143,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int), NSEC_PER_SEC / bandwidth_bytes_sec; do { - rc = clock_nanosleep(CLOCK_REALTIME, 0, + rc = clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, &delay); } while (rc < 0 && errno == EINTR); @@ -1158,7 +1158,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int), } } - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); if (stats_interval_sec && (write_bytes != file_size_bytes) && (now.tv_sec >= last_bw_print.tv_sec + stats_interval_sec)) { @@ -1174,7 +1174,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int), /* Output at least one log, regardless of stats_interval */ if (stats_interval_sec) { - clock_gettime(CLOCK_REALTIME, &now); + clock_gettime(CLOCK_MONOTONIC, &now); stats_log(&now, &start_time, read_bytes, write_bytes, file_size_bytes); } -- 1.8.3.1