* [PATCH] fsck: use monotonic time to fsck run time measurement
@ 2015-02-03 18:51 Sami Kerola
2015-02-10 10:26 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2015-02-03 18:51 UTC (permalink / raw)
To: util-linux; +Cc: Sami Kerola
Earlier use of gettimeofday() resulted to wrong measurement if system
administrator did manual time changes, or NTP or adjtime(3) adjusment
happen during fsck run.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/Makemodule.am | 4 ++--
disk-utils/fsck.c | 14 +++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/disk-utils/Makemodule.am b/disk-utils/Makemodule.am
index 2280b9d..b4606a1 100644
--- a/disk-utils/Makemodule.am
+++ b/disk-utils/Makemodule.am
@@ -83,8 +83,8 @@ endif #BUILD_SWAPLABEL
if BUILD_FSCK
sbin_PROGRAMS += fsck
dist_man_MANS += disk-utils/fsck.8
-fsck_SOURCES = disk-utils/fsck.c
-fsck_LDADD = $(LDADD) libmount.la libblkid.la libcommon.la
+fsck_SOURCES = disk-utils/fsck.c lib/monotonic.c
+fsck_LDADD = $(LDADD) libmount.la libblkid.la libcommon.la $(CLOCKGETTIME_LIBS)
fsck_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir) -I$(ul_libblkid_incdir)
endif
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 277d041..78ad43e 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -54,6 +54,7 @@
#include "c.h"
#include "closestream.h"
#include "fileutils.h"
+#include "monotonic.h"
#define XALLOC_EXIT_CODE FSCK_EX_ERROR
#include "xalloc.h"
@@ -577,20 +578,19 @@ static int progress_active(void)
*/
static void print_stats(struct fsck_instance *inst)
{
- double time_diff;
+ struct timeval delta;
if (!inst || !report_stats || noexecute)
return;
- time_diff = (inst->end_time.tv_sec - inst->start_time.tv_sec)
- + (inst->end_time.tv_usec - inst->start_time.tv_usec) / 1E6;
+ timersub(&inst->end_time, &inst->start_time, &delta);
fprintf(stdout, "%s: status %d, rss %ld, "
- "real %f, user %d.%06d, sys %d.%06d\n",
+ "real %ld.%06ld, user %d.%06d, sys %d.%06d\n",
fs_get_device(inst->fs),
inst->exit_status,
inst->rusage.ru_maxrss,
- time_diff,
+ delta.tv_sec, delta.tv_usec,
(int)inst->rusage.ru_utime.tv_sec,
(int)inst->rusage.ru_utime.tv_usec,
(int)inst->rusage.ru_stime.tv_sec,
@@ -676,7 +676,7 @@ static int execute(const char *progname, const char *progpath,
inst->pid = pid;
inst->prog = xstrdup(progname);
inst->type = xstrdup(type);
- gettimeofday(&inst->start_time, NULL);
+ gettime_monotonic(&inst->start_time);
inst->next = NULL;
/*
@@ -789,7 +789,7 @@ static struct fsck_instance *wait_one(int flags)
inst->exit_status = status;
inst->flags |= FLAG_DONE;
- gettimeofday(&inst->end_time, NULL);
+ gettime_monotonic(&inst->end_time);
memcpy(&inst->rusage, &rusage, sizeof(struct rusage));
if (progress && (inst->flags & FLAG_PROGRESS) &&
--
2.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fsck: use monotonic time to fsck run time measurement
2015-02-03 18:51 [PATCH] fsck: use monotonic time to fsck run time measurement Sami Kerola
@ 2015-02-10 10:26 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-02-10 10:26 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Tue, Feb 03, 2015 at 06:51:03PM +0000, Sami Kerola wrote:
> disk-utils/Makemodule.am | 4 ++--
> disk-utils/fsck.c | 14 +++++++-------
> 2 files changed, 9 insertions(+), 9 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-10 10:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03 18:51 [PATCH] fsck: use monotonic time to fsck run time measurement Sami Kerola
2015-02-10 10:26 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox