Skip to contentSkip to conversation

fsck.gfs2: Improve reporting of pass timings

PATCH New Andrew Price 2 participants 4 messages Nov 13, 2014 – Nov 14, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fsck.gfs2: Improve reporting of pass timings

The days value is not currently reported in the pass timings but the hours value is still reported modulo 24. Drop the use of gmtime(3) as it's more appropriate for calendar time operations than elapsed time, and add a simple duration reporting function which matches the existing output format.

---
 gfs2/fsck/main.c | 48 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 14 deletions(-)
gfs2/fsck/main.c +34 -14
index b25d802..a4af25d 100644
@@ -246,18 +246,46 @@ static const struct fsck_pass passes[] = {
 	{ .name = NULL, }
 };
 
+static void print_pass_duration(const char *name, struct timeval *start)
+{
+	char duration[17] = ""; /* strlen("XXdXXhXXmXX.XXXs") + 1 */
+	struct timeval end, diff;
+	unsigned d, h, m, s;
+	char *p = duration;
+
+	gettimeofday(&end, NULL);
+	timersub(&end, start, &diff);
+
+	s = diff.tv_sec % 60;
+	diff.tv_sec /= 60;
+	m = diff.tv_sec % 60;
+	diff.tv_sec /= 60;
+	h = diff.tv_sec % 24;
+	d = diff.tv_sec / 24;
+
+	if (d)
+		p += snprintf(p, 4, "%ud", d > 99 ? 99U : d);
+	if (h)
+		p += snprintf(p, 4, "%uh", h);
+	if (m)
+		p += snprintf(p, 4, "%um", m);
+
+	snprintf(p, 8, "%u.%03lus", s, diff.tv_usec / 1000);
+	log_notice(_("%s completed in %s\n"), name, duration);
+}
+
 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;
+	struct timeval timer;
 
 	if (fsck_abort)
 		return FSCK_CANCELED;
 	pass = p->name;
+
 	log_notice( _("Starting %s\n"), p->name);
-	gettimeofday(&before, 0);
+	gettimeofday(&timer, NULL);
+
 	ret = p->f(sdp);
 	if (ret)
 		exit(ret);
@@ -266,16 +294,8 @@ static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp)
 		log_notice( _("%s interrupted   \n"), p->name);
 		return FSCK_CANCELED;
 	}
-	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);
+
+	print_pass_duration(p->name, &timer);
 	return 0;
 }
 
Signature · 1 line
1.9.3
#1 lore raw

PATCH 2/2 mkfs.gfs2: Revert default resource group size

Choose a more performant resource group size than the maximum by default until gfs2 is more tuned for the larger number of bitmap blocks required for 2GB resource groups.

---
 gfs2/mkfs/main_mkfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gfs2/mkfs/main_mkfs.c +1 -1
index b6353dd..2590ec8 100644
@@ -147,7 +147,7 @@ static void opts_init(struct mkfs_opts *opts)
 	opts->bsize = GFS2_DEFAULT_BSIZE;
 	opts->jsize = GFS2_DEFAULT_JSIZE;
 	opts->qcsize = GFS2_DEFAULT_QCSIZE;
-	opts->rgsize = GFS2_MAX_RGSIZE;
+	opts->rgsize = GFS2_DEFAULT_RGSIZE;
 	opts->lockproto = "lock_dlm";
 	opts->locktable = "";
 	opts->confirm = 1;
Signature · 1 line
1.9.3
#2 lore raw

PATCH 2/2 mkfs.gfs2: Revert default resource group size

----- Original Message -----

Quoted 23 lines

Choose a more performant resource group size than the maximum by default until gfs2 is more tuned for the larger number of bitmap blocks required for 2GB resource groups.

---
 gfs2/mkfs/main_mkfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gfs2/mkfs/main_mkfs.c +1 -2
index b6353dd..2590ec8 100644
@@ -147,7 +147,7 @@ static void opts_init(struct mkfs_opts *opts)
 	opts->bsize = GFS2_DEFAULT_BSIZE;
 	opts->jsize = GFS2_DEFAULT_JSIZE;
 	opts->qcsize = GFS2_DEFAULT_QCSIZE;
-	opts->rgsize = GFS2_MAX_RGSIZE;
+	opts->rgsize = GFS2_DEFAULT_RGSIZE;
 	opts->lockproto = "lock_dlm";
 	opts->locktable = "";
 	opts->confirm = 1;
--
Quoted 2 lines

1.9.3

ACK

Bob Peterson
Red Hat File Systems

#3 lore raw

PATCH 1/2 fsck.gfs2: Improve reporting of pass timings

In reply to Andrew Price

----- Original Message -----

Quoted 8 lines

The days value is not currently reported in the pass timings but the hours value is still reported modulo 24. Drop the use of gmtime(3) as it's more appropriate for calendar time operations than elapsed time, and add a simple duration reporting function which matches the existing output format.

---

ACK

Bob Peterson
Red Hat File Systems