Fri Dec 2 12:38:59 2011 UTC ()
- move disk cache flushing code into a separate function.
- more verbose output if vfs.wapbl.verbose_commit >= 2.
  namely, time taken for each DIOCCACHESYNC calls.
	wapbl_flush: 1322826000.785245900 this transaction = 546304 bytes
	wapbl_cache_sync: 1: dev 0x0 0.017572724
	wapbl_cache_sync: 2: dev 0x0 0.007199825
	wapbl_flush: 1322826011.860771302 this transaction = 431104 bytes
	wapbl_cache_sync: 1: dev 0x0 0.019469753
	wapbl_cache_sync: 2: dev 0x0 0.009473410
	wapbl_flush: 1322829266.489154342 this transaction = 187904 bytes
	wapbl_cache_sync: 1: dev 0x4 0.022270180
	wapbl_cache_sync: 2: dev 0x4 0.030749402
- fix a comment.


(yamt)
diff -r1.47 -r1.48 src/sys/kern/vfs_wapbl.c

cvs diff -r1.47 -r1.48 src/sys/kern/vfs_wapbl.c (expand / switch to context diff)
--- src/sys/kern/vfs_wapbl.c 2011/09/01 09:03:43 1.47
+++ src/sys/kern/vfs_wapbl.c 2011/12/02 12:38:59 1.48
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_wapbl.c,v 1.47 2011/09/01 09:03:43 christos Exp $	*/
+/*	$NetBSD: vfs_wapbl.c,v 1.48 2011/12/02 12:38:59 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.47 2011/09/01 09:03:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.48 2011/12/02 12:38:59 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -1903,11 +1903,49 @@
 }
 
 /*
+ * wapbl_cache_sync: issue DIOCCACHESYNC
+ */
+static int
+wapbl_cache_sync(struct wapbl *wl, const char *msg)
+{
+	const bool verbose = wapbl_verbose_commit >= 2;
+	struct bintime start_time;
+	int force = 1;
+	int error;
+
+	if (!wapbl_flush_disk_cache) {
+		return 0;
+	}
+	if (verbose) {
+		bintime(&start_time);
+	}
+	error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force,
+	    FWRITE, FSCRED);
+	if (error) {
+		WAPBL_PRINTF(WAPBL_PRINT_ERROR,
+		    ("wapbl_cache_sync: DIOCCACHESYNC on dev 0x%x "
+		    "returned %d\n", wl->wl_devvp->v_rdev, error));
+	}
+	if (verbose) {
+		struct bintime d;
+		struct timespec ts;
+
+		bintime(&d);
+		bintime_sub(&d, &start_time);
+		bintime2timespec(&d, &ts);
+		printf("wapbl_cache_sync: %s: dev 0x%jx %ju.%09lu\n",
+		    msg, (uintmax_t)wl->wl_devvp->v_rdev,
+		    (uintmax_t)ts.tv_sec, ts.tv_nsec);
+	}
+	return error;
+}
+
+/*
  * Perform commit operation
  *
  * Note that generation number incrementation needs to
  * be protected against racing with other invocations
- * of wapbl_commit.  This is ok since this routine
+ * of wapbl_write_commit.  This is ok since this routine
  * is only invoked from wapbl_flush
  */
 static int
@@ -1916,19 +1954,10 @@
 	struct wapbl_wc_header *wc = wl->wl_wc_header;
 	struct timespec ts;
 	int error;
-	int force = 1;
 	daddr_t pbn;
 
-	if (wapbl_flush_disk_cache) {
-		/* XXX Calc checksum here, instead we do this for now */
-		error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force,
-		    FWRITE, FSCRED);
-		if (error) {
-			WAPBL_PRINTF(WAPBL_PRINT_ERROR,
-			    ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%x "
-			    "returned %d\n", wl->wl_devvp->v_rdev, error));
-		}
-	}
+	/* XXX Calc checksum here, instead we do this for now */
+	wapbl_cache_sync(wl, "1");
 
 	wc->wc_head = head;
 	wc->wc_tail = tail;
@@ -1955,15 +1984,7 @@
 	if (error)
 		return error;
 
-	if (wapbl_flush_disk_cache) {
-		error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force,
-		    FWRITE, FSCRED);
-		if (error) {
-			WAPBL_PRINTF(WAPBL_PRINT_ERROR,
-			    ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%x "
-			    "returned %d\n", wl->wl_devvp->v_rdev, error));
-		}
-	}
+	wapbl_cache_sync(wl, "2");
 
 	/*
 	 * If the generation number was zero, write it out a second time.