Module Name: src
Committed By: bouyer
Date: Wed Feb 16 19:31:44 UTC 2011
Modified Files:
src/sys/kern [netbsd-5]: vfs_wapbl.c
Log Message:
Pull up following revision(s) (requested by tron in ticket #1535):
sys/kern/vfs_wapbl.c: revision 1.39 via patch
Add two sysctls one that does verbose transaction logging and a second one
that disables flushing the disk cache (which is fast but dangerous for
data integrity). From simon a long while back.
To generate a diff of this commit:
cvs rdiff -u -r1.3.8.3 -r1.3.8.4 src/sys/kern/vfs_wapbl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/vfs_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.3.8.3 src/sys/kern/vfs_wapbl.c:1.3.8.4
--- src/sys/kern/vfs_wapbl.c:1.3.8.3 Mon Nov 22 02:52:29 2010
+++ src/sys/kern/vfs_wapbl.c Wed Feb 16 19:31:44 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_wapbl.c,v 1.3.8.3 2010/11/22 02:52:29 riz Exp $ */
+/* $NetBSD: vfs_wapbl.c,v 1.3.8.4 2011/02/16 19:31:44 bouyer Exp $ */
/*-
* Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
* This implements file system independent write ahead filesystem logging.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.3.8.3 2010/11/22 02:52:29 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.3.8.4 2011/02/16 19:31:44 bouyer Exp $");
#include <sys/param.h>
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/vnode.h>
#include <sys/file.h>
@@ -65,6 +66,10 @@
#define wapbl_free(a) free((a), M_WAPBL)
#define wapbl_calloc(n, s) malloc((n)*(s), M_WAPBL, M_WAITOK | M_ZERO)
+static struct sysctllog *wapbl_sysctl;
+static int wapbl_flush_disk_cache = 1;
+static int wapbl_verbose_commit = 0;
+
#else /* !_KERNEL */
#include <assert.h>
#include <errno.h>
@@ -245,8 +250,45 @@
void
wapbl_init()
{
+ int rv;
+ const struct sysctlnode *rnode, *cnode;
malloc_type_attach(M_WAPBL);
+
+ wapbl_sysctl = NULL;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "vfs", NULL,
+ NULL, 0, NULL, 0,
+ CTL_VFS, CTL_EOL);
+ if (rv)
+ return;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "wapbl",
+ SYSCTL_DESCR("WAPBL journaling options"),
+ NULL, 0, NULL, 0,
+ CTL_CREATE, CTL_EOL);
+ if (rv)
+ return;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "flush_disk_cache",
+ SYSCTL_DESCR("flush disk cache"),
+ NULL, 0, &wapbl_flush_disk_cache, 0,
+ CTL_CREATE, CTL_EOL);
+ if (rv)
+ return;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "verbose_commit",
+ SYSCTL_DESCR("show time and size of wapbl log commits"),
+ NULL, 0, &wapbl_verbose_commit, 0,
+ CTL_CREATE, CTL_EOL);
}
int
@@ -1322,6 +1364,13 @@
/* Calculate amount of space needed to flush */
flushsize = wapbl_transaction_len(wl);
+ if (wapbl_verbose_commit) {
+ struct timespec ts;
+ getnanotime(&ts);
+ printf("%s: %lld.%06ld this transaction = %zu bytes\n",
+ __func__, (long long)ts.tv_sec,
+ (long)ts.tv_nsec, flushsize);
+ }
if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) {
/*
@@ -1823,12 +1872,15 @@
int error;
int force = 1;
- /* 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));
+ 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));
+ }
}
wc->wc_head = head;
@@ -1853,11 +1905,14 @@
if (error)
return error;
- 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));
+ 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));
+ }
}
/*