fsck.gfs2: time each of the passes
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 fsck.gfs2: time each of the passes
Hi,
This patch reports how much time was taken in each pass.
Regards,
Bob Peterson
Red Hat File Systems
--- gfs2/fsck/main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
gfs2/fsck/main.c +18 -1
@@ -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;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 ; + 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 ; }
PATCH 1/1 fsck.gfs2: time each of the passes
Hi,
Quoted 43 lines · Bob Peterson
Hi,
This patch reports how much time was taken in each pass.
Regards,
Bob Peterson
Red Hat File SystemsSigned-off-by Bob Peterson <[email protected]>--- gfs2/fsck/main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)gfs2/fsck/main.c +4
-0@@ -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;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);
gfs2/fsck/main.c static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) · line 273
Quoted 10 lines
gfs2/fsck/main.c +7
-1return 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.
Quoted 11 lines
gfs2/fsck/main.c +7
-0+ 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 ; }
PATCH 1/1 fsck.gfs2: time each of the passes
----- Original Message -----
(snip)
Quoted 5 lines
Use
timersub()here perhaps?Otherwise looks good,
Steve.
Hi Steve,
Thanks for the suggestion. How about this version?
Bob Peterson
Red Hat File Systems
---
gfs2/fsck/main.c +16 -1
@@ -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 ; }
PATCH 1/1 fsck.gfs2: time each of the passes
Hi,
Quoted 10 lines · Bob Peterson
----- Original Message -----
(snip)Quoted 5 lines
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.
Quoted 50 lines
Bob Peterson
Red Hat File Systems
---gfs2/fsck/main.c +16
-1@@ -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 ; }
PATCH 1/1 fsck.gfs2: time each of the passes
----- Original Message -----
Quoted 12 lines
Hi,
Quoted 9 lines · Bob Peterson
----- Original Message -----
(snip)Quoted 5 lines
Use
timersub()here perhaps?Otherwise looks good,
Steve.
Hi Steve,
Quoted 7 lines
Quoted 1 line
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_tto containtv_secs, converting to tm and then appending thetv_usecsafter. Should be a bit cleaner than doing it manually,Steve.
Hi,
I could implement your suggestion like this. I could also use strftime, but it's ugly as sin, so I'm reluctant to do so. What do you think?
Regards,
Bob Peterson
---
gfs2/fsck/main.c +16 -1
@@ -11,6 +11,8 @@#include <signal.h> #include <libintl.h> #include <locale.h> +#include <sys/time.h> +#include <time.h> #define _ (String) gettext(String)#include "copyright.cf"
@@ -244,11 +246,15 @@ static const struct fsck_pass passes[] = {static int fsck_pass (const struct fsck_pass *p,struct gfs2_sbd *sdp) {int ret; +struct timeval before, after, diff; +time_t runtime; +struct tm *run_tm;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);
@@ -257,7 +263,16 @@ 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); + runtime = (time_t )diff.tv_sec; + run_tm =gmtime (&runtime); +log_notice (_ ("%s completed in " ), p->name); +if (run_tm->tm_hour) +log_notice ("%dh" , run_tm->tm_hour); +if (run_tm->tm_min) +log_notice ("%dm" , run_tm->tm_min); +log_notice ("%d.%03lds \n" , run_tm->tm_sec, diff.tv_usec /1000 );return 0 ; }