You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xfsprogs/SOURCES/xfsprogs-6.5.0-xfs_repair.x...

111 lines
3.5 KiB

From fcac184ccf342a345ea8fe4d842415841af89e64 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Tue, 23 Apr 2024 14:36:15 +0200
Subject: [PATCH] xfs_repair: make duration take time_t
In most of the uses of duration() takes time_t instead of int.
Convert the rest to use time_t and make duration() take time_t to
not truncate it to int.
While at it remove unnecessary parentheses around 'elapsed'.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
repair/globals.c | 2 +-
repair/globals.h | 2 +-
repair/progress.c | 9 +++++----
repair/progress.h | 2 +-
repair/xfs_repair.c | 2 +-
5 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/repair/globals.c b/repair/globals.c
index a68929bd..24f720c4 100644
--- a/repair/globals.c
+++ b/repair/globals.c
@@ -116,7 +116,7 @@ uint32_t sb_width;
struct aglock *ag_locks;
struct aglock rt_lock;
-int report_interval;
+time_t report_interval;
uint64_t *prog_rpt_done;
int ag_stride;
diff --git a/repair/globals.h b/repair/globals.h
index a67e384a..b83a8ae6 100644
--- a/repair/globals.h
+++ b/repair/globals.h
@@ -160,7 +160,7 @@ struct aglock {
extern struct aglock *ag_locks;
extern struct aglock rt_lock;
-extern int report_interval;
+extern time_t report_interval;
extern uint64_t *prog_rpt_done;
extern int ag_stride;
diff --git a/repair/progress.c b/repair/progress.c
index f6c4d988..2ce36cef 100644
--- a/repair/progress.c
+++ b/repair/progress.c
@@ -265,15 +265,16 @@ progress_rpt_thread (void *p)
(current_phase == 7))) {
/* for inode phase report % complete */
do_log(
- _("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %d %s per minute\n"),
+ _("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %ld %s per minute\n"),
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
current_phase, duration(elapsed, msgbuf),
- (int) (60*sum/(elapsed)), *msgp->format->type);
+ 60 * sum / elapsed, *msgp->format->type);
do_log(
_("\t- %02d:%02d:%02d: Phase %d: %" PRIu64 "%% done - estimated remaining time %s\n"),
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
current_phase, percent,
- duration((int) ((*msgp->total - sum) * (elapsed)/sum), msgbuf));
+ duration((*msgp->total - sum) * elapsed / sum,
+ msgbuf));
}
if (pthread_mutex_unlock(&msgp->mutex) != 0) {
@@ -420,7 +421,7 @@ timestamp(int end, int phase, char *buf)
}
char *
-duration(int length, char *buf)
+duration(time_t length, char *buf)
{
int sum;
int weeks;
diff --git a/repair/progress.h b/repair/progress.h
index 2c1690db..9575df16 100644
--- a/repair/progress.h
+++ b/repair/progress.h
@@ -38,7 +38,7 @@ extern void summary_report(void);
extern int set_progress_msg(int report, uint64_t total);
extern uint64_t print_final_rpt(void);
extern char *timestamp(int end, int phase, char *buf);
-extern char *duration(int val, char *buf);
+extern char *duration(time_t val, char *buf);
extern int do_parallel;
#define PROG_RPT_INC(a,b) if (ag_stride && prog_rpt_done) (a) += (b)
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index ba9d2833..2ceea87d 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -377,7 +377,7 @@ process_args(int argc, char **argv)
do_prefetch = 0;
break;
case 't':
- report_interval = (int)strtol(optarg, NULL, 0);
+ report_interval = strtol(optarg, NULL, 0);
break;
case 'e':
report_corrected = true;
--
2.45.2