From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Whitehouse Date: Fri, 11 Jul 2014 17:05:01 +0100 Subject: [Cluster-devel] [gfs2-utils PATCH] fsck.gfs2: time each of the passes In-Reply-To: <1927182008.6308945.1405011181430.JavaMail.zimbra@redhat.com> References: <1927182008.6308945.1405011181430.JavaMail.zimbra@redhat.com> Message-ID: <53C00B2D.2070001@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, On 10/07/14 17:53, Bob Peterson wrote: > Hi, > > This patch reports how much time was taken in each pass. > > Regards, > > Bob Peterson > Red Hat File Systems > > Signed-off-by: Bob Peterson > --- > gfs2/fsck/main.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c > index 81b7dd5..785f0c4 100644 > --- a/gfs2/fsck/main.c > +++ b/gfs2/fsck/main.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #define _(String) gettext(String) > #include > > @@ -247,11 +248,14 @@ static const struct fsck_pass passes[] = { > static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) > { > int ret; > + long hh, mm, ss, ms; > + struct timeval before, after; > > if (fsck_abort) > return FSCK_CANCELED; > pass = p->name; > log_notice( _("Starting %s\n"), p->name); > + gettimeofday(&before, 0); > ret = p->f(sdp); > if (ret) > exit(ret); > @@ -260,7 +264,20 @@ static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) > log_notice( _("%s interrupted \n"), p->name); > return FSCK_CANCELED; > } > - log_notice( _("%s complete \n"), p->name); > + gettimeofday(&after, 0); > + hh = (after.tv_sec - before.tv_sec) / 3600; > + mm = ((after.tv_sec - before.tv_sec) / 60) - (hh * 60); > + ss = ((after.tv_sec - before.tv_sec)) - (hh * 3600) - (mm * 60); > + ms = after.tv_usec - before.tv_usec; > + if (ms < 0) > + ms += 1000000; Use timersub() here perhaps? Otherwise looks good, Steve. > + ms /= 1000; > + log_notice( _("%s completed in "), p->name); > + if (hh) > + log_notice("%ldh", hh); > + if (mm) > + log_notice("%ldm", mm); > + log_notice("%ld.%03lds \n", ss, ms); > return 0; > } > >