All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [gfs2-utils PATCH] fsck.gfs2: time each of the passes
Date: Fri, 11 Jul 2014 18:58:05 +0100	[thread overview]
Message-ID: <53C025AD.5000505@redhat.com> (raw)
In-Reply-To: <493564610.7001303.1405100463558.JavaMail.zimbra@redhat.com>

Hi,

On 11/07/14 18:41, Bob Peterson wrote:
> ----- Original Message -----
> (snip)
>> Use timersub() here perhaps?
>>
>> Otherwise looks good,
>>
>> Steve.
> Hi Steve,
>
> Thanks for the suggestion. How about this version?
Yes, that looks better. There is probably a nicer way to do the 
conversion to string too... a quick google points at using a time_t to 
contain tv_secs, converting to tm and then appending the tv_usecs after. 
Should be a bit cleaner than doing it manually,

Steve.

> Bob Peterson
> Red Hat File Systems
> ---
> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
> index 81b7dd5..2c51e80 100644
> --- a/gfs2/fsck/main.c
> +++ b/gfs2/fsck/main.c
> @@ -11,6 +11,7 @@
>   #include <signal.h>
>   #include <libintl.h>
>   #include <locale.h>
> +#include <sys/time.h>
>   #define _(String) gettext(String)
>   #include <syslog.h>
>   
> @@ -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, diff;
>   
>   	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,18 @@ 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);
> +	timersub(&after, &before, &diff);
> +	hh = diff.tv_sec / 3600;
> +	mm = (diff.tv_sec / 60) - (hh * 60);
> +	ss = diff.tv_sec - (hh * 3600) - (mm * 60);
> +	ms = diff.tv_usec / 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;
>   }
>   



  reply	other threads:[~2014-07-11 17:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <187372922.6308414.1405011111441.JavaMail.zimbra@redhat.com>
2014-07-10 16:53 ` [Cluster-devel] [gfs2-utils PATCH] fsck.gfs2: time each of the passes Bob Peterson
2014-07-11 16:05   ` Steven Whitehouse
2014-07-11 17:41     ` Bob Peterson
2014-07-11 17:58       ` Steven Whitehouse [this message]
2014-07-11 19:44         ` Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C025AD.5000505@redhat.com \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.